Official XSLT validator?

前端 未结 3 1582
你的背包
你的背包 2021-02-19 04:21

Is there any official XSLT validator, like http://validator.w3.org/ for HTML & XHTML?

I know http://validator.w3.org/ can also be used to validate XML and XSL docume

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-19 05:23

    I assume that by validating XSLT stylesheets you mean checking whether the elements, attributes etcetera in an already well-formed XML document (which appears to be XSLT code) adhere to the XSLT W3C specification.

    First of all, note that there is a difference between the well-formedness and validity of an XML document. It is well-formed if the contained elements are properly nested, if there is a single root element and so forth (this is defined by the XML specification). Also see: Is there a difference between 'valid xml' and 'well formed xml'? .

    The validity of an XML document can only be verified together with an XML schema (or DTD, or RelaxNG...). A schema is a set of rules defining, for example, which elements and attributes are allowed in what sequence.

    Now, to answer your question: There is no such service from W3C, however, there is a schema available, see e.g. http://www.w3.org/2007/schema-for-xslt20.xsd for a schema that incorporates all the structures of "standard" XSLT 2.0.

    You can validate your XSLT code against this schema. Still, it is more insightful to just run your code with an XSLT processor and look for the warnings and errors it produces.


    Besides, be aware that the validity of XSLT code and the validity of the XHTML it outputs is not the same. Even if your XSLT is perfectly valid with respect to the XSLT specification, it does not mean that the resulting XHTML is reasonable.

提交回复
热议问题