Hi,
I'm trying to run my XSL code as efficiently as possible. I have an extract from my XML file (below):
Code:
<Doc>
<Document>
<Test Code="0001">
<UOM>%</UOM>
<Desc>Moisture</Desc>
<Set No="1">
<Targ>12.33</Targ>
<Min>10.83</Min>
<Max>13.83</Max>
</Set>
<Set No="2">
<Targ>12.33</Targ>
<Min>8.00</Min>
<Max>15.00</Max>
</Set>
<Set No="3">
<Min>10.00</Min>
<Max>14.80</Max>
</Set>
<SampRes No="1">
<Lab>CEN</Lab>
<Fail>N</Fail>
</SampRes>
</Test>
<Test Code="0005">
<UOM>%</UOM>
<Desc>Crude Protein</Desc>
<Set No="1">
<Targ>17.81</Targ>
<Min>16.81</Min>
<Max>18.81</Max>
</Set>
<Set No="2">
<Targ>17.80</Targ>
<Min>16.02</Min>
<Max>21.36</Max>
</Set>
<Set No="3">
<Targ>17.81</Targ>
<Min>16.03</Min>
<Max>21.37</Max>
</Set>
<SampRes No="1">
<Lab>CEN</Lab>
<Fail>N</Fail>
</SampRes>
</Test>
</Document>
</Doc>
How do I loop through each '<Test Code="xxxx">' and display each child node and the relevant fields? I understand the 'For Each' statement, but I wonder whether there is a more automated system.
Code:
<xsl:template name="Test">
<xsl:for-each select="*//Test">
<xsl:element name="Test">
<xsl:attribute name="Code">
<xsl:value-of select="@*"/>
The above obviously produces:
Code:
<Test Code="0001" />
<Test Code="0005" />
How do I retrieve and display each child node (and all other dependant fields) for each 'Test'?
For Example
How do I return the individual values for?
The <UOM> value
The <Set> Value
The <Target> value
Neal
A Northern Soul