Project

Profile

Help

Support #2192

closed

Cannot get DTD validation to work with com.saxonica.Validate and CatalogResolver

Added by Jason Mihalick over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2014-10-20
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

Hi,

Hopefully I am just overlooking something simple, but I have not been able to get Saxon to validate an instance XML against a DTD. I have broken down the problem into a simple example. We are using the Apache Catalog Resolver, which is working perfectly fine with Saxon transforms and schema-based validation of instance XMLs, but I cannot get it to work with a DTD.

In my attached test case the files are as follows:

doSaxonValidate: shell script to run a validation using com.saxonica.Validate

CatalogManager.properties: Apache Catalog Manager Properties file for specifying catalog location

catalog.xml: my bare bones catalog to locate the dtd

instance.xml: my simple example instance XML file

xml-resolver.jar: Apache XML resolver jar (version 1.2)

dtd/simple.dtd: my simple dtd used to validate the instance XML

To run the test:

  1. Expand the attached tar.gz into a directory

  2. Edit the doSaxonValidate script. Modify the SAXON_JAR variable to contain the location to your Saxon-EE jar and license. We put our Saxon license in a jar file, and add the jar to the classpath, your situation may vary.

  3. Run: ./doSaxonValidate instance.xml -t

This is the output that I get:

[pubsdm1:@pubsjsdev1:/home/pubsdm1/jrm29/saxonValidate
$ doSaxonValidate instance.xml  -t
Parse catalog: file:/home/pubsdm1/jrm29/saxonValidate/catalog.xml
Loading catalog: file:/home/pubsdm1/jrm29/saxonValidate/catalog.xml
Default BASE: file:/home/pubsdm1/jrm29/saxonValidate/catalog.xml
override: yes
OVERRIDE: yes
public: -//MYORG//DTD SIMPLE DTD//EN
        dtd/simple.dtd
PUBLIC: -//MYORG//DTD SIMPLE DTD//EN
        file:/home/pubsdm1/jrm29/saxonValidate/dtd/simple.dtd
Saxon-EE 9.5.1.7J from Saxonica
Java version 1.6.0_27-rev
Using license serial number V002327
Schema checking successful. Time: 20 milliseconds
Using parser org.apache.xml.resolver.tools.ResolvingXMLReader
Processing file:/home/pubsdm1/jrm29/saxonValidate/instance.xml
resolveSystem(file:/home/pubsdm1/jrm29/saxonValidate/simple.dtd)
resolvePublic(-//MYORG//DTD SIMPLE DTD//EN,file:/home/pubsdm1/jrm29/saxonValidate/simple.dtd)
Resolved public: -//MYORG//DTD SIMPLE DTD//EN
        file:/home/pubsdm1/jrm29/saxonValidate/dtd/simple.dtd
Validation error on line 3 column 10 of instance.xml:
  XSD99999: Cannot validate <myroot>: no element declaration available
  See http://www.w3.org/TR/xmlschema11-1/#cvc-elt clause 1
  Validating /myroot[1]
Validation error on line 3 column 10 of instance.xml:
  XSD99999: One or more validation errors were reported
Validation unsuccessful

Note that the Catalog resolver successfully resolved the simple.dtd file, but Saxon cannot locate it.

I tried this same validation using oXygen and Saxon-EE by configuring oXygen to use my example catalog.xml and it worked fine.

I will be happy to assist in any troubleshooting and answer any questions you have. Thank you.


Files

saxonValidate.tar.gz (79.5 KB) saxonValidate.tar.gz Jason Mihalick, 2014-10-21 00:43
Actions #1

Updated by Michael Kay over 9 years ago

The error message from com.saxonica.Validate is because it cannot find a schema (that is, XSD) to validate the document against. There doesn't seem to be any problem with the DTD. The command com.saxonica.Validate is used for schema (XSD) validation, and if you don't have a schema, you shouldn't be using it. To do DTD validation, you don't need Saxon at all, you only need an XML parser, but if you want to do it via Saxon, the simplest way is just to run a query such as

java net.sf.saxon.Query -s:source.xml -qs:name(*) -dtdvalidation:on

plus options to invoke catalog resolution if needed.

Actions #2

Updated by Jason Mihalick over 9 years ago

Thanks, that works. The only change I had to make was instead of using -dtdvalidation:on@, use @-dtd:on instead

Actions #3

Updated by O'Neil Delpratt over 9 years ago

  • Status changed from New to Closed

Please register to edit this issue

Also available in: Atom PDF