users@jaxb.java.net

Re: XmlRootElement to influence tag-name? Or how to get rid of <AbstractClasss xmlns:xsi="..." xsi:type="DocumentType">

From: Florian Bachmann <f.bachmann_at_micromata.de>
Date: Fri, 6 Mar 2009 14:27:25 +0100

Hi Lexi,
this is the way I create my object structure:

                final ObjectFactory obj = new ObjectFactory();

                final KmlType kml = new KmlType();
                final DocumentType document = new DocumentType();

                kml.setAbstractFeatureGroup(obj.createAbstractFeatureGroup(document));
                document.setName("testSNPN");

                final PlacemarkType p1 = new PlacemarkType();
                p1.setName("P1");

                final LineStringType ls = new LineStringType();
                ls.setTessellate(true);
                ls.getCoordinates().add("-122.370533,37.823842,0");

                p1.setAbstractGeometryGroup(obj.createAbstractGeometryGroup(ls));

                document.getAbstractFeatureGroup().add(obj.createPlacemark(p1));


and marshall it:
                try {
                        final JAXBContext context = JAXBContext.newInstance(KmlType.class);
                        final Marshaller marshaller = context.createMarshaller();
                        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
Boolean.TRUE);
                        marshaller.marshal(kml, System.out);
                } catch (final Throwable ex) {
                        LOG.error("error", ex);
                }

The https://ogc.dev.java.net/- project already generate classed for
the kml schema,
the don't mention it on their site, but they have the binding file in
their svn-trunk repository.

bye
Flori


Am 06.03.2009 um 14:10 schrieb Aleksei Valikov:

> Hi.
>
>> I created a bunch of classes from the ogc kml-schema
>> (used by Google Earth and Google Maps and found here:
>> http://www.opengeospatial.org/standards/kml/ ).
>
> By the way, there's the following project which deals with compiling
> OGC schemas with JAXB:
>
> https://ogc.dev.java.net/
>
> I think it would make sense adding KML schemas there.
>
>> So far so good, but as soon I want to marshal some objects into
>> an xml/kml-file I get this output:
>
> Would you please show your code? I think you may be composing your
> object structure incorrectly.
>
> Bye.
> /lexi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>