W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2009

Re: Restricted element content

From: Pete Cordell <petexmldev@codalogic.com>
Date: Thu, 12 Mar 2009 12:59:52 -0000
Message-ID: <206B9C8D77E6420A8B5B136106D2A880@Codalogic>
To: "Vity" <vitywap@seznam.cz>, <xmlschema-dev@w3.org>
Sadly the best you can do with this is define a complex type with complex 
content that is mixed.  You have no control over the type of TEXT data 
within the mixed content, or even where it is placed.

I've often thought it would be nice to have an xs:text element that was 
analogous to an xs:element, but didn't have start and end tags.  You could 
then do:

<xs:complexType name='fooType'>
    <xs:sequence>
        <xs:text type='xs:int'/>
        <xs:element name='bar1'/>
        <xs:element name='bar2'/>
    </xs:sequence>
    <xs:attribute name='atr1' type='xs:string'/>
</xs:complexType>

But I've never sat down and thought through the implications of this so have 
never formally proposed it.  I would be interested to hear whether anybody 
else has thought it through though.

Interestingly (or otherwise) a complex type with simple content could be 
expressed as:

<xs:complexType name='fooType'>
    <xs:sequence>
        <xs:text type='xs:int'/>
    </xs:sequence>
    <xs:attribute name='atr1' type='xs:string'/>
</xs:complexType>

and I wonder whether that could simplify the specs.

Anyway HTH,

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using XML C++
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ for more info

----- Original Message ----- 
From: "Vity" <vitywap@seznam.cz>
To: <xmlschema-dev@w3.org>
Sent: Wednesday, March 11, 2009 6:17 PM
Subject: Restricted element content


>
> Hello,
> I have very simple question, but I cannot find a solution for this.
> I would like to create XSD, which would describe following piece of XML:
> <foo atr1="some restricted attribute">
>  --limited string length (or eg. positive integer)-- 
>  <bar1 />
>  <bar2 />
> </foo>
>
> =element with an attribute which contains restricted content and other
> elements.
>
> I have no problem to describe the XML without "bar" elements, but it seems
> to have no solution with them.
>
> Thanks in advance.
>
> -Vity
>
>
>
> 
Received on Thursday, 12 March 2009 13:00:35 GMT

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