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

How to address generic unknown elements !

Subject: How to address generic unknown elements !
From: Delaney Robin <Robin.Delaney@xxxxxxx>
Date: Thu, 14 Nov 2002 13:04:27 +0100
xsl value of unknown node
I have been using XML's with "known" element names that I could address but
I need to change it to be more generic so that I can 
run a stylesheet over an XML without knowing the structure beforehand:

XML:
	<ABC>
		<BCD>
			<EFG>
				<etc.....>
			</EFG>
		</BCD>
		<BCD>
			<EFG>
				<etc.....>
			</EFG>
		</BCD>
	</ABC>

old XSL:
	<xsl:template match="ABC">
		<xsl:for-each select="BCD[1]//*[not(*)]">	 
				<xsl:value-of select="local-name()"/>	
			</xsl:for-each> 
		</xsl:template>

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

That gives me the drill down node-names from the first occurence of BCD and
the drill down node values of all BCD's.

I'm trying to have: (or similar!)
	<xsl:template match="/">
		<xsl:for-each select="?//*[not(*)]">	 ???stuck here???
			<xsl:value-of select="local-name()"/>	
		</xsl:for-each> 

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

My match is now "/"  (to process all) instead of ABC as I don't have
specific names to reference.

How do I reference BCD[1] (I know it always begins 2 levels down from the
top node) and drill down to the end of the node 1 time to get the node-names
without knowing it's name ? 

I only want it to do the local-name() piece once (ie. for the 1st element)
whilst doing node() for all elements. 

The node() bit is OK but I can't get the local-name() piece to deliver what
I want instead I end up with "number of iterations" x node-names. I guess
for-each is wrong but I think I'm stuck with 1 template match "/" or am I
thinking wrongly (again!).


Any help appreciated

Thanks,

Robin 



	


 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.