Bug 38106 - xmlvalidate fails when apply to multiple fileset and xml/xsl document with no schemaLocation specified
Summary: xmlvalidate fails when apply to multiple fileset and xml/xsl document with no...
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: 1.6.5
Hardware: All other
: P1 critical (vote)
Target Milestone: 1.7.0
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-03 12:01 UTC by Benjamin Francisoud
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments
build file and sample files (2.24 KB, application/zip)
2006-01-03 12:02 UTC, Benjamin Francisoud
Details
set parser properties just before parse method (1.67 KB, patch)
2006-01-03 15:22 UTC, Benjamin Francisoud
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Francisoud 2006-01-03 12:01:29 UTC
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.
Comment 1 Benjamin Francisoud 2006-01-03 12:02:56 UTC
Created attachment 17312 [details]
build file and sample files
Comment 2 Benjamin Francisoud 2006-01-03 15:21:38 UTC
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.
Comment 3 Benjamin Francisoud 2006-01-03 15:22:32 UTC
Created attachment 17313 [details]
set parser properties just before parse method
Comment 4 Steve Loughran 2006-01-03 22:27:51 UTC
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
Comment 5 Benjamin Francisoud 2006-01-04 16:55:42 UTC
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 ;)
Comment 6 Stefan Bodewig 2006-01-28 15:32:43 UTC
http://svn.apache.org/viewcvs.cgi?rev=278246&view=rev