You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Cezar Andrei (JIRA)" <xm...@xml.apache.org> on 2006/12/07 18:39:35 UTC

[jira] Resolved: (XMLBEANS-301) Missing top-level element when copy/moveXmlContents

     [ http://issues.apache.org/jira/browse/XMLBEANS-301?page=all ]

Cezar Andrei resolved XMLBEANS-301.
-----------------------------------

    Resolution: Won't Fix

moveXmlContents() is designed to move only the content of the current element. For moving the element use moveXml() method.

> Missing top-level element when copy/moveXmlContents
> ---------------------------------------------------
>
>                 Key: XMLBEANS-301
>                 URL: http://issues.apache.org/jira/browse/XMLBEANS-301
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: Cursor
>    Affects Versions: Version 2.2.1
>         Environment: JDK1.5
>            Reporter: Hacking Bear
>
> When using cursor to copy/move one XmlObject into another, the top-level element is missing. One has to wrap the bean into another bean before move/copy to target.
> As experiment at point (A) and (B) below, it seems that XMLBean inserts the child after the cursor, rather than at the cursor, so I have to wrp it in a dummy doc or parent element. This also seems contradicting to the tutorial/document. The expected output is 
>     ...<soap:body><Request ...><AttributeQuery ... 
> public class SOAPXBeanOutputTest {
>     public static void main(String[] args) throws Exception {
>         RequestType request = RequestType.Factory.newInstance();
>         request.setIssueInstant(Calendar.getInstance());
>         request.setRequestID ("REQ123");
>         AttributeQueryType query = request.addNewAttributeQuery();
>         SubjectType subject = SubjectType.Factory.newInstance();
>         NameIdentifierType nameId = subject.addNewNameIdentifier ();
>         nameId.setStringValue("NAME123");
>         query.setSubject((SubjectType)subject.copy());
>        
>         EnvelopeDocument soapDoc = EnvelopeDocument.Factory.newInstance();
>         Envelope soapEnv = soapDoc.addNewEnvelope();
>         Body soapBody = soapEnv.addNewBody();
>        
>         XmlCursor cursor = soapBody.newCursor();
>         cursor.toNextToken();
>         // (A) if not wrapping in dummy doc/element, results in output ...<soapenv:Body><urn:AttributeQuery...
>         RequestDocument dummyDoc = RequestDocument.Factory.newInstance();
>         dummyDoc.setRequest(request);
>         XmlCursor reqcursor = dummyDoc.newCursor(); // typs = STARTDOC
>         //reqcursor.toFirstChild(); // (B) this results in output ...<soapenv:Body><urn:AttributeQuery...
>         reqcursor.moveXmlContents(cursor);
>        
>         reqcursor.dispose();
>         cursor.dispose();
>         soapDoc.save(System.out);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org