You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Gregor <gr...@mrboogieman.com> on 2005/04/14 07:49:30 UTC

How to validate an XSD File (validating a (not against a) 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: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: How to validate an XSD File (validating a (not against a) Schema)

Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hi,

	Take a look at this blog entry

http://blog.parthenoncomputing.com/xerces/archives/2005/04/can_i_validate.html


Cheers,

Gareth

Gregor wrote:
> 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: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 
> 

-- 
Gareth Reakes, Managing Director      Parthenon Computing
+44-1865-811184 http://blog.parthenoncomputing.com/xerces

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


Re: How to validate an XSD File (validating a (not against a) Schema)

Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hey,

On 16 Apr 2005, at 4:48, Bob Foer wrote:

> Gareth Reakes wrote:
>>> I don't get this one. As a previous reply pointed out, Xerces will 
>>> validate a schema as it parses one, subject to the parameters you 
>>> specify. Full validation is one of the options. In my experience, 
>>> Xerces does a good job, even compared to the ever-in-flux XSV.
>> To a the degree required to extract the information (and then some). 
>> As I am sure you know, the schema spec is a complex beast and to test 
>> all that is says is a difficult job. Even SQC, which in my experience 
>> has shown up many problems in my schemas that xerces has not, has at 
>> least 10 different quality checking settings. On complex sets of 
>> schemas I have seen it taken hours and even days to complete!! Now, 
>> we are good, but even we can't take that down to seconds :)
>
> I find that response unsettling, but must bow to your experience. It 
> does seem to contradict Henry Thompson's recent assertion on xml-dev 
> that XML Schema had pretty much put conformance problems behind it. Is 
> this a spec to which it is impossible to conform in a performant way 
> (or entirely in any way)?
>

It is, in my opinion, fairly scary that it has taken 4 years (after 
recommendation) to get to a  state where the most widely used XML 
validation technology has "pretty much" put conformance issues behind 
it. I am not involved in standards work with my new company, but I 
certainly know that during the development of XBRL (a financial XML 
standard) last year there were some questions yet again.

I also don't think it does contradict what HT is saying. The fact that 
conformance problems may be behind us with regards to XML Schema does 
not make the specs any less complex, not the implementation any more 
performant. Xerces validates XML instances against XML schemas. It does 
that in a performant way. If we all put our mind to it, perhaps we 
could create a 100% schema checker. Maybe that even makes sense now we 
can cache grammars. But in the past, we needed to parse schemas as 
quickly as possible as it takes time and was part of the validation 
process. All I am saying is that you cannot be sure if you use xerces 
to validate your schema that you are 100% conformant. You should use a 
few tools.

Have a good weekend!

Gareth


--
Gareth Reakes, Managing Director      Parthenon Computing
+44-1865-811184                http://blog.parthcomp.com/xerces


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


Re: How to validate an XSD File (validating a (not against a) Schema)

Posted by Bob Foster <bo...@objfac.com>.
Gareth Reakes wrote:
>> I don't get this one. As a previous reply pointed out, Xerces will 
>> validate a schema as it parses one, subject to the parameters you 
>> specify. Full validation is one of the options. In my experience, 
>> Xerces does a good job, even compared to the ever-in-flux XSV.
> 
> To a the degree required to extract the information (and then some). As 
> I am sure you know, the schema spec is a complex beast and to test all 
> that is says is a difficult job. Even SQC, which in my experience has 
> shown up many problems in my schemas that xerces has not, has at least 
> 10 different quality checking settings. On complex sets of schemas I 
> have seen it taken hours and even days to complete!! Now, we are good, 
> but even we can't take that down to seconds :)

I find that response unsettling, but must bow to your experience. It 
does seem to contradict Henry Thompson's recent assertion on xml-dev 
that XML Schema had pretty much put conformance problems behind it. Is 
this a spec to which it is impossible to conform in a performant way (or 
entirely in any way)?

Bob Foster


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


Re: How to validate an XSD File (validating a (not against a) Schema)

Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hey,

On 15 Apr 2005, at 8:12, Bob Foster wrote:

> Gregor wrote:
>> 3. ) Will Schema validation be added to Xerces (the last question is
>> interesting for the "outlook"-part of my paper since I want to compare
>> Xerces with an OpenSource Tool developed by my company).
>
> I don't get this one. As a previous reply pointed out, Xerces will 
> validate a schema as it parses one, subject to the parameters you 
> specify. Full validation is one of the options. In my experience, 
> Xerces does a good job, even compared to the ever-in-flux XSV.

