Bonsoir,

Est il possible en Java7 de générer un xml avec plusieurs xmlns
par exemple
<GereService xmlns="http://www.toto.fr/namespace/EXP/0/0/inscri" xmlnssi="http://www.w3.org/2001/XMLSchema-instance" xmlns:commun="http://www.toto.fr/namespace/EXP/0/0/commun" Profil_Version="1.0" PAMD_Profil="INS" PAMD_Version="0.0" xsi:schemaLocation="http://www.toto.fr/namespace/EXP/0/0/inscri/style_inscri_vb_0r2.xsd">
ICI
xmlnssi
xmlns:commun
Mon soucis est que la classe Java est elle meme généré par Maven/Jaxb, et donc la classe package-info.java est régulièrement regénérée.


En Java6 j'utilisais, mais cela ne fonctionne plus
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
  public static byte[] objectToXML(Object objet, String []uris2,String shemaLocation) throws JAXBException {
              ByteArrayOutputStream flux = new ByteArrayOutputStream();
 
                JAXBContext context = JAXBContext.newInstance(objet.getClass()
                      .getPackage().getName());
              Marshaller m = context.createMarshaller();
              m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
              m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
 
             PreferredMapper mapper = new PreferredMapper(uris2);
 
              m.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper);
 
              if(shemaLocation!=null)
                  m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, shemaLocation) ; 
 
              m.marshal(objet, flux);
 
              return flux.toByteArray();
       }
Est il possible de passer plusieurs JAXBElement chacune avec une Uri différente ??

Merci d'avance
Phil