Date: Wed, 16 Dec 2009 23:08:50 -0000
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com>
Subject: RE: [xsl] param vs context for passing arguments
Message-ID: <3D36050C5F484433B4E46968E6F23627(_at_)Sealion>
Your code will be most versatile (reusable) if you write it as a function to
operate on any string.
> <xsl:function name="f:ReplaceHyphenWithUnderscore" as="xs:string">
<xsl:param name="input" as="xs:string"/>
> <xsl:analyze-string select="$input" 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>
With this I get
"XTTE0780: A sequence of more than one item is not allowed as the result
of function f:ReplaceHyphenWithUnderscore() ("_", "_", ...)" error.
Having said that, this particular operation can be achieved by a single call
of translate():
> <xsl:function name="f:ReplaceHyphenWithUnderscore" as="xs:string">
<xsl:param name="input" as="xs:string"/>
<xsl:sequence select="translate($in, '-', '_')"/>
> </xsl:template>
This works ok.
Thanks for help.
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>
--~--