To a the degree required to extract the information (and then some). As 
I am sure you know, the schema spec is a complex beast and to test all 
that is says is a difficult job. Even SQC, which in my experience has 
shown up many problems in my schemas that xerces has not, has at least 
10 different quality checking settings. On complex sets of schemas I 
have seen it taken hours and even days to complete!! Now, we are good, 
but even we can't take that down to seconds :)


Cheers,

Gareth


> Bob Foster
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
--
Gareth Reakes, Managing Director      Parthenon Computing
+44-1865-811184                http://blog.parthcomp.com/xerces


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


Re: How to validate an XSD File (validating a (not against a) Schema)

Posted by Bob Foster <bo...@objfac.com>.
Gregor wrote:
> 3. ) Will Schema validation be added to Xerces (the last question is
> interesting for the "outlook"-part of my paper since I want to compare
> Xerces with an OpenSource Tool developed by my company).

I don't get this one. As a previous reply pointed out, Xerces will 
validate a schema as it parses one, subject to the parameters you 
specify. Full validation is one of the options. In my experience, Xerces 
does a good job, even compared to the ever-in-flux XSV.

Bob Foster


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


Re: How to validate an XSD File (validating a (not against a) Schema)

Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hey,

On 15 Apr 2005, at 5:38, Gregor wrote:

> Hi,
>
> thank you all for these interesting thoughts!
>

> Jeff had the idea of using the grammar preparsing mechanism to validate
> schemas. I like the idea from the point of view that I want to 
> benchmark
> Xerces validation performance in a B2B scenario.
> Therefore precaching is imho required anyway for increased performance 
> in
> message validation.
>

Caching will improve performance if repeated validation occurs. From 
the benchmarking perspective it can make sense, as long as you don't 
want the time taken to parse the schema included in the benchmark. As 
Jeff points out, preparsing them will check them to xerces standards.



> The benchmark however relies on the XML Schema test collection 
> available
> here (http://www.w3.org/2001/05/xmlschema-test-collection.html). In the
> past, xerces (2.0.0_beta4) was only tested in test cases that involved 
> a
> schema and an instance.

What kind of a benchmark do you want to create? If it is instance 
validation then you can cache all those schemas and and time how long 
it takes for xerces to validate the instances against them. If you want 
to benchmark how quickly xerces parses and extracts info for schema 
validation you can time the caching process itself.


>
> Please share with me your thoughts on:
> 1. ) Did anybody try to run the W3C schema-only test cases on Xerces 
> (using
> the precaching framework)?

Don't know. IBM have extensive schema tests that get run on xerces 
prior to release (or more). These may well be part of that.

> 2. ) Is the precaching framework suitable for running the above 
> benchmark?
>

See above comments.

> 3. ) Will Schema validation be added to Xerces (the last question is
> interesting for the "outlook"-part of my paper since I want to compare
> Xerces with an OpenSource Tool developed by my company).
>

I know of no plans to fully implement the constraints of the schema 
specs (that does not mean it is not happening :) ). If you think it 
would be useful functionality, over and above other things, then speak 
up. If enough people say then it might happen.


> Thank you Gareth, Jeff and Bob for your previous answers.
>
> Kind Regards,
>
> Gregor
>
> @Gareth: This is how I came up with the idea of using the Schema for 
> Schema
> with Xerces (it was silly, but I gave it a try :-)
> From XSV homepage (http://www.w3.org/2001/03/webdata/xsv)


Its a completely reasonable approach, but as much with the schema 
specs, it is not always totally clear to mere mortals like us :)

Regards,

Gareth

--
Gareth Reakes, Managing Director      Parthenon Computing
+44-1865-811184                http://blog.parthcomp.com/xerces


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


Re: How to validate an XSD File (validating a (not against a) Schema)

Posted by Gregor <gr...@mrboogieman.com>.
Hi,

