Re: [xml] repeating elements

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 UTC