Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 7th, 2006, 03:14 AM
Friend of Wrox
Points: 696, Level: 9
Points: 696, Level: 9 Points: 696, Level: 9 Points: 696, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: Ennis, Clare, Ireland.
Posts: 129
Thanks: 10
Thanked 0 Times in 0 Posts
Default Child Node Output

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
__________________
Neal

A Northern Soul
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Process all nested child node tims XSLT 4 April 8th, 2008 07:45 AM
The reference node is not a child of this node.XSL XMLUser XSLT 2 February 25th, 2008 05:22 AM
how to append child node after an node in XML + C# vishnu108mishra XML 5 November 13th, 2007 05:30 AM
How to count the child node suri_1811 XSLT 6 November 10th, 2006 04:51 PM
Copying Source Node attributes to output node pvsat XSLT 2 November 3rd, 2005 09:46 AM



All times are GMT -4. The time now is 10:26 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.