#486818 xsltproc: Incorrectly omits namespace declaration

Package:
xsltproc
Source:
libxslt
Description:
XSLT 1.0 command line processor
Submitter:
Gábor Braun
Date:
2021-07-05 17:51:06 UTC
Severity:
normal
Tags:
#486818#5
Date:
2008-06-18 11:29:25 UTC
From:
To:
Example stylesheet: missing.xsl

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xhtml="http://www.w3.org/1999/XHTML">

<xsl:template match="/">
  <xsl:element name="foo">
    <bar/>
  </xsl:element>
</xsl:template>

</xsl:stylesheet>

Let's apply it.

$xsltproc missing.xsl missing.xsl
<?xml version="1.0"?>
<foo><bar/></foo>

The output is wrong: the namespace prefix 'xhtml' should be declared on element
bar.

Using the following, equivalent stylesheet instead of the above:

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xhtml="http://www.w3.org/1999/XHTML">

<xsl:template match="/">
  <xsl:element name="foo">
    <xsl:call-template name="bar"/>
  </xsl:element>
</xsl:template>

<xsl:template name="bar">
  <bar/>
</xsl:template>
</xsl:stylesheet>

the output is

<?xml version="1.0"?>
<foo><bar xmlns:xhtml="http://www.w3.org/1999/XHTML"/></foo>

which is correct.

Best wishes,

	Gábor Braun