xsl-list
[Top] [All Lists]

Re: validation of xslt stylesheets with java

2003-02-09 12:33:12
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 http://www.w3.org/TR/REC-xslt/#dtd 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

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>