xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Saha, Sanjeev" <SS...@asce.org>
Subject Resent: Making a copy of XmlObject
Date Fri, 30 Jul 2004 13:19:53 GMT
I am kind of stuck without a resolution to this and will have to use an implementation of dom4j
that I wrote. Trouble is, dom4j takes around 180ms whereas xbeans requires only 20ms. Any
insight into this will be really helpful.

For the following xml fragment:

<Customer Id=''>

When my program intercepts this fragment, the intent is to make a duplicate copy of this so
as not to modify the original fragment. This duplication/copying is done in a separate api
by passing the fragment as an XmlObject.

apiToCopyXmlObject(final XmlObject xobj)
  // my first attempt at copying
  return xobj.copy();
  // other attempts
  // XmlCursor cursor = xobj.newCursor();
  // return (XmlObject)cursor.getObject().copy();

As per the documentation, the copy api supposedly returns the same type as the current object,
but as it turns out, it returns a Document instead of the <Customer> fragment. To overcome
this, I try:

// attempt to get first child
XmlObject copy = xobj.copy();
XmlCursor cursor = copy.newCursor();
return cursor.getObject();

Sadly, the above code returns <FirstName/> and not the <Customer> fragment. Is
the approach flawed?


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/

View raw message