I am using jibx lib to generate xsd to java code.I have created jar file as well using ant. Where we need to set xmlschemalocation so when we do marshalmessage as below we can get xsd location.
public String marshalMessage(Object message)
{
try {
IBindingFactory jc = BindingDirectory.getFactory(DeviceCapability.class);
IMarshallingContext marshaller = jc.createMarshallingContext();
ByteArrayOutputStream out = new ByteArrayOutputStream();
marshaller.marshalDocument(message, URL_ENCODING, null, out);
return out.toString(STRING_ENCODING);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (JiBXException e) {
e.printStackTrace();
}
return null;
}
//This is used to create the object
DeviceCapability devicecapability = new DeviceCapability();
devicecapability.setHref("Hello");
String xml = marshalMessage(devicecapability);
Generated xml o/p is ?xml version="1.0" encoding="UTF-8"?> /DeviceCapability xmlns="http://zigbee.org/sep" href="Hello"//>
I want o/p like below ?xml version="1.0" encoding="UTF-8"?>DeviceCapability xmlns="http://zigbee.org/sep" href="Hello" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://zigbee.org/abc abc.xsd/>
Can someone tell me how to add schemalocation using jibx.I have used ant codegen/bind tools.