Hello,
I am having trouble figuring out what am I doing wrong in the following transform. I think that it has something to do with the"a" namespace declaration in the input XML file.
Input XML:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"?>
<t:author xmlns:t="http://namespace.t.com">
<t:basicinfo>
<t:codename>1234</t:codename>
<a:name xmlns:a="http://namespaces.a.com">John</a:name>
</t:basicinfo>
</t:author>
XSL:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:t="http://namespace.t.com"
xmlns:a="http://namespaces.a.com"
>
<xsl:template match="/">
<xsl:variable name="n" select="t:author/t:basicinfo/t:codename/text()"/>
<!-- I don't understand why this variable does not get initialized with the next John -->
<xsl:variable name="u" select="t:author/t:basicinfo/t:codename/a:name/text()"/>
<Best>
<One>
<xsl:value-of select="$n"/>
</One>
<Two>
<xsl:value-of select="$u"/>
</Two>
</Best>
</xsl:template>
</xsl:stylesheet>
Ouput XML:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Best xmlns:a="http://namespaces.a.com" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:t="http://namespace.t.com">
<One>1234</One>
<!--I would expect the node below to contain John as its text contents -->
<Two></Two>
</Best>
Any input would be very much appreciated. Thank you,
Cal