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]