RE: managing unknown values

Guillaume,

I don't fully understand what the error message is saying, I would expect an
error message that indicates that the parser found an unexpected element
because, from my understanding, the instance document can only contain
either an element of 'foo' or an element of 'bar', not both.

Try the following schema and instance documents and see if it has the
desired effect.  I have creates a root element called 'test' that includes
both foo and bar as children.


Schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
	<xs:complexType name="KeyRefType">
		<xs:attribute name="idref" type="xs:string"/>
	</xs:complexType>
	
	<xs:complexType name="test">
		<xs:sequence>
			<xs:element name="foo" type="KeyRefType"
nillable="true"/>
			<xs:element name="bar" type="KeyRefType"/>
		</xs:sequence>
	</xs:complexType>
	
	<xs:element name="test" type="test"/>
</xs:schema>


Instance:

<?xml version="1.0" encoding="UTF-8"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xml-dev.xsd">
	<foo xsi:nil="true"/>
	<bar idref="idx"/>
</test>



Steve

-----Original Message-----
From: Guillaume Rousse [mailto:rousse@ccr.jussieu.fr]
Sent: 10 September 2001 hh:mm:ss 12:36
To: Bailey, Stephen; xmlschema-dev@w3.org
Subject: Re: managing unknown values


Ainsi parlait Bailey, Stephen :
> Guillaume,
>
> Tags that must be present, but the value is not known can be declared
using
> the nillable attribute as follows...
>
> <xs:element name="foo" type="xs:integer" nillable="true"/>
>
>
>
> In the instance document, when the value is known you can declare the
> element
>
> <foo>25</foo>
>
>
>
> or when this element has unknown value you can declare the element
>
> <foo xsi:nil="true"/>
Exactly what i needed, thanks.

However, it fails in some cases...
Schema:
<element name="foo" type="KeyRefType" nillable="true"/>
<element name="bar" type="KeyRefType"/>
<complexType name="KeyRefType">
  <attribute name="idref" type="string"/>
</complexType>
Instance:
<foo xsi:nil="true"/>
<bar idref="idx"/>
Error message:
General Schema Error: xsi:nil must not be specified for the element bar with

{nillable} equals 'false'.

I thought it was missing idref attribute in foo that was in cause, so i made

it optional in KeyRefType, but that doesn't change anything. Morevoer, it's 
strange the message targets bar element when foo is the guilty (removing it 
solves the probelm). It this a bug in my validater (xerces-j 1.4.2) ?
-- 
Guillaume Rousse <rousse@ccr.jussieu.fr>
GPG key http://lis.snv.jussieu.fr/~rousse/gpgkey.html

Received on Monday, 10 September 2001 14:03:48 UTC