This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
ShoXS: a Shorter XSL Syntax
- From: "Remco Bouckaert" <rrb at xm dot co dot nz>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 5 Jun 2002 07:27:34 +1200
- Subject: [xsl] ShoXS: a Shorter XSL Syntax
- Reply-to: xsl-list at lists dot mulberrytech dot com
The last two year I have been doing quite a bit of
XSL scripting, but after a while I found the
syntax to be a bit too verbose to my taste. So, to
help do the scripting I put together a little tool
that translates XSL to a more compact syntax, edit
in that syntax and translate back to XSL. This syntax
is ShoXS (SHOrter Xsl Syntax, you get it:-).
ShoXS is a bit Javascript-ish, as far as XSL allows
this. Just to give an impression, an XSL fragment
from the XSL FAQ and its ShoXS equivalent:
===============================XSL===============================
<xsl:template name="displayyear">
<xsl:param name="yearlist"/>
<xsl:variable name="year"
select="substring-before($yearlist,',')"/>
<xsl:choose>
<xsl:when test="string-length($year) > 0">
<td><xsl:value-of select="$year"/></td>
<xsl:call-template name="displayyear">
<xsl:with-param
name="yearlist"><xsl:value-of
select="substring-after($yearlist,',')"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="$yearlist"/></td>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
===============================ShoXS==============================
fun displayyear {
par yearlist=""{}
var year="substring-before($yearlist,',')"{}
switch {
case(string-length($year) > 0) {
<td>val($year)</td>
call displayyear {
wpar yearlist=""{val(substring-after($yearlist,','))
}
}
}
default{
<td>val($yearlist)</td>
}
}
}
===================================================================
If you want to see a bit more about ShoXS, have
a browse on http://www.xm.co.nz/ShoXS.htm where you
can find ShoXSPad, a notepad like tool to toggle between
XSL and ShoXS. A bit more useful is a version integrated
in jEdit, which I use myself.
It should be easy to get to grips with ShoXS if you know XSL:
just key in the XSL, toggle to ShoXS and look at the ShoXS
equivalent.
Let me know if you have any constructive comments or
suggestions (or find any bugs).
Enjoy,
Remco
rrb@xm.co.nz
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list