gpt4 book ai didi

java - 如何从 XSLT 中的串联变量中清除噪声字符

转载 作者:数据小太阳 更新时间:2023-10-29 02:23:58 25 4
gpt4 key购买 nike

我有这段 XSLT 代码:

<xsl:variable name="VulnerabilityURI">
http://web.nvd.nist.gov/view/vuln/detail?vulnId=
</xsl:variable>
<xsl:variable name="WeaknessURI">
http://cwe.mitre.org/data/definitionsn
</xsl:variable>
<xsl:variable name="CVEURI">
http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=
</xsl:variable>
<xsl:variable name="cweID" select="substring(vuln:cwe/@id,5)" />
<xsl:template match="/*/*">
<xsl:variable name="cveID" select="vuln:cve-id" />
<xsl:element name="rdf:Description">
<xsl:attribute name="rdf:about">
<xsl:value-of select="concat($VulnerabilityURI, $cveID)" />
</xsl:attribute>
<aseg:cveID>
<xsl:value-of select="concat($CVEURI,$cveID)" />
</aseg:cveID>

输出如下:

  <?xml version="1.0" encoding="UTF-8"?>
.....
.....
<rdf:Description rdf:about="&#10;&#9;&#9;http://web.nvd.nist.gov/view/vuln/detail
vulnId=&#10;&#9;CVE-2010-2227">
<aseg:cveID>
http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=
CVE-2010-2227</aseg:cveID>

正如您在这部分结果中看到的,我想要的串联变量产生了未知字符

  &#10;&#9  

谁能帮我解决这个问题?!!

最佳答案

那些“噪音字符”是换行符和制表符。而不是

<xsl:variable name="VulnerabilityURI">
http://web.nvd.nist.gov/view/vuln/detail?vulnId=
</xsl:variable>

你可以这样写

<xsl:variable 
name="VulnerabilityURI"
select="'http://web.nvd.nist.gov/view/vuln/detail?vulnId='" >

然后你就不会得到那些字符。

您还需要在设置 CVE ID 时执行类似的操作。

关于java - 如何从 XSLT 中的串联变量中清除噪声字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22974522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com