How can I get rid of xlmns="any" in my root element :-
e.g
<?xml version="1.0" encoding="UTF-8"?>
<CTP xmlns="any">
<CTPHEADER>
when Marshalling ?
It may stem from some manipulation I have done to an AnyNode type. My main
XSD I cannot change it has <xs:any> for certain elements.
The XML Instance is like a composite document, the main part has an Element
<AIPCASERQDATA> but has a type of <xs:any> .
I take the elements under the AnyNode :-
Object[] anyNodeObjects =
ctp.getAIPCASERQV100().getAIPCASERQDATA().getAnyObject();
Marshall them to a StringWriter, just to get the AnyNode Elements as an XML
String :-
for (int i = 0; i < anyNodeObjects.length; i++)
{
Marshaller marshaller = new Marshaller(sw);
marshaller.setNamespaceMapping("","any");
marshaller.marshal(anyNodeObjects [i]);
}
I then Unmarshall the AnyNode XML String to some java classes that have been
generated from another XSD that represents the sub-schema.
StringReader sr = new StringReader(sw.toString() );
REQUEST aipReq = (REQUEST) Unmarshaller.unmarshal(REQUEST.class,
sr);
I eventually need to put back the data into the AnyNode :-
ctp.getAIPCASERQV100().getAIPCASERQDATA().clearAnyObject();
ctp.getAIPCASERQV100().getAIPCASERQDATA().addAnyObject(aipReq);
But when I marshall like this :-
FileWriter fw = new FileWriter("D:\\Projects\\marshalled.XML");
Marshaller marshaller2 = new Marshaller(fw);
marshaller2.setNamespaceMapping("","any");
marshaller2.marshal(ctp);
I get :-
<CTP xmlns="any">
but the elements at the point of the AnyNode look fine :-
<AIPCASERQV100>
<AIPCASERQDATA>
<REQUEST>
OR if I get rid of the 2nd marshaller2
//marshaller2.setNamespaceMapping("","any");
then I get a perfect root element :-
<CTP>
but then get the namespace any appearing at the point of the AnyNode
<AIPCASERQV100>
<AIPCASERQDATA>
<ns1:REQUEST xmlns:ns1="any">
This is really frustrating please help.
This transmission is confidential and intended solely for the person or
organisation to whom it is addressed. It may contain privileged and
confidential information. If you are not the intended recipient, you should
not copy, distribute or take any action in reliance on it. If you have
received this transmission in error, please notify the sender immediately.
Any opinions or advice contained in this e-mail are those of the individual
sender except where they are stated to be the views of RDF Group or EMS plc.
All messages passing through this gateway are virus scanned.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev