Be aware that not all the constraints which XML Schemas must follow can be
syntactically checked only using the Schema for XML Schema.

You may want to process your schema with some very complete Schema checking
tool.  See, for example, the XML Schema Quality Checker located on IBM
alphaWorks [1] or XSV [2].

Bob

[1] http://www.alphaworks.ibm.com/tech/xmlsqc
[2] http://www.w3.org/2001/03/webdata/xsv




                                                                           
             "Gregor"                                                      
             <[EMAIL PROTECTED]                                             
             an.com>                                                    To 
                                       [EMAIL PROTECTED]        
             04/14/2005 01:49                                           cc 
             AM                                                            
                                                                   Subject 
                                       How to validate an XSD File         
             Please respond to         (validating a (not against a)       
               xerces-j-user           Schema)                             
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Hello,

I am trying to validate Schema files using Xerces.

The problem is, that I only got one XML Schema file e.g. attA001.xsd (some
will now, this is the W3Cs Schema-test-collection
http://www.w3.org/2001/05/xmlschema-test-collection.html) and want to tell
whether it is a valid XML Schema according to XML Schema recommendation or
an invalid one.

I tried the following approaches:

1.) Download the Schema-for-Schemas from the W3Cs Website
("http://www.w3.org/2001/XMLSchema.xsd";) and validating attA001.xsd against
this file as if attA001.xsd was an instance (which technically in my
understanding it is) of XMLSchema.xsd
(Please see code snippet below)
(Before doing that I validated the XMLSchema.xsd against its own internal
dtd which worked just fine)

2.) Validate an empty file specifing attA001.xsd as Schema file for it
(hope
it would appart from empty file err also point to errors in the schema
(..schema-full-checking", true); but it did not.

I ran out of ideas at some point yesterday night.

I am very thankfull for any suggestions.

Kind Regards,

Gregor

1.) Code Snippet
This is the setup: (try/catch omitted for legibility)

SAXParserFactory factory = SAXParserFactory.newInstance();

SAXParser parser = factory.newSAXParser();

XMLReader reader = parser.getXMLReader();

reader.setFeature("http://xml.org/sax/features/namespaces";, true);
             reader.setFeature("
http://xml.org/sax/features/namespace-prefixes";,
true);

reader.setFeature("http://xml.org/sax/features/validation";, true);

reader.setFeature("http://apache.org/xml/features/validation/schema";,
true);

reader.setFeature("
http://apache.org/xml/features/validation/schema-full-checking";,
true);

Validator handler=new Validator();
reader.setErrorHandler(handler);

parser.setProperty
("http://java.sun.com/xml/jaxp/properties/schemaLanguage";,
    "http://www.w3.org/2001/XMLSchema";);

parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource";,
                                     "C:/test/XMLSchema.xsd");

parser.parse(SchemaUri, handler);
//SchemaUri = "C:/test/attA001.xsd"

This is the errorMsg:

 s4s-elt-invalid-content.1: The content of '#AnonType_documentation' is
invalid.  Element 'attribute' is invalid, misplaced, or occurs too often.

Line Number:1277

I can not find the specified element and I get the same error for many xsds
I am trying to validate (even the ones supposed to be valid according to
W3Cs XML Schema test collection)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to