W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2007

Re: [xml] repeating elements

From: C. M. Sperberg-McQueen <cmsmcq@acm.org>
Date: Mon, 4 Jun 2007 08:57:19 -0500
Message-Id: <E760017B-B326-451D-83CE-26F1F0341358@acm.org>
Cc: "C. M. Sperberg-McQueen" <cmsmcq@acm.org>, xmlschema-dev@w3.org
To: Ignacio Garcia <igcxslt@gmail.com>

On 29 May 2007, at 09:32 , Ignacio Garcia wrote:

> ... I have created a schema that with a complex type that contains  
> a few
> html like tags:
>
> <xsd:complexType name="notesText" mixed="true">
>       <xsd:sequence minOccurs="0" maxOccurs="unbounded">
>               <xsd:element name="b" type="xsd:string" minOccurs="0"/>
>               <xsd:element name="i" type="xsd:string" minOccurs="0"/>
>               <xsd:element name="p" type="notesText" minOccurs="0"/>
>               <xsd:element name="br" minOccurs="0">
>                       <xsd:simpleType>
>                               <xsd:restriction base="xsd:string">
>                                       <xsd:length value="0"/>
>                               </xsd:restriction>
>                       </xsd:simpleType>
>               </xsd:element>
>               <xsd:element name="a" minOccurs="0">
>                       <xsd:complexType mixed="true">
>                               <xsd:attribute name="href"
>                                 type="xsd:string" use="required"/>
>                       </xsd:complexType>
>               </xsd:element>
>               <xsd:element name="ul" minOccurs="0">
>                       <xsd:complexType>
>                               <xsd:sequence maxOccurs="unbounded">
>                                       <xsd:element name="li"
>                                         type="notesText"  
> minOccurs="0"/>
>                               </xsd:sequence>
>                       </xsd:complexType>
>               </xsd:element>
>     </xsd:sequence>
> </xsd:complexType>
>
> ...
> HOWEVER, using this definition none of the html editors I have used
> lets me add the same html-like-tag two times in a row with text in
> between them......
> Does anyone know why???

Like Michael Kay, I believe this is a bug.  It seems an implausible
bug, though, so you might check to make sure what you are showing
is really what they are seeing.  The behavior you describe is consistent
with systems which see a version of this declaration with
maxOccurs="1" (possibly defaulted) on the sequence.  You might
modify your sample element:  you say that

   This is some <b>text</b> with <i>html</i> tags on it.

is accepted but

   This is some <b>text</b> with <i>html</i> tags <i>on</i> it.

is not.  How about

   This is some <i>text</i> with <b>html</b> tags on it.

?

> I have tried adding <sequence minOccurrs=0" maxOccurrs="unbounded">
> surrounding all the html-like elements, but that does not work
> either...

If you're willing to modify the declaration to work around the
deficiencies of tools, you might consider changing the enclosing
sequence to a choice; the two patterns are equivalent (i.e. they
recognize the same language) and the repeated choice is more
likely to have been checked by the developers.

--C. M. Sperberg-McQueen
   World Wide Web Consortium
Received on Monday, 4 June 2007 14:09:02 GMT

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