質問

I have this input XML:

<x:html xmlns:x="http://www.w3.org/1999/xhtml"/>

and I am using the following XSLT:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:y="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="text" indent="yes"/>
<xsl:template match="*">
    <xsl:value-of select="name()"/>
</xsl:template>
</xsl:stylesheet>

The output I am getting is (root element with prefix x, as defined in input XML)

x:html

The output I expect is (root element with prefix y, as defined in the XSLT):

y:html
役に立ちましたか?

解決

You could look on the namepace axis of the root element of your XSLT code e.g.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:y="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="text" indent="yes"/>
<xsl:variable name="xslt-root" select="document('')/*"/>
<xsl:template match="*">
  <xsl:value-of select="concat(local-name($xslt-root/namespace::*[. = namespace-uri(current())]), ':', local-name())"/>
</xsl:template>
</xsl:stylesheet>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top