[geotk] Problem with 'copyright' special character when XML marshalling

Martin Desruisseaux martin.desruisseaux at geomatys.fr
Tue Jan 21 02:21:40 PST 2014


Hello Emmanuel

Thanks for the links.

Le 20/01/14 16:41, Emmanuel Blondel a écrit :
> (...snip...) Why the copyright is not converted to ©? Same 
> question for diacritics (see spanish words).
Such conversions should not be necessary if the XML file is encoded in 
UTF-8... However if someone wishes to force character conversions, I 
found the following blog which gives a tip about how to do that with JAXB:

http://lauraliparulo.altervista.org/jaxb-part-5-xml-character-handler/

If you choose this approach, you could define your own 
CharacterEscapeHandler and set the property to the Marshaller created by 
Geotk. Note however that the package name (com.sun.xml.bind.marshaller) 
suggests that this is not an officially supported API. And if you use 
the JAXB implementation bundled in the JDK rather than the "endorsed" 
one, then the package name may be com.sun.xml.internal.bind.marshaller.

> (...snip...) I point you to the code i use:
> - Metadata (where i use the copyright symbol in a citation template): 
> https://github.com/openfigis/gis-tools/blob/master/gis-metadata/gis-metadata/main/src/main/java/org/fao/fi/gis/metadata/GeographicEntityMetadata.java 
> (row: 332 - 345)
> - publisher (where i marshall to XML and publish the xml to 
> Geonetwork): 
> https://github.com/openfigis/gis-tools/blob/master/gis-metadata/gis-metadata/publisher/src/main/java/org/fao/fi/gis/metadata/publisher/MetadataPublisher.java#L67

I had a look at the code and it seems all right, so I think that the 
issue is about configuring JAXB for example with the above-cited 
CharacterEscapeHandler.

Can I suggest something? :-) As you may know, we are migrating Geotk to 
Apache SIS (http://sis.apache.org). If the only Geotk API that you are 
using is metadata, this part is already available in Apache SIS 0.3. 
Future evolutions and bugs fixes will happen on Apache side. Actually 
most metadata object are already deleted from Geotk and replaced by 
reference to the Apache classes. The metadata API is close to identical. 
If you wish to migrate, the only thing that you need to do is to replace 
your dependency in the pom.xml (if you are using Maven) by that one (use 
"sis-metadata" instead than "sis-referencing"):

http://sis.apache.org/downloads.html#maven

and replace "import org.geotoolkit..." by "import org.apache.sis..." 
(most class names are identical). Some exceptions are 
SimpleInternationalString which is located in org.apache.sis.util.iso 
(an "iso" sub-package has been added), and Anchor which is handled in a 
slightly different way - I will help you with that one if you are 
interested in the migration, ideally on the Apache SIS mailing list if 
you agree.

Our plan is to keep Geotk as a "laboratory" for Apache SIS. Geotk would 
be built on top of SIS, and Geotk classes are expected to migrate to SIS 
when they are considered mature enough. When a Geotk class migrate to 
SIS, the Geotk one is deprecated before deletion.

     Regards,

         Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20140121/3b9eefe0/attachment.html>


More information about the Geotoolkit mailing list