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 bu...@apache.org on 2003/02/13 00:46:08 UTC

DO NOT REPLY [Bug 17029] New: - Xerces 2 does not support JAXP 1.2 validation properties

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17029>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17029

Xerces 2 does not support JAXP 1.2 validation properties

           Summary: Xerces 2 does not support JAXP 1.2 validation properties
           Product: Xerces2-J
           Version: 2.3.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: JAXP
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: Joseph.Sinclair@Motorola.Com


The JAXP specification 1.2 specifies(in part) the following mechanism to 
request schema validation:
--------------------------------------
	The setProperty method in SAXParser must support the property strings 
defined below to indicate the schema language and the source of the schema file
(s) to the parser:
	http://java.sun.com/xml/jaxp/properties/schemaLanguage
	This property defines the schema language to be used for validation. 
The value of this property must be the URI of the schema language 
specification. To be compliant with this version of the specification, the 
implementation must support the W3C XML schema specification at this URI: 
http://www.w3.org/2001/XMLSchema.
	http://java.sun.com/xml/jaxp/properties/schemaSource
	The XML Schema Recommendation explicitly states that the inclusion of 
schemaLocation / noNamespaceSchemaLocation attributes in an instance document 
is only a hint; it does not mandate that these attributes must be used to 
locate schemas.

	The schemaSource property lets the user set the schema(s) to validate 
against. If the target namespace of a schema specified using this property 
matches the target namespace of a schema occuring in schemaLocation attribute, 
the schema specified by the user using this property will be used and the 
instance document�s schemaLocation attribute will be effectively ignored. 
However if the target namespace of any schema specified using this property 
doesn�t match the target namespace of a schema occuring in the instance 
document, then the hint specified in the instance document will be used for 
validation. The acceptable value for this property must be one of the following:
		�String that points to the URI of the schema
		�InputStream with the contents of the schema
		�SAX InputSource
		�File
		�an array of Objects with the contents being one of the types 
defined above.
	An array of Objects can be used only when the schema language has the 
ability to assemble a schema at runtime. When an array of Objects is passed it 
is illegal to have two schemas that share the same namespace.
	If no target namespace is defined, then only one schema can be 
referenced by the property and it must work exactly the way 
xsi:noNamespaceSchemaLocation does.

	When setValidating is set to true and a schema language is set, then 
the parser must validate against that schema language only. For example if an 
application sets the schemaLanguage property to XML Schemas then the parser 
must try to validate against the XML schema only, even if the document has a 
DOCTYPE declaration that refers to a DTD.
[.....]
	The same property strings as described above for the SAXParser must be 
supported by
	DocumentBuilderFactory.setAttribute method.
	When setValidating is set to true and a schema language is set then the 
parser must validate against that schema language only. For example if an 
application sets the schema language property to XML Schemas the parser must 
try to validate against the XML schema only, even if the document has a DOCTYPE 
declaration that refers to a DTD.
--------------------------------------
When the following code fragment, an analog to the example in the 
specification, is called, the indicated error is thrown:
------
      xmlFactory = DocumentBuilderFactory.newInstance();
      xmlFactory.setExpandEntityReferences(true);
      xmlFactory.setNamespaceAware(true);
      xmlFactory.setValidating(true);
      xmlFactory.setAttribute
("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                              "http://www.w3.org/2001/XMLSchema");
      xmlFactory.setIgnoringElementContentWhitespace(true);

      DocumentBuilder xmlBuilder = xmlFactory.newDocumentBuilder();
      xmlDocument = xmlBuilder.parse(xmlStream);
------
Error: URI=null Line=2: Document is invalid: no grammar found.
Error: URI=null Line=2: Document root element "XXXXX", must match DOCTYPE 
root "null".

Apparently, setting the schema validation per the JAXP specification does not 
properly activate schema validation in the Xerces parser, and the parser 
continues to attempt DTD validation.  I am aware that there is a Xerces-
specific attribute to enable schema, but our projects have a requirement to 
avoid product-specific calls when a standard API is available, and hence are 
limited to staying with Xerces 1.4.4 (which handles schema validation without 
product-specific attributes) until this issue is resolved in Xerces 2.

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