Avatar billede fredand Forsker
27. februar 2009 - 10:27 Der er 3 kommentarer og
1 løsning

How to add schemaLocation and xmlns:xsi with XmlBeans

Hello!

I need to add:
xsi:schemaLocation
xmlns:xsi
...with XmlBeans into a xml doc.

I found this code:
XmlCursor xmlCursor = doc.newCursor();
  if(xmlCursor.toFirstChild())
  {
  xmlCursor.setAttributeText( new QName("http://myapp.se/schema/a/b/c/x/v7", "schemaLocation"), "http://myapp.se/schema/a/b/c/x/v7/a_x.xsd");
}

It should look like:

<v7:a
tid="2009-02-26T13:48:16.656+01:00"
transid="12345"
xmlns:v7="http://myapp.se/schema/a/b/c/x/v7"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://myapp.se/schema/a/b/c/x/v7 http://myapp.se/schema/a/b/c/x/v7/a_x.xsd">
...

But I get:

<v7:a
tid="2009-02-27T09:55:53.906+01:00"
transid="12345"
v7:schemaLocation="http://myapp.se/schema/a/b/c/x/v7/a_x.xsd"
xmlns:v7="http://myapp.se/schema/a/b/c/x/v7">
...

It seems that I miss xmlns:xsi and completly, and the schemaLocation does not get the xsi: infront.

So if you guys got any ideas please let me know!

Best regards
Fredrik
Avatar billede arne_v Ekspert
28. februar 2009 - 04:48 #1
xmlCursor.setAttributeText( new QName("http://myapp.se/schema/a/b/c/x/v7", "schemaLocation"), "http://myapp.se/schema/a/b/c/x/v7/a_x.xsd");

beder da om at få en schemaLocation i dit v7 namespace

prøv med:

  xmlCursor.setAttributeText( new QName("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"), "http://myapp.se/schema/a/b/c/x/v7/a_x.xsd");
Avatar billede arne_v Ekspert
28. februar 2009 - 04:48 #2
that answer came in Danish - I hope you can read it.
Avatar billede fredand Forsker
02. marts 2009 - 15:58 #3
Hello Arne!

Thanks alot!

It worked perfect!

It's about time that I test my knowledge in Danish! ;-)

Please give a svar so I can reward you!

Best regards (... Mange tak!)
Fredrik
Avatar billede arne_v Ekspert
02. marts 2009 - 16:29 #4
svar
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester