users@jaxb.java.net

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

From: Pavel Bucek <Pavel.Bucek_at_Sun.COM>
Date: Fri, 06 Mar 2009 14:02:20 +0100

Hello,

see
http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlRootElement.html

Correct way to change name of generated element is
@XmlRootElement(name="foo")

Regards,

Pavel


Florian Bachmann wrote:
> Dear JAXB team,
> 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/ ).
>
> So far so good, but as soon I want to marshal some objects into
> an xml/kml-file I get this output:
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <kml xmlns="http://www.opengis.net/kml/2.2"
> xmlns:ns2="http://www.w3.org/2005/Atom"
> xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
> <AbstractFeatureGroup
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:type="DocumentType">
> <name>testSNPN</name>
> <abstractFeatureGroup xsi:type="PlacemarkType">
> <name>P1</name>
> <AbstractGeometryGroup xsi:type="LineStringType">
> <tessellate>true</tessellate>
> <coordinates>-122.370533,37.823842,0</coordinates>
> </AbstractGeometryGroup>
> </abstractFeatureGroup>
> </AbstractFeatureGroup>
> </kml>
>
> but the produced output isn't readable by Google Earth.
> Especially the <AbstractFeatureGroup
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:type="DocumentType"> part, should be only <Document>
> and the whole should be:
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <kml xmlns="http://www.opengis.net/kml/2.2"
> xmlns:ns2="http://www.w3.org/2005/Atom"
> xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
> <Document>
> <name>testSNPN</name>
> <Placemark>
> <name>P1</name>
> <LineString>
> <tessellate>true</tessellate>
> <coordinates>-122.370533,37.823842,0</coordinates>
> </LineString >
> </Placemark>
> </Document >
> </kml>
>
>
> So my question is it possible to affect the tag-name?
> (From "DocumentType" to "Document" and the whole from
> <AbstractFeatureGroup ... xsi:type="DocumentType"> direct into the type?
>
> I tried to add @XmlRootElement() to each class
> (@XmlRootElement("Document") to the
> DocumentType-class, @XmlRootElement("Placemark") to the
> Placemarktype-class, ...)
>
> but it doesn't seem to have any influence to the marshalled output.
>
> Could anybody give me a hint, to get the desired output?
>
> regards
> Flori
>
>
>
>
>
>
>
>