Holger,

I think the following schema definitions illustrate what you want to do.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema";>
<xsd:complexType name="simpleBaseType">
  <xsd:simpleContent>
    <xsd:restriction base="xsd:anySimpleType">
      <xsd:attribute name="isNullable" type="xsd:boolean"
use="optional"/>
      <xsd:attribute name="isUpdatable" type="xsd:boolean"
use="optional"/>
    </xsd:restriction>
  </xsd:simpleContent>
</xsd:complexType>

<xsd:complexType name="intElementType">
  <xsd:simpleContent>
    <xsd:restriction base="simpleBaseType">
      <xsd:simpleType>
        <xsd:restriction base="xsd:integer"/>
      </xsd:simpleType>
    </xsd:restriction>
  </xsd:simpleContent>
</xsd:complexType>

<xsd:complexType name="booleanElementType">
  <xsd:simpleContent>
    <xsd:restriction base="simpleBaseType">
      <xsd:simpleType>
        <xsd:restriction base="xsd:boolean"/>
      </xsd:simpleType>
    </xsd:restriction>
  </xsd:simpleContent>
</xsd:complexType>

<xsd:element name="intElement" type="intElementType"/>

<xsd:element name="booleanElement" type="booleanElementType"/>

</xsd:schema>

The builtin type, xsd:anySimpleType, is described in the
Schema Structures spec in section '3.13 (non-normative) Simple 
Type Definition Details'. It is the type to use to specify
that any simple type is acceptable.

I validated the following instances against this schema using
XML Spy 3.5.

<?xml version="1.0" encoding="UTF-8"?><intElement
        xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance";
        xsi:noNamespaceSchemaLocation="simpleType.xsd"
        isNullable="true" isUpdatable="false">10t</intElement>

<?xml version="1.0" encoding="UTF-8"?>
<booleanElement
        xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance";
        xsi:noNamespaceSchemaLocation="simpleType.xsd"
        isNullable="true" isUpdatable="false">true1</booleanElement>

In both cases XML Spy produced errors. For the first it correctly
indicated that that '10t' is not a valid integer value. For the
second it indicated that 'true1' is not a valid boolean value.

After correcting the values as follows, they both validated
without any error.

<?xml version="1.0" encoding="UTF-8"?><intElement
        xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance";
        xsi:noNamespaceSchemaLocation="simpleType.xsd"
        isNullable="true" isUpdatable="false">10</intElement>

<?xml version="1.0" encoding="UTF-8"?>
<booleanElement
        xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance";
        xsi:noNamespaceSchemaLocation="simpleType.xsd"
        isNullable="true" isUpdatable="false">true</booleanElement>

The bad news is that Xerces-J barfs on xsd:anySimpleType as
follows when using the SAX parser.

"Base type could not be found : xsd:anySimpleType."

So, I think the above is the solution you want, however,
Xerces-J doesn't handle it at this time.

Regards,

Keith

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 13, 2001 2:51 AM
> To: [EMAIL PROTECTED]
> Subject: Re: RE: anyType supported for simpleType?
> 
> 
> 
> 
> Thanks Lisa, thanks Keith,
> 
> I guess I should illustrate my problem a bit more detailed. I 
> would like to
> have a complex base type with a simple content containing 
> only attributes.
> I need the base type to make the derived types exchangeable in the xml
> documents. The type of the simple content shall be specified 
> in the derived
> type. (i.e. integer, boolean ...) As far as I understood I 
> could achieve
> the same with a substitution group and an attribute group, but the
> substitution group needs again a common base type for all exchangeable
> elements, right?
> 
> <complexType name="a">
>   <simpleContent>
>     <restriction base="anyType">
>       <attribute name="isNullable" type="boolean" use="optional"/>
>       <attribute name="isUpdatable" type="boolean" use="optional"/>
>     </restriction>
>   <simpleContent>
> </complexType>
> 
> <complexType name="b">
>   <simpleContent>
>     <restriction base="a">
>       <simpleType>
>         <restriction base="integer"/>
>       </simpleType>
>     </restriction>
>   </simpleContent>
> </complexType>
> 
> This sample works if I use the following definition for 
> complex type 'a':
> 
> <complexType name="a">
>   <attribute name="isNullable" type="boolean" use="optional"/>
>   <attribute name="isUpdatable" type="boolean" use="optional"/>
> </complexType>
> 
> But this restricts the content of 'a' to be EMPTY. And that 
> is again not
> excatly what I'm trying to do...
> 
> If I specifiy the content of a to be a 'string', I can't restrict the
> content of the derived type to be an 'integer' or a 'boolean', can I?
> 
> But in general my example should be valid, shouldn't it? Or do I have
> overlooked something in the xml schema spec?
> 
> Thanks again.
> Holger
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

Reply via email to