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 Jerry Lawson <je...@virtualsummit.com> on 2000/10/25 20:19:45 UTC
parse error on extended element
I'm pretty new to validating xml against schema,
and have run into a problem with my instance doc
and schema. The problem reported by 1.2.1 xerces
parser is:
Error on line 12 of document file:test.xml: The content of element type
"Service" must match "(subscriberId,ipAddress)"
I have had the problem with more complicated schemas,
but I've tried narrowing the scope of the problem with
these simple files. I would like the schema to define
a "base" type of Service, but allow for the instance
docs to use extended types where Service is expected.
Can anyone out there tell me what I'm doing wrong,
syntax wise ?
Here are my xml instance doc and schema:
*****************************************
test.xml:
<?xml version="1.0"?>
<Doc xmlns="http://www.jerry.org/test"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:schemaLocation="http://www.jerry.org/test test.xsd"
version="1.0">
<Record seqNum="1">
<Service xsi:type="ServiceTypeA">
<subscriberId>Joe Blow</subscriberId>
<ipAddress>172.16.25.2</ipAddress>
</Service>
</Record>
</Doc>
******************************************
and, test.xsd:
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/1999/XMLSchema"
targetNamespace="http://www.jerry.org/test"
xmlns:test="http://www.jerry.org/test">
<element name="Doc">
<complexType content="elementOnly">
<element ref="test:Record" minOccurs="1" maxOccurs="1"/>
<attribute name="version" type="string" minOccurs="1"
maxOccurs="1"/>
</complexType>
</element>
<element name="Record">
<complexType content="elementOnly">
<choice minOccurs="0" maxOccurs="1">
<element ref="test:ipAddress"/>
<element ref="test:Service"/>
</choice>
<attribute name="seqNum" type="integer" use="optional"/>
</complexType>
</element>
<complexType name="ServiceBase" content="empty" final="restriction">
<attribute name="id" type="ID" use="optional"/>
</complexType>
<element name="Service" type="test:ServiceBase">
<annotation>
<documentation> This element describes the Service.
</documentation>
</annotation>
</element>
<complexType name="ServiceTypeA" base="test:ServiceBase"
derivedBy="extension">
<element ref="test:subscriberId" minOccurs="1" maxOccurs="1"/>
<element ref="test:ipAddress" minOccurs="1" maxOccurs="1"/>
</complexType>
<element name="subscriberId" type="string">
<annotation>
<documentation> Subscriber's id.
</documentation>
</annotation>
</element>
<element name="ipAddress" type="string"/>
</schema>
--
___________________________________________________
Jerry Lawson Virtual Summit, Inc.
Virtual Programmer jerry.lawson@virtualsummit.com
Re: parse error on extended element
Posted by Jerry Lawson <je...@virtualsummit.com>.
I got the change, and it works! thanks.
Now, the next problem: if I change the declaration of
ipAddress from the top-level to inside the ServiceTypeA complexType
(and remove ipAddress from the top-level), eg,
<complexType name="ServiceTypeA" base="test:ServiceBase"
derivedBy="extension">
<element ref="test:subscriberId" minOccurs="1" maxOccurs="1"/>
<element name="ipAddress" type="string" minOccurs="1" maxOccurs="1"/>
</complexType>
I get this error, reported from TraverseSchema.traverseElementDecl() :
org.xml.sax.SAXParseException: Schema error: Element ipAddress not found
in the Schema.
Again, not being a schema guru, this may be something that is
not legal in the April schema syntax.
This particular case is an example of other schemas declaring
subelements directly inside the complexType, rather than using
the 'ref'.
Any ideas ?
Eric Ye wrote:
>
> Yes, that is a xsi:type bug that will happen only when the base type's
> content attribute has "empty" value.
> I've fixed it in the CVS, check out the
> org/apache/xerces/validators/common/XMLValidator.java to give it a try.
--
___________________________________________________
Jerry Lawson Virtual Summit, Inc.
Virtual Programmer jerry.lawson@virtualsummit.com
Re: parse error on extended element
Posted by Eric Ye <er...@locus.apache.org>.
Yes, that is a xsi:type bug that will happen only when the base type's
content attribute has "empty" value.
I've fixed it in the CVS, check out the
org/apache/xerces/validators/common/XMLValidator.java to give it a try.
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: "Jerry Lawson" <je...@virtualsummit.com>
To: <xe...@xml.apache.org>
Sent: Wednesday, October 25, 2000 11:19 AM
Subject: parse error on extended element
> I'm pretty new to validating xml against schema,
> and have run into a problem with my instance doc
> and schema. The problem reported by 1.2.1 xerces
> parser is:
>
> Error on line 12 of document file:test.xml: The content of element type
> "Service" must match "(subscriberId,ipAddress)"
>
> I have had the problem with more complicated schemas,
> but I've tried narrowing the scope of the problem with
> these simple files. I would like the schema to define
> a "base" type of Service, but allow for the instance
> docs to use extended types where Service is expected.
>
> Can anyone out there tell me what I'm doing wrong,
> syntax wise ?
>
>
> Here are my xml instance doc and schema:
>
> *****************************************
> test.xml:
>
> <?xml version="1.0"?>
>
> <Doc xmlns="http://www.jerry.org/test"
> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> xsi:schemaLocation="http://www.jerry.org/test test.xsd"
> version="1.0">
>
> <Record seqNum="1">
> <Service xsi:type="ServiceTypeA">
> <subscriberId>Joe Blow</subscriberId>
> <ipAddress>172.16.25.2</ipAddress>
> </Service>
> </Record>
> </Doc>
>
> ******************************************
>
> and, test.xsd:
>
> <?xml version="1.0"?>
>
> <schema xmlns="http://www.w3.org/1999/XMLSchema"
> targetNamespace="http://www.jerry.org/test"
> xmlns:test="http://www.jerry.org/test">
>
>
> <element name="Doc">
> <complexType content="elementOnly">
> <element ref="test:Record" minOccurs="1" maxOccurs="1"/>
> <attribute name="version" type="string" minOccurs="1"
> maxOccurs="1"/>
> </complexType>
> </element>
>
> <element name="Record">
> <complexType content="elementOnly">
> <choice minOccurs="0" maxOccurs="1">
> <element ref="test:ipAddress"/>
> <element ref="test:Service"/>
> </choice>
> <attribute name="seqNum" type="integer" use="optional"/>
> </complexType>
> </element>
>
> <complexType name="ServiceBase" content="empty" final="restriction">
> <attribute name="id" type="ID" use="optional"/>
> </complexType>
>
> <element name="Service" type="test:ServiceBase">
> <annotation>
> <documentation> This element describes the Service.
> </documentation>
> </annotation>
> </element>
>
> <complexType name="ServiceTypeA" base="test:ServiceBase"
> derivedBy="extension">
> <element ref="test:subscriberId" minOccurs="1" maxOccurs="1"/>
> <element ref="test:ipAddress" minOccurs="1" maxOccurs="1"/>
> </complexType>
>
> <element name="subscriberId" type="string">
> <annotation>
> <documentation> Subscriber's id.
> </documentation>
> </annotation>
> </element>
>
> <element name="ipAddress" type="string"/>
>
> </schema>
>
> --
> ___________________________________________________
> Jerry Lawson Virtual Summit, Inc.
> Virtual Programmer jerry.lawson@virtualsummit.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>