You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by ji...@apache.org on 2004/04/12 23:23:50 UTC

[jira] Updated: (XERCERJ-354) documentation for how to use Xerces for schema validation, better error messages for schema validation

The following issue has been updated:

    Updater: Serge Knystautas (mailto:sergek@lokitech.com)
       Date: Mon, 12 Apr 2004 2:22 PM
    Changes:
             Attachment changed from DB_Insert_abstract.xsd
    ---------------------------------------------------------------------
For a full history of the issue, see:

  http://issues.apache.org/jira/browse/XERCERJ-354?page=history

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/XERCERJ-354

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XERCERJ-354
    Summary: documentation for how to use Xerces for schema validation, better error messages for schema validation
       Type: Bug

     Status: Resolved
 Resolution: CANNOT REPRODUCE

    Project: Xerces2-J

   Assignee: Xerces-J Developers Mailing List
   Reporter: Naomi Dushay

    Created: Wed, 19 Jun 2002 6:13 PM
    Updated: Mon, 12 Apr 2004 2:22 PM
Environment: Operating System: Windows NT/2K
Platform: All

Description:
I have a suite of schemas and I wanted to test if 

a) the schemas were valid
b) instance documents validated to these schemas

with Xerces 2.0.1.

I couldn't find documentation on how to do either a or b.

For b., a colleague advised me to use the sample program sax.Counter.

I thought it would be a simple matter to run sax.Counter from the command line 
to accomplish this.  I set my path to include (in this order):

Xerces-2_0_1\xercesImpl.jar
Xerces-2_0_1\xmlParserAPIs.jar
j2sdk1.4.0\bin

I set my classpath to include:

Xerces-2_0_1\xercesSamples.jar

I used the command:

java sax.Counter -v -s -f (instance doc fname)


I got this output:

"error: Unable to instantiate parser (org.apache.xerces.parsers.SAXParser)"

This made no sense to me, as I could see that I had included the correct files 
in my path.

However, being familiar both with java and XML, I figured it may have been a 
problem with my classpath.

As a shot in the dark, I tried to run sax.Counter within JBuilder.  I was able 
to set up a code library for Xerces-2_0_1\XercesImpl.jar  I discovered that I 
needed a separate code library for Xerces-2_0_1\xmlParserAPIs.jar, and that if 
I included both of these and told JBuilder to use JDK 1.4 as the VM, I got 
error messages :


[Error] oai-identifier.xsd:22:71: e-props-correct.2: Invalid value constraint 
value 'oai' in element 'scheme'.

[Error] oai-identifier.xsd:25:72: e-props-correct.2: Invalid value constraint 
value ':' in element 'delimiter'.

[Warning] testDBInsertColl.xml:24:16: schema_reference.4: Failed to read schema 
document 'null', because 1) could not find the document; 2) the document could 
not be read; 3) the root element of the document is not <xsd:schema>.

[Warning] testDBInsertColl.xml:39:46: schema_reference.4: Failed to read schema 
document 'null', because 1) could not find the document; 2) the document could 
not be read; 3) the root element of the document is not <xsd:schema>.

[Warning] testDBInsertColl.xml:58:16: schema_reference.4: Failed to read schema 
document 'null', because 1) could not find the document; 2) the document could 
not be read; 3) the root element of the document is not <xsd:schema>.

E:\NSDL\schemas\testDBInsertColl.xml: 2062 ms (70 elems, 18 attrs, 0 spaces, 
3414 chars)


Okay, so now I'm plausibly doing some sort of schema validation, because it's 
giving me errors on the oai-identifier.xsd schema.   


Problems:

1.  My instance document validates fine with my schema suite in XSV and in 
topologi.  (XMLSpy has a bug, duly reported).  But Xerces is reporting a 
problem.  Who is correct?

2.  These messages don't tell me very much at all.  Which schemas loaded?  
Which schemas is it seeking?   How can I better tell what's going on so I can 
debug my schemas and instance doc?

3.  Why didn't I get this far from the command line?

Oh, I can answer this one.  By some stroke of luck, I had a lead to look at the 
JAXP FAQ at http://java.sun.com/xml/jaxp/faq.html.  And there's a question in 
that FAQ "How do I override the JAXP implementation in the JDK 1.4 and above?" 
which tells me I need to use the "-D" option with the java command.  So if I 
leave my path and classpath as indicated above, I can use the following command:

java -Djava.endorsed.dirs=(Xerces-2_0_1_DIR) sax.Counter -v -s -f %1

to do schema validation on an instance document.


This seems like a very convoluted, obscure indication of how to use Xerces for 
schema validation from the command line.


Have I missed the appropriate documentation?

- how to check if schemas are valid
- how to check instance documents against schemas
- how to get good error reporting on schema validation.

I would happily send my instance docs and schemas if they would be helpful to 
you.

- Naomi Dushay


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org