Thanks, Maarten!
I've put it on my todo list to add your sample to the FAQ,

Radu

-----Original Message-----
From: maarten [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 18, 2005 12:41 AM
To: [email protected]
Subject: Re: write an xmlbean to string: creating xmlns:xsi and the like


Michael Wirz wrote:

>Hello List,
>I am using xmlbeans to create an xml document, the bean is named 
>RequestDocument as below:
>
>RequestDocument reqDoc = RequestDocument.Factory.newInstance();
>RequestType request = reqDoc.addNewRequest();
>
>I then fill all the members and do a
>
>String dataString = reqDoc.xmlText();
>
>The document element shows up as
>
><mpc:Request xmlns:mpc="http://www.xyz.de/test";>
>
>I'd like it to show up as
>
><mpc:Request xmlns:mpc="http://www.xyz.de/test";
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>xsi:schemaLocation="http://www.xyz.de/test
>http://www.xyz.de/test2/mpcdta_1.0.xsd ">
>
>How do I do this with the XMLBeans API ?
>At the moment it is some ugly string/substring/indexof stuff...
>
>Thanks a lot for help!
>Michael Wirz
>from near Munich, Germany
>
>
>  
>
This should go into the FAQ:

protected void addSchemaLocation(XmlObject xmlObject, String location) {
  XmlCursor cursor = xmlObject.newCursor();
  if (cursor.toFirstChild()) {
    cursor.setAttributeText(
            new 
QName("http://www.w3.org/2001/XMLSchema-instance","schemaLocation";),
location);
  }
}

Maarten


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to