After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 341463 - Namespace-alias using #default for result-prefix with no default namespace in scope
Namespace-alias using #default for result-prefix with no default namespace in...
Status: RESOLVED FIXED
Product: libxslt
Classification: Platform
Component: general
git master
Other All
: Normal minor
: ---
Assigned To: kbuchcik
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-05-11 20:44 UTC by kbuchcik
Modified: 2006-06-19 18:31 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description kbuchcik 2006-05-11 20:44:34 UTC
Namespace-alias using #default for result-prefix with no default namespace
in scope, will incorrectly put an element in a default namespace
in-scope of the literal element. But the target namespace URI must be the
namespace in-scope of the xsl:namespace-alias element, not be evaluated
dynamically for every literal result element.

xsltApplyOneTemplateInt() calls
  copy->ns = xsltGetNamespace(ctxt, copy, copy->ns, copy);
  ... which will search at transformation-time for a default
    namespace in-scope for the literal result.
  if (URI == UNDEFINED_DEFAULT_NS) {
   xmlNsPtr dflt;	
   dflt = xmlSearchNs(cur->doc, cur, NULL);

Example:

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
  xmlns:foo="urn:test:foo">  

  <xsl:namespace-alias stylesheet-prefix="foo" result-prefix="#default"/>

  <xsl:template match="/" xmlns="urn:test:default">    
    <foo:foo >
      <foo:bar/>
    </foo:foo>
  </xsl:template>

</xsl:stylesheet>
<!--
  Result of Libxslt:  
  <foo xmlns="urn:test:default" xmlns:foo="urn:test:default"><foo:bar/></foo>

  Xalan-J:
  "NullPointerException"

  Saxon 6.5.3:
  <foo:foo xmlns:foo="" xmlns="urn:test:default"><foo:bar/></foo:foo>

  Saxon 8.1.1:
  "java.lang.RuntimeException: Cannot output a namespace node for the default
  namespace when the element is in no namespace"

  MSXML .NET:
  <foo><bar/></foo>

-->
Comment 1 kbuchcik 2006-06-19 18:31:16 UTC
We'll go the .NET way here.
Fixed in CVS HEAD.

Current result:
<?xml version="1.0"?>
<foo><bar/></foo>