Closed Bug 314163 Opened 20 years ago Closed 18 years ago

E4X XML object constructed from an XML Beans XmlObject is not consistent with a literal (inline) E4X XML object, proprosed fix is supplied

Categories

(Rhino Graveyard :: E4X, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: peter.rodgers, Unassigned)

Details

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920 Firefox/1.0.7 SUSE/1.0.7-0.1 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920 Firefox/1.0.7 SUSE/1.0.7-0.1 The following test attempts to append an XML object to an existing XML object (x). Two different constructors are used to create the XML child (y). Creating from an E4X literal produces an XML object that is not consistent with construction from an XmlObject this results in an IllegalArgumentException for the E4X operation x.* += y2; Test Case --------------------------------- importPackage(Packages.org.apache.xmlbeans); importPackage(Packages.java.lang); x= <a><b>test</b></a>; //y1 is an XML literal - uses XML(String) constructor y1= <c>hello</c>; xo=y1.getXmlObject(); System.out.println("y1\n"); System.out.println(y1.toXMLString()); xo.dump(); x.* += y1; //y2 is identical but constructed from an XmlObject. xo=XmlObject.Factory.parse("<c>hello</c>"); y2= new XML(xo); xo=y2.getXmlObject(); System.out.println("y2\n"); System.out.println(y2.toXMLString()); xo.dump(); //This should not throw an exception. x.* += y2; System.out.println("result\n"); System.out.println(x.toXMLString()); ----------------------------------- Fails with java.lang.IllegalArgumentException - Can't move/copy/insert a whole document. org.apache.xmlbeans.impl.store.Cursor.complain() line:145 org.apache.xmlbeans.impl.store.Cursor.checkInsertionValidity() line:155 org.apache.xmlbeans.impl.store.Cursor._copyXml() line:1513 org.apache.xmlbeans.impl.store.Cursor.twoLocaleOp() line:1903 org.apache.xmlbeans.impl.store.Cursor.twoLocaleOp() line:1881 org.apache.xmlbeans.impl.store.Cursor.copyXml() line:1926 org.mozilla.javascript.xmlimpl.XML.copy() line:711 org.mozilla.javascript.xmlimpl.XML.moveSrcToDest() line:661 org.mozilla.javascript.xmlimpl.XML.insertChild() line:759 org.mozilla.javascript.xmlimpl.XML.insertChild() line:770 org.mozilla.javascript.xmlimpl.XML.appendChild() line:1940 org.mozilla.javascript.xmlimpl.XML.setChildren() line:2742 org.mozilla.javascript.xmlimpl.XML.putXMLProperty() line:1274 org.mozilla.javascript.xmlimpl.XMLObjectImpl.ecmaPut() line:233 org.mozilla.javascript.ScriptRuntime.setObjectProp() line:1430 org.mozilla.javascript.ScriptRuntime.setObjectProp() line:1422 org.mozilla.javascript.gen.c2._c0() line:14 org.mozilla.javascript.gen.c2.call() org.mozilla.javascript.ContextFactory.doTopCall() line:337 org.mozilla.javascript.ScriptRuntime.doTopCall() line:2755 org.mozilla.javascript.gen.c2.call() org.mozilla.javascript.gen.c2.exec() In XML.java the XScriptAnnotation bookmark is set on the document *element* when constructed from a literal and on the *start* document when constructed from XmlObject. Literal Constructor.. http://lxr.mozilla.org/mozilla/source/js/rhino/xmlimplsrc/org/mozilla/javascript/xmlimpl/XML.java#388 XmlObject Constructor... http://lxr.mozilla.org/mozilla/source/js/rhino/xmlimplsrc/org/mozilla/javascript/xmlimpl/XML.java#233 To be consistent the XmlObject constructor should be changed to ... static XML createFromXmlObject(XMLLibImpl lib, XmlObject xo) { XScriptAnnotation anno; XmlCursor curs = xo.newCursor(); if (curs.currentTokenType().isStartdoc()) { curs.toFirstContentToken(); } try { anno = new XScriptAnnotation(curs); curs.setBookmark(anno); } finally { curs.dispose(); } return new XML(lib, anno); } With this change the test succeeds. Having worked with a patched version for several weeks we have seen no side-effects of this change to the XmlObject constructor. Reproducible: Always Steps to Reproduce: Test supplied in details.
Reassigning to please_see_bug_288433@eml.cc pending resolution of bug 288433
Assignee: igor.bukanov → please_see_bug_288433
Assignee: please_see_bug_288433 → nobody
This bug may have been fixed by the patch for bug 290715. In any case, the provided test case works now (when running with XMLBeans, but see bug 355677 for a new non-XMLBeans E4X implementation). Closing as FIXED.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Adding target milestone of 1.6R6 based on the date this bug was resolved FIXED.
Target Milestone: --- → 1.6R6
You need to log in before you can comment on or make changes to this bug.