{Disarmed} Adding namespace to an xml file

Nicolas BONNEMORT <[email protected]>
Newsgroups gmane.text.xml.xmlbeans.user
Message-ID <[email protected]>
Hi all.

First time using namespace with /XmlBeans/...

Our customer wants to add a namespace to its /xml /file... but in a 
"particular way".
_From_:
/<Root schemaVersion="1.1" >
<Elt1>
<Elt11>
<Elt111 Att1111="value1111" Att1112="value1112">
</Elt111>
</Elt11>
</Elt1>
<Elt2>
<Elt21 Att211="value211" Att212="value212">
     ...
</Elt21>
</Elt2>
</Root>
/_He wants_:
/<Root schemaVersion="1.1" *xsi:noNamespaceSchemaLocation="aSchema.xsd" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">*
<Elt1>
<Elt11>
<Elt111 Att1111="value1111" Att1112="value1112">
</Elt111>
</Elt11>
</Elt1>
<Elt2>
<Elt21 Att211="value211" *xsi:*Att212="value212">
     ...
</Elt21>
</Elt2>
</Root>
/*And no more changes.*

I found nothing in generated classes methods, but by using XmlCursor, I 
can do this:
/XmlCursor schemaCursor = myDoc.newCursor();
QName myQName = new QName("http://www.w3.org/2001/XMLSchema-instance", 
"noNamespaceSchemaLocation", "xsi");
if (schemaCursor.toFirstChild())
{
     schemaCursor.setAttributeText(myQName, 
prop.getProperty("SchemaLocation"));
}
schemaCursor.dispose();
/
It works fine... *but I cannot add the right prefix to the /Att212 
/attribute!*
_I tried_:

    * /aNewCursor.insertAttributeWithValue("Att212", "value212");/
    * /aNewCursor.insertAttributeWithValue("Att212",
      "http://www.w3.org/2001/XMLSchema-instance", "value212");/
    * /aNewCursor.insertAttributeWithValue("Att212", , "xsi", "value212");/
    * /aNewCursor.insertAttributeWithValue("noNamespaceSchemaLocation"
      ,"http://www.w3.org/2001/XMLSchema-instance",
      prop.getProperty("SchemaLocation"));
      aNewCursor.insertAttributeWithValue("Att212", "value212");
      aNewCursor.insertNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance")./


But it does not work.
I think I do not understand correctly the documentation (sorry, I am 
french! ;-) ) or forget something somewhere... but even after a good 
night (well, kind of...), I cannot find what.

Can you help me please?

Thanks,

-- 
Nicolas BONNEMORT
Akka Informatique Et Systemes
ASTEI
+33 (0)5.34.60.81.65
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.