XSLT paramsを使用して、実行時にXalan-Cを使用して属性に絶対パスを設定しています。基本的に、私の入力XMLは次のようなものです:-
<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>
ただし、コマンドラインでこのパラメータを設定しようとすると、次のXMLが表示されます:-
<root xmlns="final" dataLocation="/datafile">
<!-- document goes here -->
</root>
私は何をすべきですか?