可以处理双引号中包含多个数字的变量吗?即。当我将引号翻译成句点时,xslt 1.0中的Translate函数返回一个错误。不允许将多个项目的序列作为translate() ("2","1",“1”)的第一个参数
我想把(“2”,“1”,“1”)翻译成(.2.1.1。)
XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<Project type="cim" version="0.1">
<Projects>
<WBSs>
<WBS GUID=”2”>
<WBSs>
<WBS GUID=”1”>
</WBS>
<WBSs>
<WBS GUID=”1”>
</WBS>
</WBSs>
<WBS GUID=”2”>
</WBS>
<WBS GUID=”3”>
<WBSs>
<WBS GUID=”4”>
</WBS>
</WBSs>
</WBS>
</WBSs>
<WBS GUID=”4”>
<WBSs>
<WBS GUID=”5”>
</WBS>
<WBS GUID=”8”>
</WBS>
<WBS GUID=”2”>
</WBS>
<WBS GUID=”10”>
</WBS>
</WBSs>
</WBS>
</WBSs>
</Projects>
</Project>xslt
<xsl:variable name="NETWORK ">
<xsl:apply-templates select=".//WBS" mode="I_NETWORK">
<xsl:with-param name="ProjectId" select="$ProjectId"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:template match="WBS" mode="I_NETWORK">
<xsl:param name="ProjectId"/>
<xsl:variable name="wbsCode" select="@GUID"/>
<xsl:variable name="quot">"</xsl:variable>
<xsl:variable name="var1">
<xsl:value-of select="translate($wbsCode,$quot,'.')"/>
</xsl:template>发布于 2017-12-09 01:10:42
You have to use the real double quotes in your XML, "2", rather than the curvy double quotes, “2”. Once you have real double quotes in XML use the escape character to do your translate. Your editor may be putting the curvy double quotes in.
<xsl:variable name="test">
<xsl:value-of select="'("2","1","1")'"/>
</xsl:variable>
<xsl:variable name="result">
<xsl:value-of select="translate($test,'"','.')"/>
</xsl:variable>https://stackoverflow.com/questions/47718298
复制相似问题