This task fails when more than one file is specified and the xsl/xml document doesn't contains the schemaLocation. example: <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-no-schemaLocation" includes="*.xsl"/> </xmlvalidate> You can find the <property> documentation here: http://xerces.apache.org/xerces-j/properties.html Has said in this doc: "The XML Schema Recommendation explicitly states that the inclusion of schemaLocation/ noNamespaceSchemaLocation attributes is only a hint(...)" The W3C doc about this: http://www.w3.org/TR/xmlschema-1/#xsi_schemaLocation "2.6.3 xsi:schemaLocation, xsi:noNamespaceSchemaLocation The xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes can be used in a document to provide hints as to the physical location of schema documents which may be used for ·assessment·. See How schema definitions are located on the Web (§4.3.2) for details on the use of these attributes." In my case, I have a lot of xsl with no schemaLocation specified. I can't add the schemaLocation to all those files, so I need to specify the xsd location from "outside" (aka in the ant file). I'll provide a showcase as an attachement of this bug.
Created attachment 17312 [details] build file and sample files
After further investigations, I found a patch but I not sure it's a xerces bug or functionnality ?! Somehow the properties set on the XMLReader are lost after the first parse on the first file of fileset?! According to the javadoc: http://xerces.apache.org/xerces-j/apiDocs/org/xml/sax/XMLReader.html#setProperty(java.lang.String,%20java.lang.Object) "Some property values may be immutable or mutable only in specific contexts, such as before, during, or after a parse." This could mean anything and it's contrary ! My solution is to set the properties every time we try do parse(). Since it's just setting values in a hashmap it's not time consuming. see attached svn-patch.
Created attachment 17313 [details] set parser properties just before parse method
This should already be fixed in the SVN_HEAD version of Ant. please grab a copy and see if the problem is fixed. There are gump tests that do bulk <schemavalidate>, so I strongly believe it is fixed. I think we actually do it less efficiently, by creating a new parser instance each time, so it may give a performance boost to code
yes it does work with the SVN trunk :) Thanks. The performance issue is not a problem for me right now. Feel free to close this bug or change it's status ;)
http://svn.apache.org/viewcvs.cgi?rev=278246&view=rev