Re: [xsl] validation of xslt stylesheets with java

Subject: Re: [xsl] validation of xslt stylesheets with java
From: Mike Brown <mike@xxxxxxxx>
Date: Sun, 9 Feb 2003 12:33:12 -0700 (MST)
florian wrote:
> i was wondering if there is a way to validate xslt stylesheets
> somehow? (would be cool if there would be a way with java).

XSLT processors generally do some checks of the stylesheet structure when they
are "compiling" or "preparing" it, and will report errors at that time. JAXP
implicitly acknowledges this step in the creation of a Templates object, but
exactly when and how this occurs is going to be implementation dependent,
generally speaking. Some errors can only be detected at run-time because they
depend on information in an XPath context. Some errors that use XPath
expressions but that don't depend on context are detectable ahead of time, but
not all processors will look for them.

And then explains, to some extent, why
validation (in the pure XML 1.0 sense) using DTDs is difficult. The biggest
hurdle, not clearly mentioned in the spec, is that literal result elements and
namespace declarations are allowed to appear in stylesheets, and are more or
less random in what they look like and where they can occur. Since DTDs
require all elements and attributes to be explicitly declared, and either
explicitly referenced or referenced with the all-encompassing "ANY" token, one
would have to heavily customize each DTD for each stylesheet.

Other schema validation mechanisms may be better equipped to deal with the 
"random" nature of stylesheets, but it's unlikely.


  Mike J. Brown   |
  Denver, CO, USA |

 XSL-List info and archive:

Current Thread