0
我使用XSLT参数在运行时使用Xalan-C在属性中设置绝对路径。基本上,我的输入XML是这样的: -选择在命令行给出的XSLT参数的字符串
<root xmlns="initial">
<!-- document goes here -->
</root>
我的样式表是: -
<xsl:stylesheet version="1.0" xmlns:s="initial" xmlns="final" />
<xsl:param name="default_data_location">/path/to/some/location</xsl:param>
<xsl:template match="//s:*">
<xsl:element name="{local-name()}" namespace="final">
<xsl:attribute name="dataLocation">
<xsl:value-of select="concat($default_data_location, '/datafile')"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
<!-- rest of the stylesheet -->
</xsl:stylesheet>
因此,我需要的输出XML,当我运行它: -
Xalan foo.xml foo.xsl
应该是(这是工作的部分): -
<root xmlns="final" dataLocation="/path/to/some/location/datafile">
<!-- document goes here -->
</root>
当我运行它: -
Xalan -p default_data_location /some/other/path foo.xml foo.xsl
它应该是(这是不工作的部分): -
<root xmlns="final" dataLocation="/some/other/path/datafile">
<!-- document goes here -->
</root>
如果我尝试在命令来设置此PARAM但是,它给了我以下XML: -
<root xmlns="final" dataLocation="/datafile">
<!-- document goes here -->
</root>
我该怎么做?
nopes没有工作。我已经尝试了每种可能的组合方式,包含在''和“”中。实际上,这可能不是由于xpath字符串。它只是不输出任何值,即使我通过一些垃圾说Xalan -p default_data_location'sdndsa'并不真正工作。 – owagh
我认为shell可能会阻碍你的行为,所以我会在Windows上尝试类似'Xalan -p default_data_location“'/ some/other/path'”foo.xml foo.xsl'的实例。今晚我没有时间测试,希望其他Xalan-C用户可以提供帮助。 –
就是这样。我不确定我在绝望的蛮力搜索中错过了这些。更新您的答案,我会将其标记为已接受。 – owagh