Re: Probs with XML Schema validations using SAX

Hi Prakash,

> [Error] BSS_ResActvnBSS0.xml:4:108: src-ct.2: Complex Type
> Definition Representation Error for type
> '#AnonType_hopperhopperstop'. When simpleContent is used, the base
> type must be a complexType whose content type is simple, or, only if
> extension is specified, a simple type.
>
>From what I understand this is syntactically correct, so anybody has
>any ideas as to what is going wrong.

The validator is complaining that you're deriving the type of the
hopper element by *restriction* from xs:string. xs:string is a simple
type -- if an element is of that type, it can't have any attributes,
and only text content. You're defining a complex type derived from
xs:string, but you're trying to add attributes at the same time.

When you derive by restriction, you must *restrict* the base type --
the new type must accept less things than the base type. If you want
to allow it to accept more things, then you have to derive by
*extension*. Try:

  <xs:element name="hopper" minOccurs="0" maxOccurs="unbounded">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="identity" type="xs:ID" use="required"/>
          ...
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

(The validator is actually complaining about the fact that you're
using an xs:restriction element within a xs:simpleContent element
within a xs:complexType element, when the base attribute of the
xs:restriction element points to a simple type rather than a complex
type, since that's not allowed according to the XML Schema spec.)
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Wednesday, 12 June 2002 17:15:33 UTC