RE: [xsl] Transform XML to XML

Subject: RE: [xsl] Transform XML to XML
From: "Mike Schinkel" <mikes@xxxxxxxxx>
Date: Fri, 26 Aug 2005 09:42:06 -0400
>> This is the main motivation behind the introduction of
schema-awareness in XSLT 2.0.

Awesome! So when do you think most tools will support 2.0?   2007? 2008?


-Mike

-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: Friday, August 26, 2005 3:52 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Transform XML to XML

> One thing I do really dislike about XSLT, at least from what I
> understand, is there doesn't seem to be a way to write robust code in
> XSLT; if my input XML is off by a bit (i.e. well-formed but not
> validated by a schema), or if I make a boneheaded change to the XSL,
> the transform may not output what I expect but there's little way for
> me to catch the error without painstaking proofreading after each
> transform
> (scenario: after somethings been printed for a while; opps, looks our
> XSL forgot to include that chapter!)

This is the main motivation behind the introduction of schema-awareness
in XSLT 2.0.

Firstly, you can validate the output against a schema. Sometimes you
will get compile-time error messages telling you that the stylesheet
cannot possibly produce valid output; more often you will get run-time
error messages telling you that line 1234 of the stylesheet is trying to
output something that's invalid (or failing to output something that's
required).
My experience is that this greatly speeds up the debugging cycle.

Secondly, you can validate the input against a schema, and define your
template rules in terms of schema types. For example <xsl:template
match="schema-element(invoice)"/>. This enables the XSLT processor to do
a lot of compile-time checking of your stylesheet code, for example it
can spot path expressions that could never select anything.

Give it a try (follow the link below).

Michael Kay
http://www.saxonica.com/

Current Thread