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 Oleg <ol...@configurecode.com> on 2004/04/26 16:52:25 UTC

Schema validation problems

Ok, here are is what I am doing:

protected static final String FEATURE_NAMESPACES = 
"http://xml.org/sax/features/namespaces";
	protected static final String FEATURE_VALIDATION = 
"http://xml.org/sax/features/validation";
	protected static final String FEATURE_SCHEMA = 
"http://apache.org/xml/features/validation/schema";
	protected static final String FEATURE_DYNAMIC = 
"http://apache.org/xml/features/validation/dynamic";
	protected static final String FEATURE_SCHEMA_FULL_CHECKING = 
"http://apache.org/xml/features/validation/schema-full-checking";
	protected static final String FEATURE_DEFER_NODE_EXPANSION = 
"http://apache.org/xml/features/dom/defer-node-expansion";
	protected static final String FEATURE_NAMESPACE_PREFIXES = 
"http://xml.org/sax/features/namespace-prefixes";
	protected static final String PROPERTY_LEXICAL_HANDLER = 
"http://xml.org/sax/properties/lexical-handler";
	protected static final String PROPERTY_SCHEMA_LOCATION = 
"http://apache.org/xml/properties/schema/external-schemaLocation";
	protected static final String PROPERTY_NO_NAMESPACE_SCHEMA_LOCATION = 
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";
	protected static final String PROPERTY_CURRENT_ELEMENT_NODE = 
"http://apache.org/xml/properties/dom/current-element-node";

......

parser.setFeature(FEATURE_NAMESPACES, true);
parser.setFeature(FEATURE_VALIDATION, true);
parser.setFeature(FEATURE_SCHEMA, true);
parser.setFeature(FEATURE_SCHEMA_FULL_CHECKING, true);
parser.setFeature(FEATURE_DYNAMIC, false);
parser.setFeature(FEATURE_DEFER_NODE_EXPANSION, false);
.....
parser.setProperty(PROPERTY_SCHEMA_LOCATION,namespace+" "+ 
schemaLocation.toString());

namespace in this case is http://ns.hr-xml.org and schema is 
file://c:/apps/eclipse/{snip......}/samples/TimeCard.xsd

parser is DOMParser.

The sample xml file is otherwise well formed and valid as far as XMLSpy 
is concerned (see attached sample):

I get this exception:

org.xml.sax.SAXParseException: cvc-complex-type.2.4.at hr:TimeCard 
{"http://ns.hr-xml.org":Id, "http://ns.hr-xml.org":ReportedResource}


Re: Schema validation problems

Posted by Robert van Loenhout <r....@greenvalley.nl>.
Oleg wrote:
> > Ok, here are is what I am doing:
> > I get this exception:
> >
> > org.xml.sax.SAXParseException: cvc-complex-type.2.4.at hr:TimeCard
> > {"http://ns.hr-xml.org":Id, "http://ns.hr-xml.org":ReportedResource}
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <hr:TimeCard xmlns:hr="http://ns.hr-xml.org"
xmlns="http://ns.hr-xml.org">
> > <hr:ReportedResource>
> > <hr:Person>
> > <hr:Id>
> > <hr:IdValue>d026194</hr:IdValue>
> > </hr:Id>
> > <hr:PersonName>
> > <hr:FormattedName>Heidi Schmidt</hr:FormattedName>
> > </hr:PersonName>
> > </hr:Person>

Hmm shouldn't the hr:Person be after the hr:ReportedTime?
At least that's what I see in a TimeCard schema.



                                                                              
                                                                              
                                                                               
                                                                            

                
                                                                 

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