John E Simpson There can't be one for all cases.
>I'll never be able to validate ANY of my XSL doc? No... unless you do as suggested, and create an
application-specific DTD for use in validating your
stylesheet. This can be quite complicated; if XHTML were the
result tree's vocabulary, for instance, you'd have to allow
for the appearance of just about any XHTML element as a
child of just about any XSLT element.
As someone else said, almost no one bothers checking XSLT
stylesheets for validity -- well-formedness is all right, as
long as the XSLT processor (XT, SAXON, whatever) detects
syntax and other XSLT-specific errors. Validity in the XML
sense is not critical for XSLT. Actually, I'd guess that
absolutely no one bothers to check validity of stylesheets;
the "almost" is just a hedge. :)
Joe English adds
Validators usually give better error messages than XSLT
processors, which is helpful for catching gross structural
errors.
Plus, in cases where the stylesheet makes heavy use of
literal result elements, this can go a long way towards
semantically validating the stylesheet (that is, making sure
that the stylesheet produces valid result documents).
However, constructing a DTD against which to validate the
stylesheet in this case can be a bit tricky. It's usually
not hard to customize the XSLT DTD fragment:
<!ENTITY % xsl.dtd SYSTEM "xslt.dtd">
<!ENTITY % html.dtd PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "/dev/null">
%html.dtd;
<!ENTITY % result-elements "%inline; | %block;" >
%xsl.dtd;
but the target DTD *also* has to be parameterized in order
to allow XSL instructions inside literal result elements!
This isn't difficult either if you "cheat" and use an SGML
parser for validation; inclusion exceptions fit the bill
nicely here.
|