Skip to content

jessealama/xslutils

Repository files navigation

xslutils: Handy XLST 1.0 stylesheets

Getting started

The .xsl files are ready to go. There is a Makefile for converting the .xsltxt files to .xsl. (I program my stylesheets in XSLTXT, not XSL. See below.) To compile them just do make.

The stylesheets

  • copy.xsl: Defines an XSLT mode (called simply copy) that makes a deep copy of the current context node. (At the moment, it does not handle text nodes.)

  • die.xsl: Defines a mode, die, that kills the XSLT processor (using the msg XSLT function), going down with a given message. (See also trace.xsl.)

  • list.xsl: Apply a template to the nodes of a nodeset, separated by a given delimiter.

  • trace.xsl: Prints out (using the msg XSLT function) a kind of XPath-y trace of where the current node is. (See also die.xsl.)

  • strict.xsl: If we don't handle something explicitly, kill the XSLT processor.

  • strings.xsl: Some handy functions for manipulating strings:

    • lc: Lowecase a string

    • uc: Upppercase a string

    • capitalize: Capitalize a string.

    • position-in-string: At what position does a character (more generally, a string) first occur in a string?

    • starts-with-capital-letter: Does this string start with a capital letter?

  • token-strings.xsl: Working with strings of "tokens".

    A token string is basically a list, but represented as a string. Elements (tokens, items) are supposed to be delimited by commas; the whole string begins and ends with a comma. The empty token string is ,,. Here's a token string with one element: ,5,. The element is the string "5". Token strings are essentially just lists, and the functionality provided by this stylesheet is essentially just a kind of XSLT list.

    • token-string-is-empty: Is the given token string empty?

    • token-string-tail: Extract the tail of the token string (everything except the first token).

    • token-string-head: Extract the first element (the head) of the token list.

    • is-valid-token-string: Determine whether an arbitrary string is a token string.

    • count-items-in-token-string: How many items does this token string contain?

    • add-to-token-string: Add an item to the front of a token string.

XSLTXT

XSLT stylesheets are XML files. But who wants to write these XML files? I program my stylesheets in XSLTXT and then compile these to XSL. If you like the idea of XSLT but loathe writing the bloated XML by hand, consider XSLTXT.

Acknowledgements

Thanks to Josef Urban for getting me started with XSLT and for introducing me to XSLTXT. Some of the functions provided here are due to him.

About

Utilities for working with XSL files.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages