xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bentley Drake <bent...@nightfire.com>
Subject Crimson 1.1.3 bug and behavior changes?
Date Sat, 03 Nov 2001 23:23:14 GMT
Hi,

I have some software that is currently using the original Javasoft JAXP 1.1
reference implementation (downloaded from
http://java.sun.com/xml/download.html), which uses an older version of the
Crimson XML parser.  I'm testing upgrading it to Crimson 1.1.3, and am
seeing the following differences when I run my test cases:


When I convert the XML from a DOM Document back to a String using code like
the following:

                XmlDocument doc = //...

                doc.getDocumentElement().normalize( );

                StringWriter sw = new StringWriter( );
                
                ((XmlDocument)doc).write( sw );
                
                String xmlString = sw.toString( );

I get additional blank lines between nodes that I didn't have with the
earlier Crimson library.  I know these don't matter wrt the data, but i'm
wondering why things changed.


Also, when I attempt to copy an entire Document object using the following
code:

        XmlDocument src = //...

        XmlDocument copy = (XmlDocument)( src.cloneNode( true ) );

I get the folllowing exception:

org.apache.crimson.tree.DomEx: HIERARCHY_REQUEST_ERR: This node isn't
allowed there.
 	at
org.apache.crimson.tree.XmlDocument.changeNodeOwner(XmlDocument.java:1156)
 	at
org.apache.crimson.tree.XmlDocument.changeNodeOwner(XmlDocument.java:1177)
 	at
org.apache.crimson.tree.XmlDocument.cloneNode(XmlDocument.java:1101) 

The associated code in the XmlDocument class, method changeNodeOwner(), is
the following:

        //
        // If node is an attribute, its "scoped" by one element...
        // and if that scope hasn't been changed (i.e. if this isn't
        // a recursive call) we can't really fix anything!
        //
        if (node instanceof AttributeNode) {
            AttributeNode       attr = (AttributeNode) node;
            Element             scope = attr.getOwnerElement();

            if (scope != null && scope.getOwnerDocument () != this)
                throw new DomEx (DomEx.HIERARCHY_REQUEST_ERR);
        }

The test-case XML uses attributes similar to those shown in the following
XML fragment:

		<DTSENT type="datetime">
			<DATE value="12-12-1998"/>
			<TIME value="11:15 PM"/>
		</DTSENT>

The description for the exception from the javadoc is as follows:

HIERARCHY_REQUEST_ERR
public static final short HIERARCHY_REQUEST_ERR
     If any node is inserted somewhere it doesn't belong

If I already have a Document, and am just cloning the entire document, i'm
having trouble understanding why this exception is occurring, since
presumably the source document validates all node insertions as valid, as
does the target document.

Prior to the Crimson upgrade, the test cases ran to completion without any
exceptions. I'd like to upgrade if possible to prepare for the next JDK
release.

Any ideas?

Thanks,

Bentley

P.S.: Does the current package structure of the library reflect that which
will be present when JDK 1.4 goes GA?

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Mime
View raw message