开发者

XSLT: Define a param with & ampersand

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

<xsl:param name="greeting" as="xs:str开发者_JAVA百科ing">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.


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>


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