[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: AW: How to address generic unknown elements !

Subject: Re: AW: How to address generic unknown elements !
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 14 Nov 2002 14:24:03 GMT
xsl unknown tag names
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.