![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: XSLT: Moving node in document >Thread Next - Re: XSLT: Moving node in document Re: XSLT: Moving node in documentTo: NULL Date: 4/1/2005 9:27:00 AM
> Could you give me a hint how to parameterise this?
I knew you were going to ask that:-)
<xsl:template match="node[@id='{$nodeid}']"/>
that would never work, { _never_ has any special meaning in an XPath
expression or, as here, in an XSLT pattern. They are used to _surround_
Xpath expressions in XSLT Attribute value templates, but they are not
part of Xpath.
The syntax should be
<xsl:template match="node[@id=$nodeid]"/>
except that in a failed attempt to prevent circular definitions, any use
of variables in match patterns is outlawed in XSLT1 so you can't do
this. (You will be able to do it in XSLT2 as this restriction is
dropped in XSLT2 draft.)
Similarly for
<xsl:copy-of select="@*|//node[@id='{$nodeid}']"/>
except that here of course you can use a variable in XSLT1:
<xsl:copy-of select="@*|//node[@id=$nodeid]"/>
The reason why the restriction on variables in match patterns is
annoying (and will be removed) is that it's easy to circumvent it, in
this case for example you could do:
<xsl:template match="node">
<xsl:choose>
<xsl:when test="@id='$nodeid"/>
<xsl:otherwise>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:if test="@id=$nodeparent">
<xsl:copy-of select="//node[@id='$nodeid']"/>
</xsl:if>
<xsl:apply-templates/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
