You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Scott Lawrence <sl...@pingtel.com> on 2005/01/04 17:37:28 UTC

'all' must only appear as the content type of a complex type definition

I'm trying to develop a schema for an existing XML usage (for which no
schema or DTD was ever written before).  I've run into a case that I
can't get Xerces-C to validate, and am not sure whether my schema
construction or the parser validation is the problem.  I've put together
a simplified version of the schema that shows the problem.

The short statement of the problem is that I have an element 'address'
whose content may be either the single element 'url' or any combination
of the elements 'user', 'host', and 'qual'.  I tried to express this as:

  <group name='parts'>
    <all>
      <element ref='dmp:user' minOccurs='0' maxOccurs='1'/>
      <element ref='dmp:host' minOccurs='0' maxOccurs='1'/>
      <element ref='dmp:qual' minOccurs='0' maxOccurs='1'/>
    </all>
  </group>

  <element name='address'>
    <complexType>
      <choice>
        <group   ref='dmp:parts'/>
        <element ref='dmp:url'/>
      </choice>
    </complexType>
  </element>

When I try to validate a document against the above (using either
xerces-c version 2.5 or 2.6), I get:

======
> DOMCount -v=always -s -f -n either.xml

Error at file file:///home/lawrence/tmp/groupall/either.xsd, line 24,
char 35
  Message: A group whose content is 'all' must only appear as the
content type of a complex type definition.

Error at file /home/lawrence/tmp/groupall/either.xml, line 14, char 13
  Message: Element 'user' is not valid for content model: '(url|)'

Error at file /home/lawrence/tmp/groupall/either.xml, line 19, char 13
  Message: Element 'user' is not valid for content model: '(url|)'

Errors occurred, no output available
=======

I've attached the document and the test schema.  These validate using
the XSV validator at http://www.w3.org/2001/03/webdata/xsv#hlp-warn ,
but if my schema is wrong, this wouldn't be the first time I've found a
case it doesn't catch.

-- 
Scott Lawrence
Consulting Engineer
Pingtel Corp.
http://www.pingtel.com/
+1.781.938.5306 x162