翻译双引号内的多个数字(XSLT 1.0)

时间:2017-12-08 16:22:36

标签: xslt-1.0

是否可以处理双引号括起来的多个数字的变量? IE浏览器。当我将报价翻译成句点时,xslt 1.0中的翻译函数会返回错误。不允许使用多个项目的序列作为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>

1 个答案:

答案 0 :(得分:0)

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="'(&quot;2&quot;,&quot;1&quot;,&quot;1&quot;)'"/>
</xsl:variable>

<xsl:variable name="result">
  <xsl:value-of select="translate($test,'&quot;','.')"/>
</xsl:variable>