Philipp, In order to have a valid XML document you need to have some namespace declarations. XMLBeans always tries to create valid documents, that's why you see the xmlns:xsi namespace declaration.
If you want valid documents try using the methods that have uri as parameter. For example instead of using: > cursor.insertAttributeWithValue( "xsi:type", "xsd:short" ); (where the first parameter represents the localName of the attribute) use cursor.insertAttributeWithValue( "type", "http://www.w3.org/2001/XMLSchema-instance", "xsd:short" ); Also, depending on your schema it might be easier to use the generated xbeans directly instead of using xmlcursor which is intended for lower level manipulation. Cezar > -----Original Message----- > From: [email protected] [mailto:[email protected]] > Sent: Thursday, March 12, 2009 2:47 AM > To: [email protected] > Subject: Problems with generating XML > > Hello, > > I have some problems to generate XML. I generated the classes from my WSDL > and it works quite fine. But I have a small problem. My XML-File should > look like this: > <Write xmlns="web-adress1" xmlns:xsi="web-adress2" xmlns:xsd="web- > adress3"> > <Options/> > <ItemList> > <Items ItemName=\"S7:[DEMO]TestIntZwei\"> > <Value xsi:type=\"xsd:short\">87</Value> > </Items> > </ItemList> > </Write> > > My code to generate this file: > WriteDocument doc = WriteDocument.Factory.newInstance(); > org.opcfoundation.webservices.xmlda._1_0.WriteDocument.Write write = > doc.addNewWrite(); > XmlCursor cursor = write.newCursor(); > cursor.toEndToken(); > cursor.insertNamespace( "xsi", "web-adress2" ); > cursor.insertNamespace( "xsd", "web-adress3" ); > ItemValue item = ItemValue.Factory.newInstance(); > item.setItemName( "S7:[DEMO]TestVar" ); > // some code to create the value > > That code creates the following XML: > <Write xmlns:xsi="web-adress2" xmlns:xsd="web-adress3" xmlns="web- > adress1"> > <Options/> > <ItemList> > <Items ItemName="S7:[DEMO]TestVar"/> > </ItemList> > </Write> > > I have tried a lot to create a "correct" value-entry, but it was not > possible for me. For example: > XmlObject value = XmlObject.Factory.parse( "<Value > xsi:type=\"xsd:short\">87</Value>" ); > > // or > XmlCursor cursor = value.newCursor(); > cursor.beginElement( "Value" ); > cursor.toNextToken(); > cursor.insertAttributeWithValue( "xsi:type", "xsd:short" ); > > The first solution returns: > <Value xsi:type="xsd:short" xmlns:xsi="xsi">87</Value> > > Second solution throws an error that the name is not valid. Do you have > any ideas about it? Thanks a lot. > > Philipp > -- > Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: > http://www.gmx.net/de/go/multimessenger01 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

