You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by Shenxue Zhou <sh...@bea.com> on 2006/04/17 22:40:27 UTC

Question on writing schemaLocation attribute to root doc element

Hi, All:

 

I need to write out schemaLocation attribute to the root element of my
xml document. The code snippet I used is as following(Suppose my root
element is of type TestType):

 

TestType rootElement;

XmlCursor cursor = rootEmelent.newCursor();

assert cursor.isStartdoc();

cursor.toNextToken();

cursor.insertNameSpace(null, "name space url"); // namespace url

cursor.insertNameSpace("xsi", "name space url"); // namespace url

cursor.insertAttributeWithValue(new QName("some uri", "schemaLocation",
"xsi"), "schema location attribute value");

cursor.dispose();

......

 

After the document is edited and saved, I got the root element as
following:

<rootElement  xsi:schemaLocation="schema location val" xmlns="..."
xmlns:xsi="...">

 

As you can see, schemaLocation attribute shows up before xmlns related
attributes.

No matter how I juggle the insertion order on the cursor obj, I always
get schemaLocation attribute in front of xmlns attribute.

 

I also noticed that if I open a document with xmlns attributes in front
of schemaLocation attribute, without any edits on it, just save the
document, then schemaLocation attribute would appear in front of xmlns
attributes.

 

Is this ordering(schemLocation in front to namespace) imposed by xml
beans? Is there any way to alter the order between namespace attributes
and schemaLocation attribute so the root element would be like this:

<rootElement  xmlns="..." xmlns:xsi="..." xsi:schemaLocation="schema
location val" > 

 

Thanks!

 

 

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.