Giter VIP home page Giter VIP logo

easysaxon's Introduction

Overview

Saxon is a great XSLT processor, but for common needs it is quite complex to use. EasySaxon is a facade over Saxon that makes its use easier.

Main features

  • Use of parametric XSLT sources with automatic type detection
  • Modular transformations through the use of <xsl:import /> tag

Install

The package is built through MAVEN2, so you just have to run clean, compile and package tasks:

mvn clean
mvn compile
mvn package

...then you will find easysaxon-1.0-SNAPSHOT.jar in newly created target folder.

Examples of use

Simple transformation

  • One XML input file
  • One XSL transformation file
  • A string parameter (newtag="John Doe")
SaxonFacade api = new SaxonFacade();

XdmNode input = api.getXdm(Paths.get("src/test/resources/testSource.xml"));
XsltExecutable transform = api.getXsltExecutable(Paths.get("src/test/resources/testTransformation.xsl"));

Map<String, Object> params = new TreeMap<>();
params.put("newtag", "John Doe");

XdmNode output = api.executeTransformation(transform, input, params);
System.out.println(output.toString());

Modular transformation

  • One XML input file
  • Three XSL transformation files (Entry point + 2):
  • Empty parameter list
SaxonFacade api = new SaxonFacade();

XdmNode input = api.getXdm(Paths.get("src/test/resources/testSource.xml"));
XsltBundle bundle = new XsltBundle(Paths.get("src/test/resources/test-main.xsl"));
bundle.addImport("uri:getData-1.xsl", Paths.get("src/test/resources/test-included-1.xsl"));
bundle.addImport("uri:getData-2.xsl", Paths.get("src/test/resources/test-included-2.xsl"));
XsltExecutable transform = api.getXsltExecutable(bundle);

XdmNode output = api.executeTransformation(transform, input, Collections.EMPTY_MAP);
System.out.println(output.toString());

Live examples and demo

Look at eu.sblendorio.easysaxon.test.AppTest class for live examples

easysaxon's People

Contributors

dependabot[bot] avatar sblendorio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

easysaxon's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.