views:

15

answers:

2

Hi,

I need to define a xsl:param with a string that contains & character for further processing. For example:

<xsl:param name="greeting" as="xs:string">Hi & Bye</xsl:param>

Important Notice: I am using a xslt converter component in a webservice tool. What I do, is that I just initialize the param and as the webservice is called the param is set to a value of a variable which was set in previous steps. So I have no control on the string, i.e meaning I can't use &amp;

Any ideas how to do that?

Thanks in advance.

+1  A: 

Encode it.

& is encoded as &amp;:

<xsl:param name="greeting" as="xs:string">Hi &amp; Bye</xsl:param>

See this document about XML Character entities.

Another option is to enclose such strings in CDATA sections:

<xsl:param name="greeting" as="xs:string"><![CDATA[Hi & Bye]]></xsl:param>
Oded
Sorry, I didn't mention an important part in the question. please check the edited version. Thank you.
fouad
A: 

You could attempt to store the string as unparsed character data (CDATA). Marking the string in that case will notify an XML parser that the contained information should not be parsed:

<xsl:param name="greeting" as="xs:string"><![CDATA[ Hi & Bye ]]></xsl:param>
Chris Hutchinson