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

RE: Restricted element content

From: Michael Kay <mike@saxonica.com>
Date: Thu, 12 Mar 2009 12:48:29 -0000
To: "'Vity'" <vitywap@seznam.cz>, <xmlschema-dev@w3.org>
Message-ID: <CD8AA2CB2533411BB6F2A8045A8C9410@Sealion>
XSD 1.0 does not allow you to constrain the content of the text nodes in
mixed content.

It's worth bearing in mind that XSD was never designed to allow you to
describe arbitrary XML instance documents.  Rather it was designed to
support a particular set of widely used XML design patterns. Holding
structured data in mixed content elements is probably not a good idea; you
would be better off wrapping the positive integer in another child element.
This will be much easier to process in XSLT or XQuery.

With assertions in XSD 1.1, however, you can do what you like.

Michael Kay

> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Vity
> Sent: 11 March 2009 18:17
> To: xmlschema-dev@w3.org
> 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 12:49:21 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:50 UTC