I have the following XML data:
<main xmlns="http://www.w3.org/1999/xhtml">
<section>
<value>s1</value>
</section>
<section>
<value>s2</value>
</section>
</main>
and XSLT:
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<page>
<xsl:apply-templates select="/main/section" />
</page>
</xsl:template>
<xsl:template match="section">
<test section="{value}" />
</xsl:template>
</xsl:stylesheet>
The output I'm expecting is the following:
<page>
<test section="s1" />
<test section="s2" />
</page>
But I'm getting:
<page xmlns="http://www.w3.org/1999/xhtml"/>
I've tested this using this online tool. Obviously I'm doing something wrong, but it's late and I can't wrap my head around this. Could you suggest a way for me to fix this problem?
To be a bit more precise: I cannot name the namespace of the XML data, therefore the answer to the suggested duplicate does not solve this problem.