Re: Restricted element content

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 UTC