2

I'm using jaxb to marshall data

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MessageType", propOrder = {

})
@XmlRootElement(name = "message")

  protected String source;
  protected GroupesVeh groupesVeh;
  @XmlSchemaType(name = "dateTime")
  protected XMLGregorianCalendar heureMesure1;
  @XmlSchemaType(name = "dateTime")
  protected XMLGregorianCalendar heureMesure2;

and when i m using jaxb to marshal this like :

  Marshaller marshaller = jaxbContext.createMarshaller();
  marshaller.marshal(messageType, writer);

i got :

<source xmlns="" xmlns:ns7="http://www.w3.org/2005/08/addressing">SOURCE</source>
<groupesVeh xmlns="" xmlns:ns7="http://www.w3.org/2005/08/addressing"/>
<heuremesure1 xmlns="" xmlns:ns7="http://www.w3.org/2005/08/addressing">2016-02-12T14:40:56.000Z</heuremesure1>
<heuremesure2 xmlns="" xmlns:ns7="http://www.w3.org/2005/08/addressing">2018-02-07T10:59:00.439Z</heuremesure2>

how can i do to remove xmlns="" xmlns:ns7="http://www.w3.org/2005/08/addressing"? to obtain only :

    <source>SOURCE</source>
    <groupesVeh/>
    <heureMesure1>2016-02-12T14:40:56.000Z</heureMesure1>
    <heureMesure2>2018-02-07T09:21:48.092Z</heureMesure2>

thanks by advance.

  • 1
    I think this solution might be appropriate [Link](https://stackoverflow.com/questions/2816176/how-to-marshal-without-a-namespace/5597035#5597035) – sharon182 Feb 07 '18 at 14:45
  • 1
    I think [ this link] (https://www.programcreek.com/java-api-examples/?api=com.sun.xml.bind.marshaller.NamespacePrefixMapper) has most of the namespaces related answers. For the solution to your problem, search for the comment "Remove unused namespace prefixes". That being said, if you've found a cleaner approach, please comment it below or add it as an answer for future folks :) – storesource Jun 21 '19 at 06:14

0 Answers0