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 Em...@tcc.thomson-csf.com on 2000/12/01 09:33:32 UTC

RE: Schema validation with Xerces-J 1.2.1

Hi,

To complete my question I give my code in Xerces-J for xml validation.
What's wrong or missing in it ?

Thanks for your help.

	Emmanuel.

-----Message d'origine-----
De: Emmanuel.COLLAIN@tcc.thomson-csf.com
[mailto:Emmanuel.COLLAIN@tcc.thomson-csf.com]
Date: mercredi 29 novembre 2000 12:51
À: xerces-j-dev@xml.apache.org
Objet: Schema validation with Xerces-J 1.2.1


Hi all,
I use Xerces-J 1.2.1. I want to validate a document instance with a
XML-schema, but it doesn't wotks. (The DTD validation works.)

For example, with the document :
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE Foo SYSTEM "Foo.dtd">
<Foo>
   <Bar>some text</Bar>
   <Foobar/>
   <Bar>some text again</Bar>
</Foo>

and his DTD :

<?xml version="1.0" encoding="ISO-8859-1"?>
<!ELEMENT Foo (Bar*)>
<!ELEMENT Bar (#PCDATA)>

an error is detected because the element "Foobar" is unknown. And, with the
document instance :

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<Foo xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Foo.xsd">
   <Bar>some text</Bar>
   <Foobar/>
   <Bar>some text again</Bar>
</Foo>

and his schema :

<?xml version="1.0" encoding="ISO-8859-1">
<schema>
   <element name="Foo">
      <complexType content="elementOnly">
	<element ref="Bar" minOccurs="0" maxOccurs="unbounded"/>
      </complexType>
   </element>
  <element name="Bar" type="string"/>
</schema>

no error detected !!!

In the both cases I set the following features :
	    parser.setFeature("http://xml.org/sax/features/validation",
true);
	
parser.setFeature("http://apache.org/xml/features/validation/dynamic",
true);
	
parser.setFeature("http://apache.org/xml/features/validation/schema", true);
and I use a DOM parser.

May I miss something ? Do I something wrong ?
Thanks for your help.


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