I found a peculiar difference in the behavior of xslt when the root element has a default namespace attribute, and not the one when it does not.
I wonder why this is happening.
XML input
<root>
<content>xxx</content>
</root>
When does the following conversion apply
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<root>
<xsl:apply-templates/>
</root>
</xsl:template>
<xsl:template match="content">
<w>x</w>
</xsl:template>
</xsl:stylesheet>
result - expected
<?xml version="1.0" encoding="UTF-8"?>
<root>
<w>x</w>
</root>
But when the same conversion applies to
<root xmlns="http://test.com">
<content>xxx</content>
</root>
the result is different and based on the use of only default templates (which effectively print the text node value "xxx"):
<?xml version="1.0" encoding="UTF-8"?>
<root>xxx</root>
Adding
If this is the expected behavior in this case, then what is the value of the matching attribute necessary to match the element contentin the second case?
source
share