以下の XML から「LIVE」を取得したいと思います。同様の投稿を読んで、結果として local-name() 関数を使用していますが、どの XSLT を使用しても取得できません。
<?xml version="1.0"?>
<cns:customer xmlns:cns="https://services.cns.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://services.cns.com docs/xsd/customer.xsd">
<cns:userId>1001</cns:userId>
<cns:status>LIVE</cns:status>
<cns:type wholesale="true" suspended="false">W1</cns:type>
<cns:properties>
<cns:property>
<cns:name>Name</cns:name>
<cns:value>Bob</cns:value>
</cns:property>
</cns:properties>
</cns:customer>
これが私が使用しているXSLTです。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="//*[local-name()='status']/text()">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
Oxygen アプリケーションを使用してテストしています。プロセッサはSaxon 6.5.5だと思います。
私が得る出力は次のとおりです。
1001
LIVE
W1
Name
Bob
ありがとう、ポール