A SNAT-based code generator is available at github ([5]). It generates the code of document transformations defined by a SNAT document. The SNAT is prepared by hand-editing an initial version generated from an XSD description of the target documents. After changes of the XSD, the SNAT can be upgraded automatically. The upgrade ensures that the SNAT is kept in sync with the XSD. Usually, the upgrade must be finalized by a limited amount of hand-editing, for example adding manual settings for any new items.
A typical workflow is illustrated by an example in which we assume the use of
BaseX ([2]) as XQuery processor. Let target documents of the
desired transformation code have a root element <publications>
and
be described by an XSD publications.xsd
. The first step is the
generation of an initial version of a SNAT document
(publications.snat.xml
):
basex –b "request=snat?xsd=/a/b/c/publications.xsd, ename=publications" –o publications.snat.xml $HOME_XSDPLUS/xsdplus.xq
After editing the SNAT document, the transformation code
(publications.xq
) is generated:
basex –b "request=snat2xq?snat=publications.snat.xml" –o publications.xq $HOME_XSDPLUS/xsdplus.xq
Given a set of input documents (e.g. books.xml
), the transformer can
be tested, creating a target document publications.xml
:
basex –i books.xml –o publications.xml publications.xq
After changes of the XSD, the SNAT document must be upgraded. After renaming the
current SNAT document (e.g. to publications.snat.v100.xml
), this is
achieved by the following command:
basex –b "request=snat?xsd=/a/b/c/publications.xsd, ename=publications, upgrade=publications.snat.v100.xml" –o publications.snat.xml $HOME_XSDPLUS/xsdplus.xq
As a new XSD version typically contains new elements and attributes, the automatic upgrade must be followed by hand-editing which supplies the necessary settings not yet made.