XSD: How to nest elements and text


M

Michael

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?
 
Ad

Advertisements

M

Martin Honnen

Michael said:
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
 
M

Martin Honnen

Michael said:
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
 
Ad

Advertisements

M

Martin Honnen

Michael said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top