W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2008

RE: "mixing" simpleType and complexType

From: Michael Kay <mike@saxonica.com>
Date: Fri, 25 Jul 2008 21:04:32 +0100
To: <info@minimag.de>, "'XML Schema List'" <xmlschema-dev@w3.org>
Message-ID: <760D1BF6810E47188D8B47A92273F830@Sealion>

Your <peculiar> element has mixed content, and XSD 1.0 gives you no way to
constrain the text that may appear in an element with mixed content.

You can do this using assertions in XSD 1.1:

<xs:element name="peculiar">
  <xs:complexType mixed="true">
    ...
    <xs:assert test="matches(text(), '\p{IsGreek}+')"/>

Implemented in Saxon 9.1.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Andreas Peter
> Sent: 25 July 2008 20:13
> To: XML Schema List
> Subject: "mixing" simpleType and complexType
> 
> 
> Hello list-users,
> 
> I need to "mix" simpleTypes and complexTypes. To be more precisely an
> example:
> 
> As result I need the following
> 
> <peculiar><subscript>2</subscript></peculiar>
> 
> where as the "" should be from the unicode block "greek" and the "2" 
> from the unicode block "superscriptsandsubscripts". The 
> problem is that I defined a simpleType for both and I do not 
> know how to nest them in an element "peculiar"? The "" and 
> the "2" should be tested if they are part of the unicode blocks.
> 
> 
>     <xs:simpleType name="greekType">
>         <xs:restriction base="xs:string">
>             <xs:pattern value="\p{IsGreek}+"/>
>         </xs:restriction>
>     </xs:simpleType>
> 
>     <xs:simpleType name="subscriptType">
>         <xs:restriction base="xs:string">
>             <xs:pattern value="\p{IsSuperscriptsandSubscripts}+"/>
>         </xs:restriction>
>     </xs:simpleType>
>    
>     <xs:element name="peculiar">
>         <xs:complexType>
>             ???
>         </xs:complexType>
>     </xs:element>
> 
> I hope that the problem was described clearly :-) Any hints 
> are welcome. Thanks so much,
> 
> Andreas
> 
> 
> 
> 
> 
Received on Friday, 25 July 2008 20:05:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:06 GMT