xsl:变量选择concat

时间:2016-02-24 16:34:15

标签: xslt

我正在尝试构建一个XSLT,以将XML格式的Excel电子表格转换为另一种XML格式。

我的部分代码是:

            <!-- SPREADSHEET VALUES -->
        <xsl:variable name="cluster" select="./ss:Cell[1]/ss:Data"/>
        <xsl:variable name="server" select="./ss:Cell[2]/ss:Data"/>
        <xsl:variable name="database" select="./ss:Cell[3]/ss:Data"/>
        <xsl:variable name="instance" select="./ss:Cell[4]/ss:Data"/>
        <xsl:variable name="scheme" select="./ss:Cell[5]/ss:Data"/>
        <xsl:variable name="dblocation" select="./ss:Cell[6]/ss:Data"/>
        <xsl:variable name="dbdescription" select="./ss:Cell[7]/ss:Data"/>
        <xsl:variable name="dbstatus" select="./ss:Cell[8]/ss:Data"/>
        <xsl:variable name="infraservicesla" select="./ss:Cell[9]/ss:Data"/>
        <xsl:variable name="dbms" select="./ss:Cell[10]/ss:Data"/>
        <xsl:variable name="edition" select="./ss:Cell[11]/ss:Data"/>
        <xsl:variable name="version" select="./ss:Cell[12]/ss:Data"/>
        <xsl:variable name="clustertype" select="./ss:Cell[13]/ss:Data"/>

        <!-- GENERATED VALUES -->
        <xsl:variable name="artifactname" select="{concat('[',$dblocation,'-',$database,'] ',$dbdescription,' (Artifact)')}"/>

更新:最后一行实际上没有失败,正如我在输入问题时所说,正如一个工具报告的那样,它在其他地方失败了。

答案:我现在知道我需要花括号:

<xsl:variable name="infraservicename" select="concat('[', $server, '-', $instance, '-', $scheme, '] ', $dbdescription, ' (Infrastructure Service)')"/>
<xsl:variable name="infraservicexmiid" select="concat('[', $server, '-', $instance, '-', $scheme, '] DBINSTANCE (Infrastructure Service)')"/>

但我需要他们:

<InfrastructureService name="{$infraservicename}" xmi.id="{$infraservicexmiid}" xmi.type='InfrastructureService' />

我还没有找到好的文档。我通常会去w3schools,但我没有看到这里解释(没有提到花括号)。有关良好文档的任何提示,以便很好地学习语法?并感谢所有回复的人。

1 个答案:

答案 0 :(得分:0)

第一种方法显然是错误的,因为花括号。

第二种方法看起来不错。但如果&#34;失败&#34;,为什么不告诉我们它是如何失败的呢?这是所有问题调查开始的地方 - 伴随着失败的症状。

相关问题