Sign In/My Account | View Cart  
advertisement

Article:
 Shortening XSLT Stylesheets
Subject: Shorthands and EXSLT
Date: 2003-06-18 13:20:22
From: Tom Moertel

You asked, "Do you have other ways of keeping XSLT readable?"


One of the things that I do is to use a shorthand notation.


In essence, XSLT is a programming language embedded within XML. While XML is great for writing documents, it isn't a clean and tidy medium in which to express programming languages.


So I don't write XSLT in XML anymore. Instead, I use a shorthand notation.


One such notation is XSLTXT, "the XSLT compact form." It is open source and tailor made for writing XSLT.


http://savannah.nongnu.org/projects/xsltxt


A more general notation is PXSL ("pixel"), the Parsimonious XML Shorthand Language. It's an open-source, extensible shorthand for markup-dense XML, and it also has built-in shortcuts for writing XSLT. (Disclaimer: I'm one of the guys who created PXSL.)


http://community.moertel.com/pxsl/


For advanced users, PXSL has a macro facility that can be used to refactor XSLT code. One particularly good application of its macros is to compartmentalize and reuse the boilerplate code that seems so common to XSLT stylesheets. If you're interested in seeing an example of this, I wrote a diary about it on kuro5hin.org:


http://www.kuro5hin.org/story/2003/6/4/12434/75716


Another option is to write less XSLT code in the first place by using a richer XSLT vocabulary. One such vocabulary is EXSLT, the result of a community initiative to augment XSLT with common, much-needed extensions. Most XSLT processing engines support EXSLT out of the box, and the few that don't can make use of EXSLT implementations written in vanilla XSLT.


http://www.exslt.org/


If your XSLT stylesheets are becoming unreadable, do consider these options. They make a big difference.


Previous Message Previous Message   Next Message Next Message


Sponsored By: