XSD: How to nest elements and text

Discussion in 'XML' started by Michael, Sep 3, 2008.

  1. Michael

    Michael Guest

    I'd like to define a paragraph element p in XSD which contains text
    (xs:string) and formatting elements i and b (italic and bold). A valid p
    element could look like this:

    <p>This is <b>bold</b> and this <i>italic</i>.</p>

    I'd use something like this:

    <xs:complexType name="p">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
    <xs:choice>
    <xs:element name="i" type="xs:string" />
    <xs:element name="b" type="xs:string" />
    </xs:choice>
    </xs:sequence>
    </xs:complexType>

    But what do I use for the third option, "raw text", to cover "This is "
    and similar sections in the example above?
    Michael, Sep 3, 2008
    #1
    1. Advertising

  2. Michael wrote:
    > I'd like to define a paragraph element p in XSD which contains text
    > (xs:string) and formatting elements i and b (italic and bold). A valid p
    > element could look like this:
    >
    > <p>This is <b>bold</b> and this <i>italic</i>.</p>
    >
    > I'd use something like this:
    >
    > <xs:complexType name="p">
    > <xs:sequence minOccurs="0" maxOccurs="unbounded">
    > <xs:choice>
    > <xs:element name="i" type="xs:string" />
    > <xs:element name="b" type="xs:string" />
    > </xs:choice>
    > </xs:sequence>
    > </xs:complexType>
    >
    > But what do I use for the third option, "raw text", to cover "This is "
    > and similar sections in the example above?


    See the mixed contents example in
    http://www.w3.org/TR/xmlschema-0/#mixedContent


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Sep 3, 2008
    #2
    1. Advertising

  3. Michael wrote:
    > I'd like to define a paragraph element p in XSD which contains text
    > (xs:string) and formatting elements i and b (italic and bold). A valid p
    > element could look like this:
    >
    > <p>This is <b>bold</b> and this <i>italic</i>.</p>
    >
    > I'd use something like this:
    >
    > <xs:complexType name="p">
    > <xs:sequence minOccurs="0" maxOccurs="unbounded">
    > <xs:choice>
    > <xs:element name="i" type="xs:string" />
    > <xs:element name="b" type="xs:string" />
    > </xs:choice>
    > </xs:sequence>
    > </xs:complexType>
    >
    > But what do I use for the third option, "raw text", to cover "This is "
    > and similar sections in the example above?


    See the mixed contents example in
    http://www.w3.org/TR/xmlschema-0/#mixedContent


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Sep 4, 2008
    #3
  4. Michael wrote:
    > I'd like to define a paragraph element p in XSD which contains text
    > (xs:string) and formatting elements i and b (italic and bold). A valid p
    > element could look like this:
    >
    > <p>This is <b>bold</b> and this <i>italic</i>.</p>
    >
    > I'd use something like this:
    >
    > <xs:complexType name="p">
    > <xs:sequence minOccurs="0" maxOccurs="unbounded">
    > <xs:choice>
    > <xs:element name="i" type="xs:string" />
    > <xs:element name="b" type="xs:string" />
    > </xs:choice>
    > </xs:sequence>
    > </xs:complexType>
    >
    > But what do I use for the third option, "raw text", to cover "This is "
    > and similar sections in the example above?


    See the mixed contents example in
    http://www.w3.org/TR/xmlschema-0/#mixedContent


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Sep 4, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,069
    Markus
    Nov 22, 2005
  2. Rick Razzano

    XSD document for XSD defintion

    Rick Razzano, Sep 26, 2003, in forum: XML
    Replies:
    1
    Views:
    456
    C. M. Sperberg-McQueen
    Sep 26, 2003
  3. Martin
    Replies:
    2
    Views:
    468
    Martin
    Dec 7, 2003
  4. Replies:
    1
    Views:
    837
    Martin Honnen
    Jan 14, 2004
  5. Bernd Oninger
    Replies:
    1
    Views:
    510
    Henry S. Thompson
    Jun 30, 2004
Loading...

Share This Page