XSLT:使用 & 定义参数与号
我需要使用包含 &
字符的字符串定义一个 xsl:param
以便进一步处理。 例如:
<xsl:param name="greeting" as="xs:string">Hi & Bye</xsl:param>
重要通知: 我在 Web 服务工具中使用 xslt 转换器组件。我所做的是,我只是初始化 param
,并且在调用 Web 服务时,将 param
设置为在前面的步骤中设置的变量的值。所以我无法控制字符串,即意味着我无法使用 &
有什么想法如何做到这一点?
提前致谢。
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 &
Any ideas how to do that?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对其进行编码。
&
编码为&
:请参阅 此有关 XML 字符实体的文档。
另一种选择是将此类字符串包含在
CDATA
部分中:Encode it.
&
is encoded as&
:See this document about XML Character entities.
Another option is to enclose such strings in
CDATA
sections:您可以尝试将字符串存储为未解析的字符数据 (CDATA)。在这种情况下标记字符串将通知 XML 解析器不应解析所包含的信息:
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: