XSLT:使用 & 定义参数与号

发布于 2024-09-08 04:18:09 字数 393 浏览 18 评论 0原文

我需要使用包含 & 字符的字符串定义一个 xsl:param 以便进一步处理。 例如:

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

重要通知: 我在 Web 服务工具中使用 xslt 转换器组件。我所做的是,我只是初始化 param ,并且在调用 Web 服务时,将 param 设置为在前面的步骤中设置的变量的值。所以我无法控制字符串,即意味着我无法使用 &amp;

有什么想法如何做到这一点?

提前致谢。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤者何惧 2024-09-15 04:18:09

对其进行编码。

& 编码为 &

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

请参阅 有关 XML 字符实体的文档。

另一种选择是将此类字符串包含在 CDATA 部分中:

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

Encode it.

& is encoded as &:

<xsl:param name="greeting" as="xs:string">Hi & 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>
吲‖鸣 2024-09-15 04:18:09

您可以尝试将字符串存储为未解析的字符数据 (CDATA)。在这种情况下标记字符串将通知 XML 解析器不应解析所包含的信息:

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文