RE: [xsl] This could be simple, but not for me!

Subject: RE: [xsl] This could be simple, but not for me!
From: "Kenny Akridge" <kenny@xxxxxxxxxxxxxxxxx>
Date: Tue, 25 May 2004 08:44:46 -0400
The best way to approach this is to find out what you need to do logically.
Based on your output, this is my though:

Match every unique occurrence of Root/Community/A/B/Info/Detail/@no (use a
template of a for-each)
	Concat the value of @no, Detail.
	Loop through all the matches of Detail and Detail/@no (most likely
using a key, but you could use other means)
		Print the ancestor::City and the preceding-sibling::Name

Of course, you didn't provide an actual spec, and this could be completely
wrong given your rules.  This ought to help you approach it though.  With
most programming, it is usually just a logical decomposition into functions.


-----Original Message-----
From: Kenny Bogoe (BogoeMD) [mailto:kenny@xxxxxxxxx] 
Sent: Tuesday, May 25, 2004 7:15 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] This could be simple, but not for me!

Hi,

Though I have been working sometime with XSLT, I am having trouble with this
transformation. Anyone know how to do this? The XML source is from a
database and is really really huge in size, so performance of the
transformation is very critical...


<Root>
    <Community>
        <City>City1</City>
        <A>
            <B>
                <Name>Name1</Name>
                <Info>
                    <Detail no="100">Red</Detail>
                </Info>
            </B>
            <B>
                <Name>Name2</Name>
                <Info>
                    <Detail no="200">Blue</Detail>
                </Info>
            </B>
            <B>
                <Name>Name3</Name>
                <Info>
                    <Detail no="300">Green</Detail>
                </Info>
            </B>
        </A>
    </Community>
    <Community>
        <City>City2</City>
        <A>
            <B>
                <Name>Name4</Name>
                <Info>
                    <Detail no="100">Red</Detail>
                </Info>
            </B>
            <B>
                <Name>Name5</Name>
                <Info>
                    <Detail no="200">Blue</Detail>
                </Info>
            </B>
            <B>
                <Name>Name6</Name>
                <Info>
                    <Detail no="400">Yellow</Detail>
                </Info>
            </B>
        </A>
    </Community>
</Root>


This is the result I need to produce:


100, Red

    City1
        Name1
    
    City2
        Name4
    
    
200, Blue

    City1
        Name2
        
    City2
        Name5
        
300, Green

    City1
        Name3
        
400, Yellow

    City2
        Name6

Current Thread