Since Year 2000

Version 0.7
Check out TerseXML project

XSLScript is for those, who are writing complex XSLT stylesheets.

XSLScript is a terse notation for writing complex XSLT stylesheets. XSLScript is part of  Hiawatha web-server, but XSLScript also can be used stand-alone.

To execute XSLScript script:

xsls some.xml some.xsls

The XSLScript script (some.xsls) gets compiled into corresponding XSLT stylesheet and then generated XSLT stylesheet is applied to the file some.xml (no temporary .xsl file is created, this all happens in the memory). The actual XSLT tranformation is performed by SAXON. There is 1-1 lines mapping between XSLScript script and generated XSLT ( this means if some XSLScript construction starts on line 5, the corresponding XSLT construction will also start on the same line 5. )

To generate the XSLT stylesheet out of XSLScript script:

xslsdump some.xsls


xslsdump-indent some.xsls

if you want a nice looking indentation.

Why XSLScript ?

XSLT syntax is not for human beings.

One can write complex XSLT code in XSLScript and then generate the 100% XSLT stylesheet. Like I do. Occasionaly.

Can I use my XSLT stylesheets with XSLScript?

You can use xsl:import / xsl:include to include .xsl into .xsls and to include .xsls into .xsl.

What if I like writing <xsl:something?

You can write XSLT instructions in plain XSLT, XSLScript preprocessor will not touch them and will pass those constructions as-is.

Top-level elements should be plain XSLScript.

What is XSLScript ?

XSLScript is just syntax sugar, 1-1 mapping of XSLT. The only exception is that XSLScript has 'else' (which is missing in XSLT). In XSLScript if-else is translated into appropriate xsl:choose-when-otherwise. XSLScript could get more 'non-xslt' semantics if you ask me for something you need.

OK, but what is XSLScript ?

Snippet 1

X:stylesheet {

X:template = "poem" {
		<title> !{title} </title>
		!! "title";
		!! "author";
		X:apply-templates "stanza";
		X:apply-templates "date";

X:template = "title"  { <div align="center"><h1> !{.} </h1></div> }
X:template = "author" { <div align="center"><h2> By <% !{.} %> </h2></div> }
X:template = "stanza" { <p> !! "line"; </p> }

X:template = "line" {
    X:if "position() mod 2 = 0" {&#160;&#160;} 
    !{.} <br/>

X:template = "date" { <p><i> !{.} </i></p> }



Snippet 2

X:transform {

X:template max( list ) {
    X:if "$list" {
	   X:variable first="count($list[1]/LINE)"
	   X:variable max-of-rest={ !max( list="$list[position()!=1]" ) }

	   X:if "$first &gt; $max-of-rest"  {
	   } else {
    } else {
 X:template ="/" {
  Longest speech is <% X:text; !max( list="//SPEECH" ) X:text; %> lines.   

Syntax overview

Rather than drawing the mapping for all of 35 XSLT elements, I'l just provide the mapping rules. If this is not enough, please note that XSLScript distribution contains more than 10 examples of XSLScript code. Those examples are XSLT stylesheets from Michael Kay's XSLT Programming Reference (available for download from Wrox website) rewritten in XSLScript. This results in XSLScript examples being educational and covering almost every XSLT (XSLScript) command.



Because SAXON (http://users.iclway.co.uk/mhkay/saxon/) is 100% free, XSLScript distribution contains everything you need to run XSLScript.

xsls.jar includes not only .class files, but also the source code of XSLScript

XSLScript is 100% free.


Paul Tchistopolskii.  

Changes in version 0.7

(major rewrite)

Changes in version 0.51

(small bugfixes)