不在xsl:templates中显示XML标记

时间:2016-03-24 10:09:01

标签: xml xslt

我有一个XML和XSLT

  <xsl:template match="header/options">
        <Username>
            <xsl:value-of select="user" />
        </Username>
        <Password>
            <xsl:value-of select="pass" />
        </Password>
  </xsl:template>

转换后,它只显示用户名值。它没有显示<Username></Username>

和xsl:template中的其他xml标记。为什么呢?

XML

<ObjectNode>
    <header>
        <options>
            <username>username</username>
            <password>password</password>
        </options>
    </header>
    <payload>
        <application>
            <applicants id="12345">

            </applicants>
        </application>
        <contacts>
            <person id="12345">
                <names>
                    <id>42342</id>
                    <title>Mr</title>
                    <firstName>Jhon</firstName>
                    <middleNames>Mason</middleNames>
                    <surName>Smith</surName>
                </names>
            </person>
        </contacts>
    </payload>
</ObjectNode>

XSLT

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org">
<xsl:template match="ObjectNode">
  <Search>
    <Authentication>
        <xsl:apply-templates select="header/options"/>
    </Authentication>
    <CountryCode><xsl:value-of select="/ObjectNode/header/options/CONTROL_COUNTRY"/></CountryCode>
    <Person>


    </Person>
</Search>
</xsl:template>

  <xsl:template match="header/options">
        <Username>
            <xsl:value-of select="username" />
        </Username>
        <Password>
            <xsl:value-of select="password" />
        </Password>
  </xsl:template>
</xsl:stylesheet>

0 个答案:

没有答案