Re: managing unknown values

Ainsi parlait Bailey, Stephen :
> 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.
I don't understand it also, however:
-foo and bar should be totaly independent (in theory)
-presence or absence of foo (in reality) triggers the message vs bad

> 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.
> <?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>
I just modified foo and bar element to allow non-occurence (minOccur="0")

With following instance:
<?xml version="1.0" encoding="UTF-8"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="schema.xsd">
        <foo xsi:nil="true"/>
        <bar idref="idx"/>
</test>
[guillaume@silbermann guillaume]$ xml-check instance.xml
[Error] instance.xml:4:27: General Schema Error: xsi:nil must not be 
specified for the element bar with {nillable} equals 'false'.
instance.xml: 649 ms (3 elems, 4 attrs, 19 spaces, 0 chars)

With following instance:
<?xml version="1.0" encoding="UTF-8"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="schema.xsd">
        <bar idref="idx"/>
</test>
[guillaume@silbermann guillaume]$ xml-check instance.xml
instance.xml: 631 ms (2 elems, 3 attrs, 10 spaces, 0 chars)
-- 
Guillaume Rousse <rousse@ccr.jussieu.fr>
GPG key http://lis.snv.jussieu.fr/~rousse/gpgkey.html

Received on Monday, 10 September 2001 14:16:24 UTC