You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在XSLT的value-of select标签字符串中添加换行符适配RSA Archer富文本

错误原因
  • 你直接在concat()函数中写入<BR>标签时,XSLT解析器会将其识别为XML节点而非文本内容,直接抛出语法错误
  • XPath语法中不支持\n转义字符,该内容会被作为普通字符输出,无法产生换行效果
解决方案

直接在XSLT模板中嵌套你需要输出的HTML标签,不要将标签放入concat()函数拼接,修改后的完整代码如下:

<NewSourceName>
  <xsl:for-each select="CORRELATION/EXPLOITS/EXPLT_SRC/EXPLT_LIST/EXPLT">
    <xsl:variable name="Source" select="../../SRC_NAME"/>
    <xsl:variable name="Link" select="LINK"/>
    <xsl:variable name="Description" select="DESC"/>
    <xsl:variable name="Reference" select="REF"/>
    <p>
      Source: <xsl:value-of select="$Source"/><br/>
      Reference: <xsl:value-of select="$Reference"/><br/>
      Description: <xsl:value-of select="$Description"/><br/>
      Link: <xsl:value-of select="$Link"/>
    </p>
    <br/>
  </xsl:for-each>
</NewSourceName>

如果你的XSLT声明中输出模式设置为method="text",无法直接输出HTML标签,可以使用disable-output-escaping属性强制输出尖括号,写法如下:

<NewSourceName>
  <xsl:for-each select="CORRELATION/EXPLOITS/EXPLT_SRC/EXPLT_LIST/EXPLT">
    <xsl:variable name="Source" select="../../SRC_NAME"/>
    <xsl:variable name="Link" select="LINK"/>
    <xsl:variable name="Description" select="DESC"/>
    <xsl:variable name="Reference" select="REF"/>
    <xsl:value-of select="concat('&lt;p&gt;Source: ', $Source, '&lt;br&gt;')" disable-output-escaping="yes"/>
    <xsl:value-of select="concat('Reference: ', $Reference, '&lt;br&gt;')" disable-output-escaping="yes"/>
    <xsl:value-of select="concat('Description: ', $Description, '&lt;br&gt;')" disable-output-escaping="yes"/>
    <xsl:value-of select="concat('Link: ', $Link, '&lt;/p&gt;&lt;br&gt;')" disable-output-escaping="yes"/>
  </xsl:for-each>
</NewSourceName>

两种写法输出的HTML结构都符合RSA Archer富文本字段的解析规则,传入后会自动渲染出你需要的换行效果。

内容的提问来源于stack exchange,提问作者LarMedina75

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 18:48:02