Subject: Re: [xsl] Converting an xml to another xml Using XSLT From: "Jon Gorman" <jonathan.gorman@xxxxxxxxx> Date: Tue, 2 May 2006 15:47:34 -0500 |
I need suggestion or solution how to handle arbitary depth i.e. if "classitem" depth is 5 or 8 or some other value.
Right.....but the confusion is why you're checking for the depth anyhow. The entire point of XSLT is that the processor can do the work of traveling for the tree for you. If you always do the same thing regardless of depth, just put it into one template. To repeat my code templates before (with them cleaned up a little):
<xsl:template match="class"> <hier> <xsl:apply-templates /> </hier> </xsl:template>
<xsl:template match="classitem"> <hierlev> <heading> <title><xsl:value-of select="identifier/name" /></title> </heading> <xsl:apply-templates /> </hierlev> </xsl:template>
<xsl:template match="identifier" /> <xsl:template match="code" />
Given these templates, the code will always produce <hierlev> <heading> <title>name</title> </head> ...whatever output applying templates to children element <hierlev>
Now, a variation might be that you need to do something different based off the depth of the element in the tree. Off the top of my head counting the nodes in the ancestor axis would be the way to do that.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Converting an xml to anot, Tedla, Sridhar \(LNG | Thread | RE: [xsl] Converting an xml to anot, Michael Kay |
RE: [xsl] Converting an xml to anot, Tedla, Sridhar \(LNG | Date | RE: Re: RE: [xsl] Producing Excel 2, cknell |
Month |