Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用xsltproc将shell变量传递到xsl中?_Shell_Xslt - Fatal编程技术网

如何使用xsltproc将shell变量传递到xsl中?

如何使用xsltproc将shell变量传递到xsl中?,shell,xslt,Shell,Xslt,我想传递一个变量name=$(echo“$t”| cut-f1-d.) 从shell脚本到以下xsl作为$name变量: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="ht

我想传递一个变量
name=$(echo“$t”| cut-f1-d.)
从shell脚本到以下xsl作为$name变量:

 <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

<xsl:template match="dc:record">
    <xsl:copy copy-namespaces="no">
        <xsl:apply-templates select="@* | *" />
        <xsl:param name="name"/>
         <dc:relation><xsl:value-of select="$name"/></dc:relation>    
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>


是否可以通过
xsltproc-o ie1.xml.././transform.xsl ie1.xml发送变量,以及如何执行此操作?

在顶层定义
xsl:param

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:param name="name" />
...

仅此而已。

有趣的是,它与
--stringparam
一起工作,即使没有声明
xsl:param
xsltproc --stringparam name "$name" -o ie1.xml ../../transform.xsl ie1.xml