W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2004

Constraining a mixed type ?

From: Bruno Chatel <bcha@chadocs.net>
Date: Fri, 16 Apr 2004 09:10:53 +0200
Message-ID: <0a9a01c42381$f57315d0$0600a8c0@chadocshome.com>
To: <xmlschema-dev@w3.org>
Cc: "Pierre Attar" <attar@tireme.fr>, "Bruno Chatel" <bcha@chadocs.net>

Hi,

I wonder if it is possible to define a constrain on a mixed content using
XML Schemas. 
For example, I need to specify that there is at least one character in my mixed
complextype. 

I try the following schema :

<xs:simpleType name="nonempty-content-ST">
    <xs:restriction base="xs:string">
        <xs:minLength value="1"/>
    </xs:restriction>
</xs:simpleType>

<xs:complexType name="nonempty-content-CT">
    <xs:simpleContent>
        <xs:extension base="nonempty-content-ST"/>
    </xs:simpleContent>
</xs:complexType>

<xs:complexType name="mixed-content-CT" mixed="true">
    <xs:complexContent mixed="true">
        <xs:extension base="nonempty-content-CT">
            <xs:choice maxOccurs="unbounded">
                    <xs:element name="emph" type="xs:string"/>
            </xs:choice>
        </xs:extension>
    </xs:complexContent>
</xs:complexType>

<xs:element name="p" type="mixed-content-CT"/>

But it have problem to validate a document such 

<p><emph>test</emph></p>

is this schema correct ?

It there an other  way to write this ?

Thanks in advance

-- bruno -- 
Bruno Chatel
Tel : (+33) (0)4 96 11 14 57
bcha@chadocs.com
--------------------------------------
Received on Friday, 16 April 2004 03:05:07 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:11 UTC