xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Vasilik" <eric...@bea.com>
Subject RE: changing the schemaLocation
Date Thu, 15 Jul 2004 03:36:41 GMT
Something like the following should work:

    XmlObject x = XmlObject.Factory.parse( ... ); // Parse in your XML
    XmlCursor c = x.newCursor(); // Cursor on the document

    c.toFirstChild();  // Navigate to document element

    c.setAttributeText(  // Change the attr value
        new QName(
           "http://www.w3.org/2001/XMLSchema-instance ",
          "schemaLocation" ),
       "TheNewSchem.xsd" );

    c.dispose();  // Done with the cursor

-Eric

-----Original Message-----
From: Monica Granbois [mailto:mgranbois@abebooks.com] 
Sent: Wednesday, July 14, 2004 7:35 PM
To: xmlbeans-user@xml.apache.org
Subject: changing the schemaLocation

Hi,

I have an xml document which I have parsed into my XmlObject.  I want to
change the schemaLocation that is reference by the xml.  Is there a way
to do
this?

For example if the xml had a schema location of original.xsd as below:

<xs:Foo xs:id="123" xs:deletestatus="false" xs:typecode="1"
xsi:schemaLocation="http://www.foobar.com/XMLSchema
http://www.foobar.com/docs/Schemas/original.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.foobar.com/XMLSchema">

Is it possible to change the schemaLocation to be 'TheNewSchema.xsd' as
shown
below:

<xs:Foo xs:id="123" xs:deletestatus="false" xs:typecode="1"
xsi:schemaLocation="http://www.foobar.com/XMLSchema
http://www.foobar.com/docs/Schemas/TheNewSchema.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.foobar.com/XMLSchema">


I'm assuming I will need to use an XmlCursor, but I'm not sure if should
use
the execQuery() method to attempt this or not. Any pointers in which
direction I should be looking would be appreciated.

Thanks,

Monica


- ---------------------------------------------------------------------
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/


- ---------------------------------------------------------------------
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/


Mime
View raw message