thank you all for these interesting thoughts!

Gareth (now Chair of of Apache Xerces Project Management Committee) stated
that Xerces does not claim to validate Schemas and that I should hence try
another
tool.
(http://blog.parthenoncomputing.com/xerces/archives/2005/04/can_i_validate.html)

Jeff had the idea of using the grammar preparsing mechanism to validate
schemas. I like the idea from the point of view that I want to benchmark
Xerces validation performance in a B2B scenario.
Therefore precaching is imho required anyway for increased performance in
message validation.

The benchmark however relies on the XML Schema test collection available
here (http://www.w3.org/2001/05/xmlschema-test-collection.html). In the
past, xerces (2.0.0_beta4) was only tested in test cases that involved a
schema and an instance. 

Please share with me your thoughts on:
1. ) Did anybody try to run the W3C schema-only test cases on Xerces (using
the precaching framework)?
2. ) Is the precaching framework suitable for running the above benchmark?
3. ) Will Schema validation be added to Xerces (the last question is
interesting for the "outlook"-part of my paper since I want to compare
Xerces with an OpenSource Tool developed by my company).

Thank you Gareth, Jeff and Bob for your previous answers.

Kind Regards,

Gregor

@Gareth: This is how I came up with the idea of using the Schema for Schema
with Xerces (it was silly, but I gave it a try :-)
>From XSV homepage (http://www.w3.org/2001/03/webdata/xsv)

...This means that if the only input is a schema document, XSV normally just
validates that document against the Schema for Schema Documents
(XMLSchema.xsd), but does not also check the Schema REC's constraints on the
corresponding schema...




> Xerces will validate your schema if you cause it to be parsed with the 
> appropriate parser features set.  The necessary features are discussed 
> on the Features page of the documentation and the XML Schema FAQ.  You 
> can force the schema to be read
>   1.  by parsing an instance document whose root element is in the 
> namespace of your schema (and one of the typical means is specified for 
> the parser to find the schema for that namespace)  or
>   2.  by using the grammar preparsing mechanism (see the Caching and 
> Preparsing Grammars FAQ)
> 
> The validation features set in the parser determine which constratints 
> on the schema are checked.  You should almost certainly provide a custom 
> error handler to the parser to get good error reporting. 
> 
> You don't need to worry about the schema-for-schemas.  Xerces treats 
> that as a built-in. 
> 
> All the doc pages mentioned can be accessed from the root of the xerces 
> documentation tree.
> 
> Jeff
> 
> Bob Schloss wrote:
> 
> >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"                                                    
>  
> >             <gregor@mrboogiem                                           
>  
> >             an.com>                                                   
> To 
> >                                       xerces-j-user@xml.apache.org      
>  
> >             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: xerces-j-user-unsubscribe@xml.apache.org
> >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 

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


Re: How to validate an XSD File (validating a (not against a) Schema)

Posted by Jeff Greif <jg...@alumni.princeton.edu>.
Xerces will validate your schema if you cause it to be parsed with the 
appropriate parser features set.  The necessary features are discussed 
on the Features page of the documentation and the XML Schema FAQ.  You 
can force the schema to be read
  1.  by parsing an instance document whose root element is in the 
namespace of your schema (and one of the typical means is specified for 
the parser to find the schema for that namespace)  or
  2.  by using the grammar preparsing mechanism (see the Caching and 
Preparsing Grammars FAQ)

The validation features set in the parser determine which constratints 
on the schema are checked.  You should almost certainly provide a custom 
error handler to the parser to get good error reporting. 

You don't need to worry about the schema-for-schemas.  Xerces treats 
that as a built-in. 

All the doc pages mentioned can be accessed from the root of the xerces 
documentation tree.

Jeff

Bob Schloss wrote:

>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"                                                      
>             <gregor@mrboogiem                                             
>             an.com>                                                    To 
>                                       xerces-j-user@xml.apache.org        
>             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: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
>  
>


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


Re: How to validate an XSD File (validating a (not against a) Schema)

Posted by Bob Schloss <rs...@us.ibm.com>.
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"                                                      
             <gregor@mrboogiem                                             
             an.com>                                                    To 
                                       xerces-j-user@xml.apache.org        
             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: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org




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