scripting or scripting-like features

Subject: scripting or scripting-like features
From: "Lawton, Scott" <slawton@xxxxxxxxxxxx>
Date: Tue, 10 Nov 1998 12:27:14 -0500
I've just spent more than a week using XSL to transform XML into HTML.  I
realize that XSL isn't ready for prime time but I thought it was better to
start with that than build something else from scratch.

I like the basic approach: specify a pattern to match tags and associate
with it an output template.  The XSL processor handles conflict resolution &
the inherent hierarchy of XML.  That's very useful.

However, it seems that the current draft of XSL just doesn't have enough
expressive power.  I've encountered so many things that would have been
trivial if I had clean, simple, orthogonal "scripting" power: variables,
arbitrary conditionals and general-purpose macros/functions/subroutines.
Some examples (not attempting XML/XSL syntax for the most part):

- create attributes; then later code doesn't have to distinguish between a
value provided in the XML file and a default value provided by XSL:

	if not attribute.exists(value)
		value = "50"
	<myTag value="{attribute(value)}"/>

- pass arbitrary flags to macros/functions/subroutines then test them:
	on doThis(someFlag)
		switch someFlag
			case "this"
			case "that"

- use character data in a conditional, e.g. given <someTag>the
	<!-- add colon & space after the text, but not if there is no text!
	if someTag not equals ""
		<xsl:text>: </xsl:text>

- more flexibility in getting character data, e.g. the text until the first
tag, all text at the top level (at the moment I can only get the entire
text, including that nested in other tags)

- more direct access to data at any point in the tree, e.g. so a child
element can get an attribute from it's immediate parent -- or a parent could
make an arbitrary query of its children or descendents

I'm sure there are plenty more examples....


 XSL-List info and archive:

Current Thread