Joey,
It's because element 'cwe' belongs in the "" namespace according to the
schema. By default, the schema's elementFormDefault attribute is false.
This determines the qualification of local variables. In your case, element
'cwe' is local (i.e., not direct child element of the 'schema' element) and
therefore should not be qualified. However, in your instance doc, it has
the namespace xmlns="http://www.foo.com/ClinicalElement".
So the parser is correctly flagging that your instance doc does validate
against the schema.
For more info, search for "elementFormDefault" in the XML Schema Specs:
http://www.w3.org/TR/xmlschema-0/
- Jeehong
----- Original Message -----
From: "Joey Coyle" <joey@xxxxxxxxxx>
To: <xerces-j-user@xxxxxxxxxxxxxx>
Sent: Friday, April 09, 2004 2:20 PM
Subject: Why is Content Invalid????
> I just can't figure out what the problem is here, but I assume it is
> some namespace problem.
>
> Here is the Error, and below is the Instance Document with the Schema,
> and finally the Method where I validate.
>
> [Error] Instance.xml:3:10: cvc-complex-type.2.4.a: Invalid content was
> found starting with element 'cwe'. One of '{"":cwe}' is expected.
>
>
> $$$$$$$$$$$$$$$$$$$$$$$$$$
>
> INSTANCE DOCUMENT
>
> <?xml version="1.0" encoding="UTF-8"?>
> <TransportWrapper xmlns="http://www.foo.com/ClinicalElement"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <cwe>hello</cwe>
> </TransportWrapper>
>
>
> $$$$$$$$$$$$$$$$$$
>
> SCHEMA
>
> <xs:schema targetNamespace="http://www.ihc.com/ClinicalElement"
> xmlns="http://www.foo.com/ClinicalElement"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <xs:element name="TransportWrapper" type="ClinicalElement"/>
>
> <xs:complexType name="ClinicalElement">
> <xs:sequence>
> <xs:element name="cwe" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
>
> </xs:schema>
>
> $$$$$$$$$$$$$$$$$$$$
>
> CODE
>
> public Document parse(String fileName)
> {
> DOMParser parser = new DOMParser();
> Document doc = null;
>
> setFeature(parser, "http://xml.org/sax/features/validation",
> true);
> setFeature(parser,
> "http://apache.org/xml/features/validation/schema", true);
> setFeature(parser,
> "http://apache.org/xml/features/validation/schema-full-checking",
> true);
>
> try
> {
> parser.setProperty(
>
> "http://apache.org/xml/properties/schema/external-schemaLocation",
> "http://www.foo.com/ClinicalElement
> ClinicalElement.xsd");
> }
> catch (SAXNotRecognizedException e)
> {
> System.out.print("Unrecognized property: ");
>
> System.out.println("http://apache.org/xml/properties/schema/external-
> schemaLocation");
> }
> catch (SAXNotSupportedException e)
> {
> System.out.print("Unrecognized property: ");
>
> System.out.println("http://apache.org/xml/properties/schema/external-
> schemaLocation");
> }
>
>
>
> try
> {
> parser.parse(fileName);
> doc = parser.getDocument();
>
> }
> catch (IOException ie)
> {
> System.out.println("Could not read file.");
> }
> catch (SAXException e)
> {
> System.out.print("Could not create Document: ");
> System.out.println(e.getMessage());
> }
>
> return doc;
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xxxxxxxxxxxxxx
> For additional commands, e-mail: xerces-j-user-help@xxxxxxxxxxxxxx
>
>
|