Re: minOccurs

Hi Eddie,

My type "S" is just an xs:string and the "groupB" looks like "groupA" with
different elements (the problem is not on that side but more with the
minOccurs).

My problem is with a product we have bought helping us to generate Java code
based on our schemas. This product generate a function to validate if the
XML file is valid.

The problem is that if I have no element in my "groupA" (since they are all
optional) their API got a problem when I call their validation function
because they assume (since I have no minOccurs specified to the reference,
like xs:group ref="groupA" minOccurs="0") that the minOccurs is "1"
(default) and during their validation they have probably initiate a kind of
pointer on nothing since I have not specify any elements in my "groupA" and
they return an error.

To solve my problem they suggest me to add a minOccurs="0" (which make
sense) but for some reason I do not want to do that since my schema is valid
(what I try to be sure).

They argue that their comprehension of the W3C is correct and they do not
want to correct what I call a bug, but I guess they are wrong.

Also I am using the XML Spy editor which includes a Microsoft XML parser
(MSXML 4.0) and I have no error when I validate my schema.

I hope to be clear enough !

Thanks again,
Frédéric Jaouën


Eddie Robertsson wrote:

> Hi,
>
> > I have define a group "groupA" which contains 3 optional elements.
> >
> > Is that correct to make a reference without specifying a minOccurs="0"
> > in my definition of "testMin" element even though all elements in
> > "groupA" are all optional ?
> >
> > Even though it is probably not very nice, I understand in the W3C that
> > it can be done and I should be able to validate it !
> >
> > RIGHT ???
> >
> I guess this depends on if your base type "S" and the "groupB" are valid
> but otherwise I don't see any problems with your schema. What errors are
> you getting?
> One problem could be that your groupB defines the same elements as
> groupA which would create an ambigous content model since all your
> elements in groupA are optional.
>
> Cheers,
> /Eddie
>
> > <xs:group name="*groupA*">
> >   <xs:sequence>
> >    <xs:element name="*A*" minOccurs="0">
> >     <xs:simpleType>
> >      <xs:restriction base="S">
> >       <xs:maxLength value="64"/>
> >      </xs:restriction>
> >     </xs:simpleType>
> >    </xs:element>
> >    <xs:element name="*B*" minOccurs="0">
> >     <xs:simpleType>
> >      <xs:restriction base="S">
> >       <xs:maxLength value="32"/>
> >      </xs:restriction>
> >     </xs:simpleType>
> >    </xs:element>
> >    <xs:element name="*C*" minOccurs="0">
> >     <xs:simpleType>
> >      <xs:restriction base="S">
> >       <xs:maxLength value="32"/>
> >      </xs:restriction>
> >     </xs:simpleType>
> >    </xs:element>
> >   </xs:sequence>
> >  </xs:group>
> >
> >  <xs:element name="*testMin*">
> >   <xs:complexType>
> >    <xs:sequence>
> >     <xs:group ref="groupA"/>
> >     <xs:group ref="groupB"/>
> >    </xs:sequence>
> >   </xs:complexType>
> >  </xs:element>
> >
> > "groupB" maybe anything.
> >
> > Thanks !
> >
> > Frédéric Jaouën
> >
> >

Received on Wednesday, 28 August 2002 11:25:39 UTC