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

Namespace declarations are lost on transformation to DOMResult

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.7.1, 2.7
    • None
    • DOM, JAXP, Xalan
    • None
    • Intel Pentium 4
      Windows 2000 SP4
      Sun JDK 6 (build 1.6.0-b105)

    Description

      Have a look at the following snippet:

      <a:a1 xmlns:a="http://a"
      xmlns:b="http://b"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <a:a2 xsi:type="b:B"/>
      </a:a1>

      As you can see, the value of the attribute 'xsi:type' contains a namespace prefix, which is declared in the root element.

      When I read this document as a StreamSource or SAXSource and transform it with Xalan into a DOMResult, the namespaces are invalid because the namespace declaration 'xmlns:b="http://b"' is lost:

      <a:a1 xmlns:a="http://a">
      <a:a2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:type="b:B"/>
      </a:a1>

      When I try to read the document as a DOMSource and try to transform it into a DOMResult, an exception occurs ('NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.').

      I attach the example code and output.

      Attachments

        1. output.txt
          2 kB
          Christian Koppen
        2. TransformerTest.java
          5 kB
          Christian Koppen
        3. xalan-j2-XALANJ-2382.patch
          1.0 kB
          Richard Opalka

        Activity

          People

            Unassigned Unassigned
            ck1 Christian Koppen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: