Subject: Re: [xsl] suggestion: xsl:modified-copy From: Michael Kay <mike@xxxxxxxxxxxx> Date: Wed, 01 Aug 2012 11:26:39 +0100 |
We get quite close in XSLT 3.0It's a bit late for 3.0, but perhaps for 3.1... sometimes it would be useful to have the ability to copy and modify a section of the input at the point its copied, rather than using an additional moded identity template and no-op templates.
For example given something like:
<foo> <bar/> <baz/> </foo>
and you want to copy the lot to the result except <baz/> you could do:
<xsl:modified-copy select="foo"> <xsl:except select="baz"/> </xsl:modified-copy>
<xsl:apply-templates select="foo" mode="m"> <xsl:mode name="m" on-no-match="shallow-copy"/> <xsl:template mode="m" match="baz"/>
<xsl:apply-templates select="foo" on-no-match="shallow-copy"> <xsl:template match="baz"/> </xsl:apply-templates>
if you wanted to add another <baz/> you could do:
<xsl:modified-copy select="foo"> <xsl:insert-after select="baz"> <baz/> </xsl:insert-after> </xsl:modified-copy>
Again, that's
<xsl:apply-templates select="foo" mode="m"> <xsl:mode name="m" on-no-match="shallow-copy"/> <xsl:template mode="m" match="baz"> <xsl:next-match/> <baz/> </xsl:template>
Michael Kay Saxonica
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] suggestion: xsl:modified-copy, Andrew Welch | Thread | Re: [xsl] suggestion: xsl:modified-, Andrew Welch |
[xsl] suggestion: xsl:modified-copy, Andrew Welch | Date | Re: [xsl] suggestion: xsl:modified-, Andrew Welch |
Month |