Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsd schema for paragraph with bold, italics, etc

Status
Not open for further replies.

eLearningDeveloper

Programmer
Nov 24, 2008
2
US
I am trying to create a schema that allows simple paragraphs to include bold, underlined, and other inline text with styles - one at a time, not nested. I do not need arbitrary mixing, such as portions of bold text underlined, and so on - just a simple text string paragraph tag that can include portions of inline text marked up EITHER bold, underlined, or italics:

<para>This is <b>a sample</b> paragraph with <i>some</i> inline content marked up further.</para>

The problem with the examples I am finding is that they permit starting with the inline markup - for example, this would be legal:

<i>Here is an <para>example <b>of <u>what</u></b></para> I do not want.</i>

Can anyone point me to an example?
 
[0] You can use substitutionGroup with simpleType xs:string. For the head element of the group, you can make it abstract (uninstantiable) so as to make the other instantiable elements on equal footing without specifically select one particular tag as head element.

[1] Let's us inline elements including b, i and em say. Then construct a type called "paraType". Like this.
[tt]
<xs:element name="para" type="paraType" minOccurs="0" maxOccurs="unbounded" />

<xs:complexType name="paraType" mixed="true">
<xs:sequence>
<xs:element ref="in-line-element" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>

<xs:element name="in-line-element" abstract="true" />
<xs:element name="b" substitutionGroup="in-line-element" type="xs:string" />
<xs:element name="i" substitutionGroup="in-line-element" type="xs:string" />
<xs:element name="em" substitutionGroup="in-line-element" type="xs:string" />
[/tt]
[2] There may be some minor implementation/interpretation issue on the reading of the recommendation for simpleType's abstract attribute. In case one has doubt and concern, you can choose one of the inline elements, say b, as head element in the place of "in-line-element" in [1] and take out the abstract attribute. Then the separate line on the xs:element for b in [1] should not be there as a matter of course. This is just a minor academic issue for specialists.
 
Amendment
The corresponding line should be read as amended, surely no type attribute there with ref.
>[self]<xs:element ref="in-line-element" [red]type="xs:string"[/red] minOccurs="0" maxOccurs="unbounded" />
[tt]<xs:element ref="in-line-element" minOccurs="0" maxOccurs="unbounded" />[/tt]
 
Amendment-2
Upon re-read what I posted, I now see why type attribute incorrectly appear in the previous amendment. I had incidentally misplace it from the following during editing.
>[self]<xs:element name="in-line-element" abstract="true" />
[tt]<xs:element name="in-line-element" [red]type="xs:string"[/red] abstract="true" />[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top