Making XSLT ignore a node in the source
Posted: Wed May 03, 2006 6:43 pm
does anyone have a way to create a template in XSLT that in effect removes a node (but not its children) from the input document and then continues to process as if it had never been there.
By example I have the following XML
My XSL MUST contain a match="columns/column" and can not contain a match simply for "column" as this will find many other nodes that are not relevant.
My aim is to output the nodes with ids "aaa" to "eee" but not to output "111" to "333"
I appreciate I could change the match to include columns/column AND columns/ignoreme/column but that is not practical in the real process.
So what I am looking for is a way to ADD something to the existing stylesheets that in effect causes the remaining stylesheet to act as if the <ignoreme> nodes had never existed and that the child <column> nodes were the immediate children of <columns>
Is there something that can be done with <xsl:copy-of/> that places the child nodes in the output tree but then processes it again?
I am not a newbie and can assure you that if it were possible to alter the existing styles to xpath matches that ignored the nodes then I would - if only!
Many thanks for any assistance
Graeme
By example I have the following XML
Code: Select all
<root>
<columns>
<column id="aaa" />
<column id="bbb" />
<ignoreme>
<column id="ccc" />
<column id="ddd" />
</ignoreme>
<differentstuff>
<column id="111" />
<column id="222" />
<column id="333" />
</differentstuff>
<column id="eee" />
</columns>
</root>
My aim is to output the nodes with ids "aaa" to "eee" but not to output "111" to "333"
I appreciate I could change the match to include columns/column AND columns/ignoreme/column but that is not practical in the real process.
So what I am looking for is a way to ADD something to the existing stylesheets that in effect causes the remaining stylesheet to act as if the <ignoreme> nodes had never existed and that the child <column> nodes were the immediate children of <columns>
Is there something that can be done with <xsl:copy-of/> that places the child nodes in the output tree but then processes it again?
I am not a newbie and can assure you that if it were possible to alter the existing styles to xpath matches that ignored the nodes then I would - if only!
Many thanks for any assistance
Graeme