Replying to myself...
It is a bug. When the JAXP option is used and validation is selected, the current implementation defaults to DTD validation, not XML Schema!
The error is at line 297 of org.exolab.castor.util.LocalConfiguration.java:
try {
SAXParser saxParser = factory.newSAXParser();
return saxParser.getParser();
}Should be replaced with:
try {
parser = factory.newSAXParser().getParser();
XMLReader xmlReader = (XMLReader) parser;
xmlReader.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
return parser;
}
Also, at line 405 the line:
reader.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
should be added to the try block.
Do you agree?
Do I need to post the bug on bugzilla (I can only do it tomorrow to to mail server problems - can't get my password) or is this report enough?
Jo�o Luis
From: "Joao Luis Pinto" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [castor-dev] Validation problem - Castor or Xerces bug? Date: Tue, 03 Feb 2004 19:14:19 +0000
Dear all
I'm using the SourceGenerator from version 0.9.5.2 on the following schema:
<?xml version="1.0" encoding="utf-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://power.inescn.pt/2004/01/compete#" xmlns:compete="http://power.inescn.pt/2004/01/compete#" elementFormDefault="qualified">
<element name="PowerSystem"> <complexType> <sequence> <element minOccurs="0" maxOccurs="unbounded" ref="compete:Node"/> <element minOccurs="0" maxOccurs="unbounded" ref="compete:Line"/> </sequence> <attribute name="name" type="string"/> </complexType> <key name="nodeName"> <selector xpath="compete:Node"/> <field xpath="@ID"/> </key> <keyref name="fromNodeNameRef" refer="compete:nodeName"> <selector xpath="compete:Line"/> <field xpath="compete:from"/> </keyref> <keyref name="toNodeNameRef" refer="compete:nodeName"> <selector xpath="compete:Line"/> <field xpath="compete:to"/> </keyref> </element>
<element name="Node" type="compete:NodeType"/> <complexType name="NodeType"> <sequence/> <attribute name="ID" type="integer"/> <attribute name="voltage" type="double"/> </complexType>
<element name="Line" type="compete:LineType"/> <complexType name="LineType"> <sequence> <element name="from" type="integer"/> <element name="to" type="integer"/> </sequence> <attribute name="ID" type="integer"/> </complexType> </schema>
I've set:
org.exolab.castor.parser.validation=true org.exolab.castor.parser.namespaces=true org.exolab.castor.marshalling.validation=true
to require validation and set to empty org.exolab.castor.parser and commented out org.exolab.castor.serializer on the castor.properties file to force using the default JAXP implementation.
I've updated using the "endorsed" mechanism the Xalan on j2se1.4.2 to 2.5.2 and Xerces to 2.6.1 .
I'm getting this stack trace:
org.xml.sax.SAXException: In document: 'file:///home/jpinto/src/eclipse/Test/powersystem.xsd'
Parsing Error : Document is invalid: no grammar found.
Line : 2
Column : 8
at org.exolab.castor.xml.schema.reader.Sax2ComponentReader.error(Sax2ComponentReader.java:281)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:372)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:425)
at org.exolab.castor.builder.SourceGenerator.main(SourceGenerator.java:760)
If I processe an XML instance of the document that uses this schema using JAXP and DOM, with validation, I have no problem.
Anybody has an idea?
Do you believe it is a Xerces issue and should report it to them, or that it is an issue on the way castor sets the parser validation flags?
Thank you in advance,
Jo�o Luis
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
