I have jaxb objects from xsd and want to generate xml with this code:
StringWriter strWriter = new StringWriter();
try {
JAXBContext jc = JAXBContext.newInstance(Constante.getInstance().getString("JAXB_CONTEXT_PATH"));
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);
m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
m.setProperty(Marshaller.JAXB_ENCODING, Constante.getInstance().getString("JAXB_CODIFICACION"));
m.setProperty("com.sun.xml.bind.xmlDeclaration", Boolean.FALSE);
strWriter = new StringWriter();
m.marshal(jaxpObject, strWriter);
} catch (JAXBException ex) {
logger.log(Level.SEVERE, "Error al convertir Jaxp a XML", ex);
}
return strWriter.toString();
The output is:
<ns3:OficioElectronico xmlns:ns3="http://www.cidge.gob.mx/SCG/Interoperabilidad" xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:ns4="http://www.w3.org/2001/04/xmlenc#" Confidencialidad="Publica" EnRespuestaDe="GSCE-ENV-1" Folio="GSCE-ENV-1" TipoOficio="Solicitud" VersionEsquema="1.0">
<ns3:Transformacion Tipo="XSLT" Uri="www.xslt.mx"/>
...
but i need it without ns3, ns2, xmlns:ns3... etc. like this:
<OficioElectronico Confidencialidad="Publica" EnRespuestaDe="GSCE-ENV-1" Folio="GSCE-ENV-1" TipoOficio="Solicitud" VersionEsquema="1.0">
<Transformacion Tipo="XSLT" Uri="www.xslt.mx"/>
...
any help, thanks.