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 Hycel Taylor <ht...@upromise.com> on 2000/10/26 18:35:23 UTC

Element type must be declared error

Hello,

Below, I have a fairly simple schema file for describing student addresses:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/1999/XMLSchema"
targetNamespace="http://www.testco.com/testco"
xmlns:TEST="http://www.testco.com/testco">
	<annotation>
		<documentation/>
	</annotation>
	<!-- Includes -->
	<include schemaLocation="../../xml/Utilities/Dummy.xsd"/>
	<include schemaLocation="../../xml/Utilities/Address.xsd"/>
	<include schemaLocation="../../xml/Utilities/SSN.xsd"/>
	<include schemaLocation="../../xml/Utilities/RecordType.xsd"/>
	<include schemaLocation="../../xml/Utilities/USPhoneNumber.xsd"/>
	<include schemaLocation="../../xml/Abstract/RequestResponse.xsd"/>
	<!--
	
	-->
	<element name="studentAddressRequestList"
type="TEST:StudentAddressRequestList"/>
	<!--
	
	-->
	<complexType name="StudentAddressRequestList"
base="TEST:RequestList"  derivedBy="extension">
		<element name="studentAddressRequest"
type="TEST:StudentAddressRequest" minOccurs="0" maxOccurs="unbounded"/>
		<attribute name="version" type="decimal" use="fixed"
value="1.0"/>
	</complexType>
	<!--
	
	-->
	<complexType name="StudentAddressRequest" base="TEST:Request"
derivedBy="extension">
		<element name="address" type="TEST:USAddress"/>
		<attribute name="studentId" type="TEST:SSN" use="required"/>
		<attribute name="phoneNumber" type="TEST:USPhoneNumber"
use="optional"/>
		<attribute name="operation" type="TEST:RecordType"
use="required"/>
	</complexType>
</schema>

I created a one record test file, the purpose of which is to test parsing
the file  with Xerces using the schema file rather than using the DTD witch
describes the  schema. I have tried parsing my test file with both the XSD
schema and the DTD  which describes the schema.  Parsing with the DTD works
perfectly.  Parsing with  the XSD schema file always raises the following
error:

*Parsing Error**
 Line:    7 URI:
file:C:/Apps/Schema/TestData/StudentAddress/StudentAddresses.xml Message:
Element  type "studentAddressRequest" must be
declared.org.xml.sax.SAXException: Error  encountered

Here is what the test file looks like when I try parsing wit the XSD schema:

<?xml version="1.0" encoding="UTF-8"?>
<studentAddressRequestList xmlns="http://www.testco.com/testco"
xmlns:TEST="http://www.w3.org/1999/XMLSchema-instance"
TEST:schemaLocation="http://www.testco.com/testco StudentAddress.xsd"
version="1.0">
  <studentAddressRequest studentId="111223333" operation="UPDATE"
phoneNumber="6175901223">
    <address addressOne="1234 South Parker Avenue Apt. 3B"
addressTwo="Building 4"  city="Cambridge" state="MA" zip="02138"/>
  </studentAddressRequest>
</studentAddressRequestList>

Here is what the test file looks like when I try parsing wit the DTD:

<!DOCTYPE studentAddressRequestList SYSTEM "StudentAddress.dtd">
<studentAddressRequestList version="1.0">
  <studentAddressRequest studentId="111223333" operation="UPDATE"
phoneNumber="6175901223">
    <address addressOne="1234 South Parker Avenue Apt. 3B"
addressTwo="Building 4"  city="Cambridge" state="MA" zip="02138"/>  
  </studentAddressRequest>
</studentAddressRequestList>

Any explanations as to reason why I keep getter this parser "must be
declared"  exception, would be much appreciated.

Sincerely,

Hycel
htaylor@upromise.com
hycel@mediaone.net