0

以下のxmlをxsltで変換したいです。 注: 入力 xml で name spave を使用しています

入力 XML

<?xml version="1.0" encoding="UTF-8"?>
<Roottag xmlns="aaa">
    <Employee>
        <name>Nimal</name>
    </Employee>
    <Employee>
        <name>Kamal</name>
    </Employee>
    <Employee>
        <name>Sunil</name>
    </Employee>
</Roottag>

XSLT

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="//name">
        <xsl:element name="person">
            <xsl:value-of select="." />
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

期待される出力

<?xml version="1.0" encoding="UTF-8"?>

<person>Nimal</person>
<person>Kamal</person>
<person>Sunil</person>

電流出力

<?xml version="1.0" encoding="UTF-8"?>  
        Nimal   
        Kamal   
        Sunil

xslt2.0変換でこの名前空間の問題を解決するのを手伝ってくれる人はいますか?

4

1 に答える 1

1

XSLT2.0およびXSLT2.0プロセッサを使用すると、

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xpath-default-namespace="aaa">

    <xsl:template match="name">
        <person>
            <xsl:value-of select="." />
        </person>
    </xsl:template>
</xsl:stylesheet>

XSLT 1.0プロセッサでは、必要なものがあります

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:df="aaa" exclude-result-prefixes="aaa">

    <xsl:template match="df:name">
        <person>
            <xsl:value-of select="." />
        </person>
    </xsl:template>
</xsl:stylesheet>
于 2013-02-11T10:50:26.067 に答える