「FOO」という名前の要素の属性値を変更したいので、次のように記述しました。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="FOO/@extent">
<xsl:attribute name="extent">
<xsl:text>1.5cm</xsl:text>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
このようなものは動作します。今は同じものが必要ですが、要素は「fs:BOO」です。FOOを「fs:BOO」に置き換えてみましたが、xsltprocはそのようなコードをコンパイルできないと言っています。私はこの問題を次のように一時的に解決します。
sed 's|fs:BOO|fs_BOO|g' | xsltproc stylesheet.xsl - | sed 's|fs_BOO|fs:BOO|g'
しかし、「sed」を使用せずに、もっと簡単な解決策があるのではないでしょうか。
入力データの例:
<root>
<fs:BOO extent="0mm" />
</root>
書く場合:
<xsl:template match="fs:BOO/@extent">
私が得た:
xsltCompileStepPattern : no namespace bound to prefix fs
compilation error: file test.xsl line 10 element template
xsltCompilePattern : failed to compile 'fs:BOO/@extent'