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 Sebastien Gignoux <gi...@intalio.com> on 2001/08/06 22:58:05 UTC

Problem with xs:choice?

Hi all,

I am using xerces 1.4.2 to validate an XML document against a very simple schema
which contain an xs:choice. When I try to run my code I have the following error:

[Error] :6:14: Element type "aaa" must be declared.
[Error] :7:9: The content of element type "pipo" must match "(aaa|bbb)".


For reference, the XML document:

<?xml version='1.0'?>
<pipo    xmlns='http://www.pipo.org'
         xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
         xsi:schemaLocation='http://www.pipo.org choice.xsd'>

        <aaa>asdfasdfa</aaa>
</pipo>



And the schema 'choice.xsd':

<?xml version="1.0"?>
<xs:schema targetNamespace="http://www.pipo.org" 
            xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="pipo" type="pipoType"/>

    <xs:complexType name="pipoType">
       <xs:choice>
          <xs:element name="aaa" type="xs:string"/>
          <xs:element name="bbb" type="xs:string"/>
       </xs:choice>
    </xs:complexType>
</xs:schema>


Is it me who is missing something obvious or is there a problem with xs:choice?

Thanks 

Seb

-- 
There is a theory which states that if ever anyone discovers exactly what the
Universe is for and why it is here, it will instantly disappear and be replaced
by something even more bizarre and inexplicable. There is another theory which
states that this has already happened.
       -- Douglas Adams, The Restaurant at the End of the Universe

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: Problem with xs:choice?

Posted by Sebastien Gignoux <gi...@intalio.com>.
Erwin Bolwidt writes:
 > On Mon, 6 Aug 2001, Sebastien Gignoux wrote:
 > 
 > > [Error] :6:14: Element type "aaa" must be declared.
 > > [Error] :7:9: The content of element type "pipo" must match "(aaa|bbb)".
 > > [...]
 > > <?xml version="1.0"?> <xs:schema targetNamespace="http://www.pipo.org"
 > >             xmlns:xs="http://www.w3.org/2001/XMLSchema">
 > >
 > >     <xs:element name="pipo" type="pipoType"/>
 > >
 > >     <xs:complexType name="pipoType">
 > >        <xs:choice>
 > >           <xs:element name="aaa" type="xs:string"/>
 > >           <xs:element name="bbb" type="xs:string"/>
 > >        </xs:choice>
 > >     </xs:complexType>
 > > </xs:schema>
 > 
 > I think it might be the same problem that I had. There was a good
 > solution in a response from Sandy Gao, see "Re: Schema problem?" on this
 > list about a week ago:
 > 
 > | [...] In your xsd file, you didn't specify attribute "elementFormDefault",
 > | whose default is "unqualified". That means, all locally declared
 > | elements don't have a target namespace. [...]
 > | To solve it, you can either specify "elementFormDefault" as "qualified",
 > | or try not use default namespace in the instance file. [...]
 > 
 > At least it seems to me that you have the same problem, so you could add
 > elementFormDefault="qualified" to the <xs:schema> element.

Thank you very much, that solved my problem. 

Seb

-- 
There is a theory which states that if ever anyone discovers exactly what the
Universe is for and why it is here, it will instantly disappear and be replaced
by something even more bizarre and inexplicable. There is another theory which
states that this has already happened.
       -- Douglas Adams, The Restaurant at the End of the Universe

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: Problem with xs:choice?

Posted by Erwin Bolwidt <ej...@klomp.org>.
On Mon, 6 Aug 2001, Sebastien Gignoux wrote:

> [Error] :6:14: Element type "aaa" must be declared.
> [Error] :7:9: The content of element type "pipo" must match "(aaa|bbb)".
> [...]
> <?xml version="1.0"?> <xs:schema targetNamespace="http://www.pipo.org"
>             xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
>     <xs:element name="pipo" type="pipoType"/>
>
>     <xs:complexType name="pipoType">
>        <xs:choice>
>           <xs:element name="aaa" type="xs:string"/>
>           <xs:element name="bbb" type="xs:string"/>
>        </xs:choice>
>     </xs:complexType>
> </xs:schema>

I think it might be the same problem that I had. There was a good
solution in a response from Sandy Gao, see "Re: Schema problem?" on this
list about a week ago:

| [...] In your xsd file, you didn't specify attribute "elementFormDefault",
| whose default is "unqualified". That means, all locally declared
| elements don't have a target namespace. [...]
| To solve it, you can either specify "elementFormDefault" as "qualified",
| or try not use default namespace in the instance file. [...]

At least it seems to me that you have the same problem, so you could add
elementFormDefault="qualified" to the <xs:schema> element.

Best,
  Erwin Bolwidt



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org