[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

param vs context for passing arguments

Subject: param vs context for passing arguments
From: Piotr Dobrogost <pd@xxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 16 Dec 2009 23:46:18 +0100
 param vs context for passing arguments
Hi

This is simple template to replace hyphen with underscore in 'name' attribute of some element;

<xsl:template name="ReplaceHyphenWithUnderscore">
  <xsl:analyze-string select="@name" regex="-">
    <xsl:matching-substring>
      <xsl:text>_</xsl:text>
    </xsl:matching-substring>
    <xsl:non-matching-substring>
      <xsl:value-of select="."/>
    </xsl:non-matching-substring>
  </xsl:analyze-string>
</xsl:template>


I'm using it to transform some of 'xsd:element' elements' 'name' attribute like this;


<xsl:template match="xsd:element[<some condition here>]">
  <xsl:call-template name="ReplaceHyphenWithUnderscore"/>
  (...)
</xsl:template>

Now, I need to do the same transformation with 'xsd:attribute' elements but to another attribute this time - type. I could add a parameter to ReplaceHyphenWithUnderscore template to let know which attribute it should act upon. But this seems to be not in the spirit of xslt. Shouldn't rather ReplaceHyphenWithUnderscore always act upon context node instead? Then it would be a task of caller to set proper context node before calling the template.

How could I change context node (focus) being inside
<xsl:template match="xsd:element[<some condition here>]">
before calling
<xsl:call-template name="ReplaceHyphenWithUnderscore"/>
and reverting it back after this call so following lines of template would be evaluated in the original context set by 'match' clause?



Regards Piotr Dobrogost

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.