This package contains a Java XSL transformer compliant with the JAXP
specification. It depends on the GNU DOM and XPath implementations, and
will generate GNU DOM nodes unless a specific target from another
implementation was given. It understands DOM, SAX, and stream sources
and result sinks and supports these JAXP features.
To use this transformer, set the system property
javax.xml.transform.TransformerFactory
to the value
gnu.xml.transform.TransformerFactoryImpl
. You can then
instantiate
TransformerFactory
and transformers in the ordinary manner. Reuse of stylesheets is
supported using the JAXP
Templates
mechanism.
Architecture
When given a stylesheet source, this implementation compiles it internally
into a Stylesheet object, which is a container for templates and state.
Each stylesheet instruction is represented by a subclass of TemplateNode,
which is arranged in a directed graph: each TemplateNode has a reference
to its first child and the next node.
The transformation process consists of identifying the Template that matches
the root of the source context, and calling apply
on its
corresponding TemplateNode. This in turn processes its children and next
TemplateNode, depending on the semantics of each node type.
Template nodes may reference XPath expressions or patterns. These are fully
compiled to objects of type
Expr at the
time the stylesheet is compiled.
Conformance
This implementation is feature complete, but the XSLT specification is
large and there are still many bugs that need to be ironed out. It has
been tested against the OASIS XSLT TC test suite, comprising unit tests
from the Xalan project and Microsoft. Conformance to these unit tests
is approximately 70% at the current time, although normal usage of the
transformer should involve relatively few surprises (the test suite is
designed to test very complex and obscure functionality).
Note that this transformer implements the XSLT 1.0 specification and not
later specifications.
Known bugs
- When reusing stylesheets using the JAXP Templates mechanism, XSL
apply-imports
instructions will not work.
- XPath filter expressions do not always work as expected (this is a
problem with the GNU XPath implementation rather than the transformer).
This can result in problems with the
position()
function,
as well as select
expressions and numbering.
Obviously we'd like to improve conformance and fix these bugs. If you're
interested in working on any of these issues please
contact us.