Update: I you are interested only by the eclipse part of this post take a look at a more recent/specialize post: "
XSD schema validation for XSL and auto-completion in eclipse (second edition)"
If you want information about xerces, ant, xsl and validation keep reading this one ;) Good luck!
I wanted to have auto-completion and validation on xsl in eclipse. I did it but it was hard!
First You need to understand how xsd works. For syntax examples see
xerces doc at the bottom of the page.
You can add those lines to your stylesheet:
<xsl:stylesheet xsl="http://www.w3.org/1999/XSL/Transform" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://www.w3.org/1999/XSL/Transform http://www.w3.org/2005/02/schema-for-xslt20.xsd" version="2.0">
But according to the w3c spec you can override the schema location with a global attribut.
In eclipse-3.1 you can do it in Window>Preferences>Web and XML>XML Catalogue:
In Xerces you can do it with a property -
see the doc.
In Ant you can set xerces property in xmlvalidate ant task (but there was a
bug, I provided a patch
here)
An ant build file snippet to validate xsl:
<xmlvalidate failonerror="yes" lenient="no" warn="yes">
<attribute name="http://xml.org/sax/features/validation" value="true">
<attribute name="http://apache.org/xml/features/validation/schema" value="true">
<attribute name="http://xml.org/sax/features/namespaces" value="true">
<property name="http://apache.org/xml/properties/schema/external-schemaLocation" value="http://www.w3.org/1999/XSL/Transform http://www.w3.org/2005/02/schema-for-xslt20.xsd">
<fileset dir="xsl-schemaLocation" includes="*.xsl">
</fileset>
</property></attribute></attribute></attribute></xmlvalidate>
Interesting resources I found will investigating all this: