Subject: Re: AW: [xsl] How to address generic unknown elements ! From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 14 Nov 2002 14:24:03 GMT |
It helps people understand your problem if you use the right terminoligy > 1) tag-names for descendants Tags don't have names in XSLT/Xpath in fact Tags don't appear at all. Tags are used when XML is written out in a linear fashion, to mark element boundaries. > 2) the values of all tags that don't have descendants. Tags never have descendants (in any XML or SGML context) in <ABC> <BCD/> </ABC> there are three tags, the contents of the start tag ABC is just the element name "ABC", similarly the end tag </ABC>. So TAGS don't nest (which is why attributes can't have structured values) elements do however nest, and teh above three tags do denote two elements, with BCD being inside ABC. If you only want the second level you don't want to use // which will search the entire document (you rarely want to use // it is expensive) <xsl:template match="/"> <xsl:for-each select="/*/*[not(*)]"> <xsl:value-of select="local-name()"/> </xsl:for-each> </xsl:template> to get them just once is a standard grouping problem, see the faq, but to use a key you's do something like <xsl:key name="x" match="/*/*[not(*)]" use="local-name()"/> then change the above to be <xsl:template match="/"> <xsl:for-each select="/*/*[not(*)]"> <xsl:if test="generate-id()=generate-id(key('x',local-name()))"> <xsl:value-of select="local-name()"/> </xsl:if> </xsl:for-each> </xsl:template> See Jeni's site for an explanation of this grouping technique. David _____________________________________________________________________ This message has been checked for all known viruses by Star Internet delivered through the MessageLabs Virus Scanning Service. For further information visit http://www.star.net.uk/stats.asp or alternatively call Star Internet for details on the Virus Scanning Service. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
AW: [xsl] How to address generic un, Delaney Robin | Thread | RE: [xsl] How to address generic un, Américo Albuquerque |
Re: [xsl] Error Using , Joerg Heinicke | Date | [xsl] displaying xslt using xsl:fo, Andrew Welch |
Month |