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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--