I am trying to go through some xml files and create paths and attributes from them.
I have the following XSL that almost works:
using the xml file:
And the results are:
It seems I am getting the closing nodes as well.
Is there a way to change this so I get something like:
I am not trying to create an XML file but am trying to create a list of paths from an xml file that I want to put in an excel sheet.
I will also be making changes to show the attributes as well.
But I need to not show the path for the closing nodes.
Thanks,
Tom
I have the following XSL that almost works:
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL]
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/*">
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node()">
<path>
<xsl:for-each select="ancestor-or-self::*">
<xsl:text>/</xsl:text>
<xsl:value-of select="name()" />
</xsl:for-each>
</path>
<xsl:apply-templates>
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
using the xml file:
Code:
<RESPONSE MISMOVersionID="2.6">
<REPORT _ID="Major" MajorFormType="Form102">
<FORM _ID="Minor" MinorFormType="Form240">
<IMAGE _ID="Im2"/>
<IMAGE _ID="Im5"/>
</FORM>
</REPORT>
<METHODS Description="THIS IS SUMMARY">
<COMPARISON ID="241" ComparisonAmount="352,000">
<LOCATION ID="HOME"/>
<LOCATION ID="WORK"/>
</COMPARISON>
</METHODS>
</RESPONSE>
And the results are:
Code:
<?xml version="1.0" encoding="utf-8"?>
<path>/RESPONSE</path>
<path>/RESPONSE</path>
<path>/RESPONSE/REPORT</path>
<path>/RESPONSE/REPORT</path>
<path>/RESPONSE/REPORT/FORM</path>
<path>/RESPONSE/REPORT/FORM</path>
<path>/RESPONSE/REPORT/FORM/IMAGE</path>
<path>/RESPONSE/REPORT/FORM</path>
<path>/RESPONSE/REPORT/FORM/IMAGE</path>
<path>/RESPONSE/REPORT/FORM</path>
<path>/RESPONSE/REPORT</path>
<path>/RESPONSE</path>
<path>/RESPONSE/METHODS</path>
<path>/RESPONSE/METHODS</path>
<path>/RESPONSE/METHODS/COMPARISON</path>
<path>/RESPONSE/METHODS/COMPARISON</path>
<path>/RESPONSE/METHODS/COMPARISON/LOCATION</path>
<path>/RESPONSE/METHODS/COMPARISON</path>
<path>/RESPONSE/METHODS/COMPARISON/LOCATION</path>
<path>/RESPONSE/METHODS/COMPARISON</path>
<path>/RESPONSE/METHODS</path>
<path>/RESPONSE</path>
It seems I am getting the closing nodes as well.
Is there a way to change this so I get something like:
Code:
<?xml version="1.0" encoding="utf-8"?>
<path>/RESPONSE</path>
<path>/RESPONSE/REPORT</path>
<path>/RESPONSE/REPORT/FORM</path>
<path>/RESPONSE/REPORT/FORM/IMAGE</path>
<path>/RESPONSE/REPORT/FORM/IMAGE</path>
<path>/RESPONSE/METHODS</path>
<path>/RESPONSE/METHODS/COMPARISON</path>
<path>/RESPONSE/METHODS/COMPARISON/LOCATION</path>
<path>/RESPONSE/METHODS/COMPARISON/LOCATION</path>
I am not trying to create an XML file but am trying to create a list of paths from an xml file that I want to put in an excel sheet.
I will also be making changes to show the attributes as well.
But I need to not show the path for the closing nodes.
Thanks,
Tom