Read this blog post too: Declarative and Immutable Pipeline of Transformations
Also, watch this video from Object Thinking Meetup #7.
It's a declarative and immutable chain of XSL transformations in Java,
which is more convenient than an imperative routine application
of transformations one by one. EO compiler
is an example use case: the source code compiles to XML and then has
to go through a few dozen transformations written in XSL. Each transformation
has to be logged, validated, and in general be flexibly configurable. We started
with a series of consecutive instantiations and executions of
XSLDocument
,
but then realized the necessity to turn this workflow into something more
object-oriented. This is how this library was born.
You add this to your pom.xml
(find the latest version here):
<dependency>
<groupId>com.yegor256</groupId>
<artifactId>xsline</artifactId>
<version><!-- use the latest one --></version>
</dependency>
Use it like this:
import com.jcabi.xml.XML;
import com.jcabi.xml.XMLDocument;
import com.jcabi.xml.XSLDocument;
import com.yegor256.xsline.Shift;
import com.yegor256.xsline.StXSL;
import com.yegor256.xsline.TrDefault;
import com.yegor256.xsline.Train;
import com.yegor256.xsline.Xsline;
import java.io.File;
Train<Shift> train = new TrDefault<Shift>()
.with(new StXSL(new XSLDocument(new File("first.xsl"))))
.with(new StXSL(new XSLDocument(new File("second.xsl"))));
XML input = new XMLDocument("<hello/>");
XML output = new Xsline(train).pass(input);
This will transform your input
XML document through two XSL stylesheets.
Fork repository, make changes, send us a pull request.
We will review your changes and apply them to the master
branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run full Maven build:
$ mvn clean install -Pqulice
You will need Maven 3.3+ and Java 8+.