[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

trying to do XML Schema validation with Xerces-J 2.4.0, does not complai

  • To: xml-dev@l...
  • Subject: trying to do XML Schema validation with Xerces-J 2.4.0, does not complain about unique constraits when using the xs:key feature
  • From: Bill Riegel <BRiegel@l...>
  • Date: Wed, 14 May 2003 08:59:17 -0500

xerces validation schema
I can get it to complain about structural error's. i.e. have a child element
in the instance document but not defined in the XML Schema. 

But when I try to create in in-valid key constraint, i.e.
DataSet/WellEntireData/WellEntire/wellid is not unique, it does not throw an
exception. ( Note: xmlspy does ) 

Instance document:

<?xml version="1.0"?>

<DataSet xmlns=http://www.lgc.com/schema/OpenWorksData/2003
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
   xsi:schemaLocation="http://www.lgc.com/schema/OpenWorksData/2003
            Adt_OW_Stratigraphy2_Schema.xsd">
  <WellEntireData>
    <WellEntire>
      <wellid>3567</wellid>
    </WellEntire>
    <WellEntire>
      <wellid>3197</wellid>
    </WellEntire>
    <WellEntire>
      <wellid>3198</wellid>
     </WellEntire>
    <WellEntire>
      <wellid>3567</wellid>
    </WellEntire>
 </WellEntireData>
</DataSet>


XML Schema file.
 
<?xml version="1.0"?>
<xs:schema targetNamespace="http://www.lgc.com/schema/OpenWorksData/2003"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.lgc.com/schema/OpenWorksData/2003"
elementFormDefault="qualified" attributeFormDefault="unqualified">
  <!--This XML Schema defines an ADT XML File. It Defines the DataModel
OpenWorksData and partitionName Stratigraphy2-->
  <xs:element name="DataSet">
    <xs:complexType>
      <xs:all>
        <xs:element name="WellEntireData" type="WellEntireData_Type"
minOccurs="0">
          <xs:key name="WellEntire_InHierarchy_Key_Definition">
            <xs:selector xpath="WellEntire"/>
            <xs:field xpath="wellid"/>
          </xs:key>
        </xs:element>
      </xs:all>
    </xs:complexType>
  </xs:element>
   <xs:complexType name="WellEntireData_Type">
    <xs:sequence>
      <xs:group ref="WellEntire_Top_Group" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:group name="WellEntire_Top_Group">
    <xs:choice>
      <xs:element name="WellEntire" type="WellEntire_Type"/>
    </xs:choice>
  </xs:group>
  <xs:complexType name="WellEntire_Type">
    <xs:sequence>
      <xs:group ref="WellEntire_Atrributes_Group"/>
    </xs:sequence>
  </xs:complexType>
  <xs:group name="WellEntire_Atrributes_Group">
    <xs:sequence>
      <xs:element name="wellid" type="xs:integer"/>
     </xs:sequence>
  </xs:group>
  <xs:complexType name="WellEntireRef_Type">
    <xs:sequence>
      <xs:element name="wellid" type="xs:integer"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

I have set the following features:

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

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

Am I setting the features incorrectly ?
Does the 2.4.0 version of Xerces support this feature of XML Schema ?



Bill Riegel
LandMark Graphics
713-839-3388



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.