I'm trying to write a soap mesage with:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
using XOM.
I'm creating the element using
Element soap = new Element("soap:Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
but I don't know how to add the xmlns:xsi and xmln:xsd attributes. Using
Attribute xsi = new Attribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
return the following error
Attribute objects are not used to represent namespace declarations
So how can I add these attributes?
Thanks
XOM and other tree-based packages should automatically add required namespace declarations, based on namespace URIs (and possibly prefixes) you define for your elements and attributes. So why are you trying to add them explicitly? Does that not work?