-1

我有一个 XLST 转换代码,它从元素列表中获取值

  <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('Source: ',$Source,' Reference: ',$Reference,' Description: ',$Description,' Link: ',$Link,' ')"/>
    </xsl:for-each>
  </NewSourceName>

此代码生成我需要的输出文本:

Source: The Exploit-DB Reference: CVE-2020-14882 Description: Oracle WebLogic Server 12.2.1.0 - RCE (Unauthenticated) - The Exploit-DB Ref : 49479 Link: http://www.exploit-db.com/exploits/49479 Source: The Exploit-DB Reference: CVE-2020-11022 Description: jQuery 1.2 - Cross-Site Scripting (XSS) - The Exploit-DB Ref : 49766 Link: http://www.exploit-db.com/exploits/49766 

我确实尝试在字符串中添加 \n 或 <BR> 以添加换行符以在 RSA Archer 文本字段的“富文本字段”上获取此格式,但是在处理转换时会返回错误。

<xsl:value-of select="concat('<BR>Source: ',$Source,'\n Reference: ',$Reference,' Description: ',$Description,' Link: ',$Link,' ')"/>

我需要这样的文字

<p>Source: The Exploit-DB<br> 
Reference: CVE-2020-14882<br> 
Description: Oracle WebLogic Server 12.2.1.0 - RCE (Unauthenticated) - The Exploit-DB Ref : 49479<br> 
Link: http://www.exploit-db.com/exploits/49479 </p>
<br>
<p>Source: The Exploit-DB <br>
Reference: CVE-2020-11022 <br>
Description: jQuery 1.2 - Cross-Site Scripting (XSS) - The Exploit-DB Ref : 49766 <br>
Link: http://www.exploit-db.com/exploits/49766<p>

任何想法?

4

1 回答 1

0

HTML 中的换行符是一个元素,而不是文本。要获得您显示的结果,您需要执行以下操作:

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

未经测试,因为没有提供可重复的示例进行测试。

于 2021-08-22T04:49:06.680 回答