xsl-list
[Top] [All Lists]

AW: How to address generic unknown elements !

2002-11-14 06:26:52

I'll try and simplify. Complicated version (sorry Agnes :-) ) in my previous
mail.

XML:
                <ABC>                           1st level
                        <BCD>                   2nd level
                                <EFG>123</EFG>  lower levels
                        </BCD>
                        <BCD>   
                                <EFG>456</EFG>
                        </BCD>
                </ABC>

and without knowing the tag names try to get 
1) tag-names for descendants of the 2nd level tag (in this case BCD) which
don't themselves have descendants (ie. the lowest level in the hierarchy).
Result: EFG  (but only one time)
2) the values of all tags that don't have descendants. Result: 123 456  (i
think this bit is OK)

What I'm getting is: EFGEFG 123456   
What I want is: EFG 123456
                       

Obviously because of the for-each which iterates 2 times.  How do I limit it
to 1st Occurrance of my "level-2" tag and it's decendants. Can I have two
template matches and how would I describe the path ?

        <xsl:template match="/">
                        <xsl:for-each select="?//*[not(*)]">     ???stuck
here???
                                <xsl:value-of select="local-name()"/>   
                        </xsl:for-each> 

                        <xsl:for-each select=".//*[not(*)]">        Getting
Values OK
                                <xsl:value-of select="node()"/> 
                </xsl:template>

Hopefully a bit clearer ! 
 
Thanks in advance,

Robin

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>