Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-301

Missing top-level element when copy/moveXmlContents

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • Version 2.2.1
    • None
    • Cursor
    • None
    • JDK1.5

    Description

      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); }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            hackingbear@gmail.com Hacking Bear
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: