Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XSLT: Moving node in document

From: David Carlisle <davidc@---.--.-->
To: 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>
  


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent