Schematron / ant-schematron

Ant task for running Schematron
MIT License
3 stars 0 forks source link

Using XML Catalog with "doctyped" xml files #4

Open tgraham-antenna opened 4 years ago

tgraham-antenna commented 4 years ago

From Schematron/schematron#9 (also has attachments):

Hi, 

I ran "google.code.schematron\trunk\ant-schematron\test\ant\build.xml" with 
target "ant test-resolver-1"

Everything is fine from the original declared target : 
<!-- Resolver -->
<target name="test-resolver-1" description="Simple test">
    <taskdef name="schematron" classname="com.schematron.ant.SchematronTask" classpath="../lib/*.jar"/>
    <schematron schema="../schemas/test.sch" file="../xml/test1.xml" failonerror="false"
    debugmode="true"  resolver="org.apache.xml.resolver.tools.CatalogResolver"

    classpath="../lib/resolver.jar" 
    catalog="xxx.xml" 

    fileNameParameter="XXX"  fileDirParameter="ABC"/>
</target>

but this target defines an non existent catalog (xxx.xml).

SO I defined a catalog.xml file which contains : 
<public publicId="-//DOG//EN" 
uri="file:///C:/google.code.schematron/trunk/ant-schematron/test/ant/dog.dtd"/>

It points to dod.dtd with absolute uri (file is located at the same level as 
the build.xml file).

See attached files.

I then added the following doctype to test1.xml : 
<!DOCTYPE Dog PUBLIC "-//DOG//EN" "dog.dtd">

And when running "ant test-resolver-1"
I get the following error : 
test-resolver-1:
[schematron] Error
[schematron] java.io.FileNotFoundException:
[schematron] C:\google.code.schematron\trunk\ant-schematron\test\xml\dog.dtd 
[schematron] DEBUG: error
[schematron] Could not validate document 
C:\google.code.schematron\trunk\ant-sche
xml\test1.xml
[schematron] java.io.FileNotFoundException: 
C:\google.code.schematron\trunk\ant-s
st\xml\dog.dtd (Le fichier spécifié est introuvable)
BUILD FAILED

It seems dog.dtd file is being searched in "../xml" folder, which indicates the 
catalog resolver didn't work.

In oXygen, I added the catalog.xml files in catalog list, and I can 
successfully validate test1.xml. 
Note that I need to add catalog/@prefer="public" in catalog.xml so it works.

Configuration : 

* OS : windows 7 Pro

* JAVA : java version "1.6.0_20"

* ANT : Apache Ant(TM) version 1.8.2 compiled on December 20 2010
(I define ANT_HOME variable)

* SCHEMATRON : I get the whole test files from mercurial repo on 2011-08-30, 
the ant-schematron/test/lib folder contains : 
ant-schematron.jar
resolver.jar
saxon8.jar
saxon9.jar
saxon9.jar.old
saxon9he.jar

* SAXON : saxon9he.jar is in my CLASSPATH. If not I get an ANT error message. 
Version is : Saxon-HE 9.2.1.1J from Saxonica

I know saxon need a few options to be fixed so it work with a catalog : 

-r "Use URIResolver class" has to be set to 
"org.apache.xml.resolver.tools.CatalogResolver" which seems to be parameted by 
schematron/@resolver attribute

But also :
-x "Use specified SAX parser for source" has to be set to 
"file:org.apache.xml.resolver.tools.ResolvingXMLReader"

-y "Use specified SAX parser for stylesheet" also has to be set to 
"file:org.apache.xml.resolver.tools.ResolvingXMLReader"

But I don't see any attributes to set these parameters in the pdf doc  ("Using 
Schematron for Ant.pdf"). 
By the way, in this PDF, i think there is a mistake at parameter 
"xml.catalog.files" which should be "catalog" (attribute to schematron element)

Any help welcome !
(maybe I should post this on another place, but I can't find where ?)

Best Regards,
Matthieu

Original issue reported on code.google.com by rica...@gmail.com on 1 Sep 2011 at 9:53
tgraham-antenna commented 4 years ago

Attachments: