Subject: Re: [xsl] Understanding Identity Transformations From: "Joris Gillis" <roac@xxxxxxxxxx> Date: Sat, 12 Feb 2005 19:28:13 +0100 |
Recursive algorithms are not a priori infinite. The copying stops when all nodes have been copied.Is the nature of identifty transformations recursive? How does the engine know that eventually the recursive call is going to run out?
I have a large document, I am interested in transforming it. I want to reproduce the xml source but restricted for a specific value match. I totally understand how to write the appropriate select in an apply-template rule to get the desired results, but do not understand how to mix this call up with the recursive template identity tranformation. So, starting with SAMPLE_002, where would I stub out and add the qualifying select? What confuses me, is that in the sample we are saying (basically) grab everything from the top to the bottom and at every level. I'm affraid that my select on an element who's value is '1234' is going to mess up the results. I hope this makes sense and I understand the concept of changing a single element, or single attribute by setting up the match, but in this case, I need the parent node, and all of the child nodes.
XML: <root> <part1> <!--I will be copied--> <node copy="yes">So do <b>I</b>.</node> </part1> <part2> <node copy="no">I <b>don't</b> feel like being copied today</node> <data> <value>1</value> <value>2</value> <value>3</value> </data> </part2> </root>
OUTPUT: <result> <part1> <!--I will be copied-->
<node copy="yes">So do <bold>I</bold>.</node> </part1> <p>I don't feel like being copied today</p> <p>Sum= 6</p> </result>
<xsl:template match="root"> <result> <xsl:apply-templates select="part1" mode="IdTr"/> <xsl:apply-templates select="part2"/> </result> </xsl:template>
<xsl:template match="node"> <p><xsl:apply-templates/></p> </xsl:template>
<xsl:template match="data"> <p>Sum= <xsl:value-of select="sum(value)"/></p> </xsl:template>
<xsl:template match="@* | node()" mode="IdTr"> <xsl:copy> <xsl:apply-templates select="@* | node()" mode="IdTr"/> </xsl:copy> </xsl:template>
<xsl:template match="b" mode="IdTr"> <bold><xsl:apply-templates/></bold> </xsl:template>
regards, -- Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041) Gaudiam omnibus traderat W3C, nec vana fides
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Understanding Identity Tr, David Carlisle | Thread | Re: [xsl] Understanding Identity Tr, Karl Stubsjoen |
Re: [xsl] Understanding Identity Tr, David Carlisle | Date | Re: [xsl] Understanding Identity Tr, Karl Stubsjoen |
Month |