Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-2069

XSLTC produces incorrect output for multiple default namespaces

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 2.6
    • 2.7
    • XSLTC
    • Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
    • None
    • Windows XP, J2SE 1.5.0 default SDK install, Eclipse 1.0.1 defualt install. JAXP interface

    Description

      Input template:
      <?xml version="1.0" encoding="utf-8"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

      <xsl:template match="/">
      <core:Display
      xmlns:core="http://example.com/core"
      xmlns:foo="http://example.com/java/foo"
      >
      <core:Styles xmlns="http://example.com/java/foo">
      <Constant/>
      </core:Styles>
      <core:View xmlns="http://example.com/java/javax.swing">
      <!-- workaround for buggy XSLT processor.-->
      <!-This should work:->
      <foo:Constant/>
      <!-Workaround is:->
      <!--xsl:element
      namespace="http://example.com/java/foo"
      name="Constant"
      /-->
      </core:View>
      </core:Display>
      </xsl:template>
      </xsl:stylesheet>

      Input document:
      <doc/>

      Expected result:
      <?xml version="1.0" encoding="UTF-8"?>
      <core:Display xmlns:core="http://example.com/core"
      xmlns:foo="http://example.com/java/foo">
      <core:Styles xmlns="http://example.com/java/foo">
      <Constant/>
      </core:Styles>
      <core:View xmlns="http://example.com/java/javax.swing">
      <foo:Constant/>
      </core:View>
      </core:Display>

      Actual result:
      <?xml version="1.0" encoding="UTF-8"?>
      <core:Display xmlns:core="http://example.com/core"
      xmlns:foo="http://example.com/java/foo">
      <core:Styles xmlns="http://example.com/java/foo">
      <Constant/>
      </core:Styles>
      <core:View xmlns="http://example.com/java/javax.swing">
      <Constant/>
      </core:View>
      </core:Display>

      (Note second Constant tag is missing namespace prefix)

      The error only occurs when a node is defined when its namespace was the default,
      then later the same node is defined when its namespace is no longer the default.
      The lack of prefix the second time around means it goes into the new (now
      incorrect) default namespace. This example is a cut-down version of working
      software.

      I'm fairly new to the Java sphere, so am not 100% sure of version numbers. I'm
      running Eclipse 3.0 and the 1.5.0 Java SDK and am using whatever the combination
      of these two forces brings in by default. The classes that get instantiated
      appear to be XSLTC-related, and I'm using the JAXP interface. My code looks
      something like this:

      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setNamespaceAware(true);
      DocumentBuilder parser = factory.newDocumentBuilder();
      Document template = parser.parse("transform.xsl");
      Document instance = parser.parse("doc.xsli");
      Document result = parser.newDocument();
      TransformerFactory factory = TransformerFactory.newInstance();
      Transformer transform = factory.newTransformer(new DOMSource(template));
      DOMResult doc = new DOMResult(result);
      transform.transform(new DOMSource(instance), doc);

      This is the same bug as the misfiled Bug 33783. This may be a duplicate of XALANJ-2032, but is probably an escilation since actual incorrect output is produced.

      Benjamin.

      Attachments

        Issue Links

          Activity

            People

              zongaro@ca.ibm.com Henry Zongaro
              fuzzybsc Benjamin
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: