|
|
|
|
jaxP and jaxB
Posted:
Nov 5, 2009 9:05 AM
|
|
|
Hi,
I use an XML writer based on a XMLEventWriter.
For some part of my xml i want to use JAXB to marshall an object into my XMLEventWriter.
The Marshaller of JAXB has the capability to do that :
eventWriter.add(new StartDocumentEvent("UTF-8")); eventWriter.add(new CharacterEvent("\n")); eventWriter.add(new StartElementEvent("root")); eventWriter.add(new StartElementEvent("firstproperty")); eventWriter.add(new CharacterEvent("somevalue")); eventWriter.add(new EndElementEvent("firstproperty"));
Marshaller m = pool.acquireMarshaller(); m.marshal(myobjectToMarshall, eventWriter);
The problem is that : - first i've got a second xmlHeader beginning at the node of my JAXB marshall - second : i lost the pretty print of JAXB (i can survive that but ...)
example of the created xml:
<?xml version="1.0" encoding="UTF-8"?> <root> <firstproperty>somevalue</firstproperty> <lagune>Canet</lagune> <?xml version="1.0" encoding="UTF-8"?><gml:MultiGeometry xmlns:gml="http://www.opengis.net/gml"><gml:geometryMember><gml:PolyhedralSurface srsName="EPSG:27593"><gml:polygonPatches><gml:PolygonPatch><gml:exterior><gml:Ring srsName="EPSG:27593"><gml:curveMember...................</r
Is someone now a solution to at least remove the second XML header (properly)
Guilhem Legal
|
|
|
|
|
|
|
Re: jaxP and jaxB
Posted:
Nov 6, 2009 5:19 AM
in response to: guilhem_legal
|
|
|
I reply to myself, to remove the xml header in the JAXB marshalled you have to add a property to the JAXB marshaller :
marshaller.setProperty(marshaller.JAXB_FRAGMENT, true);
I still looking for the pretty print part
|
|
|
|
|