com.caucho.xsl.package.html Maven / Gradle / Ivy
Show all versions of resin Show documentation
The XSLT transformation package. XSLT transforms XML trees to XML
trees using Stylesheets. The steps for a typical transformation are:
- Create the XSLT stylesheet.
- Read the source document.
- Transform the source document.
The Caucho XSL package supports two related stylesheet languages.
XSLT (W3C 1.0) and 'StyleScript'. Strict XSLT stylesheets are
created by parsing the XML externally, then generating the stylesheet:
StylesheetFactory factory = new Xsl();
Stylesheet style = factory.newStylesheet("mystyle.xsl");
StreamTransformer transformer = style.newStreamTransformer();
WriteStream os = Vfs.openWrite("test.html");
transformer.transform("test.xml", os);
os.close();
StyleScript stylesheets just use a different stylesheet factory.
StylesheetFactory factory = new StyleScript();
Stylesheet style = factory.newStylesheet("mystyle.xsl");
StreamTransformer transformer = style.newStreamTransformer();
WriteStream os = Vfs.openWrite("test.html");
transformer.transform("test.xml", os);
os.close();
Transformers
Resin's XSL provides several different output methods, each represented
by a transformer:
- StreamTransformer - print directly to an output stream
- StringTransformer - create a string from the result
- NodeTransformer - append the results to an XML node