You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Michael Wirz <mi...@abs.de> on 2005/10/14 19:52:44 UTC

write an xmlbean to string: creating xmlns:xsi and the like

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


-- 
abs IT Service GmbH
abs gruppe
Michael Wirz
Entwicklung

Landsberger Straße 57
82266 Stegen am Ammersee
Telefon: +49 (0)8143 999 43
Telefax: +49 (0)8143 999 49

Michael.Wirz@abs.de
www.eFonds24.de


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


Re: write an xmlbean to string: creating xmlns:xsi and the like

Posted by Michael Wirz <mi...@abs.de>.
Thank you very much Maarten,
this works fine for me.
Michael

> 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: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>


-- 
abs IT Service GmbH
abs gruppe
Michael Wirz
Entwicklung

Landsberger Straße 57
82266 Stegen am Ammersee
Telefon: +49 (0)8143 999 43
Telefax: +49 (0)8143 999 49

Michael.Wirz@abs.de
www.eFonds24.de


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


Re: write an xmlbean to string: creating xmlns:xsi and the like

Posted by maarten <ma...@dns.be>.
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: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org