[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: [xml] repeating elements

Subject: RE: [xml] repeating elements
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 29 May 2007 14:40:49 +0100
RE:  [xml] repeating elements
Since this problem has nothing to do with XSLT, could I suggest you move it
to a different list, such as xmlschema-dev?

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Ignacio Garcia [mailto:igcxslt@xxxxxxxxx] 
> Sent: 29 May 2007 14:18
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  [xml] repeating elements
> 
> The problem is still there...
> 
> I tried using grouping, but the same thing happens...
> 
> I can have multiple <i> elements, but the editor won't allow 
> me to add <i> MIXED TEXT <i>.
> If I do it by hand the result is validated with no problems.
> 
> Any other suggestions?
> 
> 
> On 5/24/07, Andrew Welch <andrew.j.welch@xxxxxxxxx> wrote:
> > On 5/24/07, Ignacio Garcia <igcxslt@xxxxxxxxx> wrote:
> > > Hello,
> > >
> > > I have the following problem...
> > >
> > > 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>
> > >
> > > As you can see, the type is simple and does exactly what I want...
> > > If I put this inside an element and create an stylesheet using 
> > > <xsl:copy-of> I get the desired result of working html code...
> > >
> > > 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...
> > >
> > > Let me explain:
> > >
> > > If my element contains:
> > > ----------------
> > > This is some <b>text</b> with <i>html</i> tags on it.
> > > ----------------
> > >
> > > Everything works perfect...BUT if after that I want to add 
> > > <i>another italics</i>, the editor won't let me... If I use a raw 
> > > text editor, then I can add it, and the instance is 
> valid, but any 
> > > xml editor that helps with tag addition will not let me add the 
> > > second <i> after I have used one.
> > >
> > > However, if I have some other html-like-tag between the two <i>, 
> > > then there is no problem...
> > >
> > > Does anyone know why???
> > > I have tried adding <sequence minOccurrs=0" 
> maxOccurrs="unbounded"> 
> > > surrounding all the html-like elements, but that does not work 
> > > either...
> >
> > This is an XML Schema question, not XSLT, so its better 
> asked on XML 
> > Schema Dev (although Schema Aware XSLT is on-topic so I guess the 
> > lines are blurred a little).
> >
> > You've defined <i> as optional, so you're only only allowed 0 or 1 
> > occurrence, hence when you add second the XML becomes 
> invalid.  If you 
> > want to allow more that one then specify maxOccurs on the 
> definition 
> > to it optional-repeatable.
> >
> > Even then, all that will do is allow you to have multiple 
> <i>'s in a 
> > sequence.  If you want to allow any element in any order 
> then I use a
> > group:
> >
> > <xs:group name="html-elements">
> >   <xs:sequence>
> >     <xs:element name="b" type="xs:string" minOccurs="0"/>
> >     <xs:element name="i" type="xs:string" minOccurs="0"/>
> >     <xs:element name="p" type="html-elements" minOccurs="0"/>
> >     .....
> >   </
> > </
> >
> > and then:
> >
> > <xs:complexType name="notesText" mixed="true">
> >        <xs:group ref="html-elements" minOccurs="0"
> > maxOccurs="unbounded"/>
> > </
> >
> > This should allow any mix of "html-elements" and text.
> >
> > (this is just one way I've done it - there may well be better ways)
> >
> > cheers
> > andrew

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.