如何在xslt/xquery中将`&lt;br&gt;`转换为`<br>`。

huangapple go评论56阅读模式
英文:

How to convert &lt;br&gt; to <br> in xslt/xquery

问题

我需要将这个请求转换为以下代码并发送到目标系统:

V1&lt;br&gt;V2&lt;br&gt;V3

我该如何在XSLT/查询中进行转换?

英文:

I am getting this request

&lt;description&gt;V1&amp;lt;br&amp;gt;V2&amp;lt;br&amp;gt;V3&lt;/description&gt;

and I need to convert it into below code and send it to target system:

V1&lt;br&gt;V2&lt;br&gt;V3

How I can convert it in xslt/query?

答案1

得分: 1

你实际上不需要进行任何转换。<description> 元素的字符串值是字符串 V1<br>V2<br>V3。你唯一的问题是要避免它被转换为其他内容,例如,如果你尝试使用 XML 序列化方法将其输出,就会发生这种情况。

所以,这在一定程度上取决于你所说的“将其发送到目标系统”。

使用 XSLT,通常你会希望使用文本输出方法来输出结果。

使用 XQuery,一个返回字符串给调用应用程序的查询会做正确的事情。

英文:

You don't actually need to do any conversion. The string value of the &lt;description&gt; element is the string V1&lt;br&gt;V2&lt;br&gt;V3. Your only problem is to avoid it being converted to something else, which will happen for example if you try to output it using the XML serialization method.

So it depends a bit on what you mean by "send it to the target system".

With XSLT, typically you would want to output the result using the text output method.

With XQuery, a query that returns a string to the calling application will do the right thing.

答案2

得分: 0

use disable-output-escaping="yes" like below

&lt;xsl:value-of select="." disable-output-escaping="yes"/&gt;
英文:

use disable-output-escaping=&quot;yes&quot; like below

&lt;xsl:value-of select=&quot;.&quot; disable-output-escaping=&quot;yes&quot;/&gt;

huangapple
  • 本文由 发表于 2020年10月23日 19:25:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/64499073.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定