0

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.

user3241039
  • 23
  • 1
  • 5
  • 1
    try this one : http://stackoverflow.com/questions/2816176/jaxb-how-to-marshal-without-a-namespace?rq=1 – Sembrano Feb 19 '14 at 19:32
  • [here](http://stackoverflow.com/a/8273148/2415194) – nachokk Feb 19 '14 at 19:34
  • Namespaces are significant. Removing them means that your XML document will no longer be valid against the XML schema you used to generate the model. Is this really what you mean to do? – bdoughan Feb 19 '14 at 20:47

0 Answers0