如何从XSLT中的连接变量中清除噪声字符

Tec*_*ech 3 java xml xslt variables

我有这个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/de?nitionsn
</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>
Run Code Online (Sandbox Code Playgroud)

输出如下:

  <?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> 
Run Code Online (Sandbox Code Playgroud)

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

  &#10;&#9  
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我解决问题?!!

Daw*_*ica 5

那些"噪音字符"是换行符和制表符.代替

<xsl:variable name="VulnerabilityURI">
    http://web.nvd.nist.gov/view/vuln/detail?vulnId=
</xsl:variable>
Run Code Online (Sandbox Code Playgroud)

你可以写

<xsl:variable 
    name="VulnerabilityURI" 
    select="'http://web.nvd.nist.gov/view/vuln/detail?vulnId='" >
Run Code Online (Sandbox Code Playgroud)

然后你就不会得到那些角色了.

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