首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >翻译用双引号括起来的多个数字(XSLT 1.0)

翻译用双引号括起来的多个数字(XSLT 1.0)
EN

Stack Overflow用户
提问于 2017-12-09 00:22:36
回答 1查看 167关注 0票数 0

可以处理双引号中包含多个数字的变量吗?即。当我将引号翻译成句点时,xslt 1.0中的Translate函数返回一个错误。不允许将多个项目的序列作为translate() ("2","1",“1”)的第一个参数

我想把(“2”,“1”,“1”)翻译成(.2.1.1。)

XML

代码语言:javascript
复制
<?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

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-12-09 01:10:42

代码语言:javascript
复制
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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47718298

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档