RE: [xsl] Apply-templates - how to omit top level element tags?

Subject: RE: [xsl] Apply-templates - how to omit top level element tags?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 9 Sep 2005 23:36:15 +0100
> XSL is fragile because you can break things by messing
> around?  That's pretty much true of any complex system.

Yes: though more true of some systems than of others.

XSLT 1.0 is designed with a rather different notion of robustness than many
other languages: it's designed on the principle that if you hit something
unexpected in the input, you should struggle on to produce some kind of
output rather than catching fire and printing a stacktrace on the poor
user's screen. There are times when this is quite a good idea. But it does
have the consequence that writing incorrect code often causes the stylesheet
to produce garbage output. Other languages have a different notion of
robustness: incorrect code should wherever possible produce an error message
to tell you what you've done wrong.

XSLT 2.0, especially if you opt for schema-awareness, has swung a long way
towards this more conventional definition of robustness. Write a schema
describing the input document, and a schema describing the output document,
and write your stylesheet code to be schema-aware, and you will find that
many of your coding errors are detected at compile time, or failing that at
run-time. If this is a style you are more comfortable with, give
schema-aware XSLT a try, and tell us how you get on.

Michael Kay

Current Thread