Re: split xml based on node name - SOLVED
Posted: Mon Oct 01, 2018 7:07 pm
Hi All,
I'm trying to split an xml into individual orders but cannot get it to split and use the required name. See below for sample xml and xslt
What I'm trying to do is split and save based on "Design Number" ie GC155 but I can't get the XSLT to see that field name.
I believe I'm almost there but cannot see the simple mistake I'm making.
Can you help me out please.
TIA
Andrew
XML
<?xml version="1.0" encoding="UTF-8"?>
<csv entries="37">
<entry num="1">
<field name="Design Number">GC155</field>
<field name="Range">Christmas</field>
<field name="Envelope Colour"></field>
<field name="ize">150x150</field>
<field name="QUANTITY ORDERED">60</field>
<field name="PRINTED"></field>
</entry>
XSLT
<xsl:template match="/csv/entry">
<xsl:result-document method="xml" href="{/field/[@name="Design Number"]/value}.xml">
<xsl:copy-of select="." />
</xsl:result-document>
</xsl:template>
I'm trying to split an xml into individual orders but cannot get it to split and use the required name. See below for sample xml and xslt
What I'm trying to do is split and save based on "Design Number" ie GC155 but I can't get the XSLT to see that field name.
I believe I'm almost there but cannot see the simple mistake I'm making.
Can you help me out please.
TIA
Andrew
XML
<?xml version="1.0" encoding="UTF-8"?>
<csv entries="37">
<entry num="1">
<field name="Design Number">GC155</field>
<field name="Range">Christmas</field>
<field name="Envelope Colour"></field>
<field name="ize">150x150</field>
<field name="QUANTITY ORDERED">60</field>
<field name="PRINTED"></field>
</entry>
XSLT
<xsl:template match="/csv/entry">
<xsl:result-document method="xml" href="{/field/[@name="Design Number"]/value}.xml">
<xsl:copy-of select="." />
</xsl:result-document>
</xsl:template>