sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Desruisseaux (JIRA)" <>
Subject [jira] [Created] (SIS-152) Consider using XSLT for handling XML documents compliant to different version of the standards
Date Thu, 05 Dec 2013 06:20:41 GMT
Martin Desruisseaux created SIS-152:

             Summary: Consider using XSLT for handling XML documents compliant to different
version of the standards
                 Key: SIS-152
             Project: Spatial Information Systems
          Issue Type: Task
          Components: Utilities
    Affects Versions: 0.3
            Reporter: Martin Desruisseaux
            Priority: Minor

OGC standards are updated once every few years. When a standard get significant changes, OGC
produces a new XML schema with a new namespace URI. For example when upgrading from GML 3.1
to 3.2, the namespace URI changed from to

Such namespace changes are problematic with JAXB because the usual pattern is to create distinct
Java classes for elements in different namespaces, even if the elements are otherwise identical.
This is because namespaces in JAXB annotations are static. We can generate those classes using
the {{xjc}} compiler for all versions, but OGC/ISO standards have thousands of elements, and
duplicating all of them for every version has many inconvenient:

* Massive code duplication (hundreds of classes, many of them strictly identical except for
the namespace).
* Handling of above-cited classes duplication requires either a bunch of {{if (x instanceof
Y)}} in every SIS corners (unconceivable), or to modify the {{xjc}} output in order to give
to generated classes a common parent class or interface. In the later case, the auto-generated
classes require significant work anyways.
* The namespaces of all versions appear in the {{xmlns}} attributes of the root element (we
can not always create separated JAXB contexts), which is confusing and prevent usage of usual
prefixes for all versions except one.

An alternative is to support only one version of each standard, and transform XML documents
before unmarshalling or after marshalling if they use different versions of standards. XSLT
is often used for that, but this is heavy.

A lighter approach is to use {{}} and {{XMLStreamWriter}}
as "micro-transformers". This is the approach currently taken by SIS. This works for simple
changes. However if the changes to support become more complicated, we may revisit this choice
and uses XSLT together with {{javax.xml.transform}}.

This task is opened as a reminder that the use of XSLT in place of our custom filters is an
open question. This is not necessarily something that we should do - it will depends on experience

This message was sent by Atlassian JIRA

View raw message