Recommendations:
Tutorials and hints:
See examples in XML02.zip. They show definition of the same document model written in several different ways. Note the differences in:
Try out validating the example document against different schemas (note the xsi:noNamespaceSchemaLocation
attribute).
Starting from students05 or higher, add definitions of new structures to the schema.
room
element – it has an identification number, number of seats, equipment (projector, blackboard, etc.)meeting
element – each one has the following information specified: room, day of week, start-end hours.Text mixed with embedded elements is called a mixed content. It is typical to text-oriented applications of XML, e.g. XHTML.
Defining mixed content in XML Schema is very easy – we only need to set attribute mixed="true"
in a complex type definition.
It allows any text within an element mixed with element content defined by this complex type.
In order to reflect DTD-like definitions of complex content, which allow any number and order of subelements within mixed content, we have to describe something like choice*
Mixed content definition in DTD (the only allowed form):
<!ELEMENT p (#PCDATA | b | i)*>
The same definition in XML Schema:
<xs:complexType name="TextContent" mixed="true"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="b"/> <xs:element ref="i"/> </xs:choice> </xs:complexType>
In Schema we can control the order and number of subelements (which is rarely used, in fact):
<xs:complexType name="LetterBody" mixed="true"> <xs:sequence> <xs:element name="greeting" type="xs:string"/> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="important" type="xs:string"/> <xs:element name="quotation" type="xs:string"/> </xs:choice> <xs:element name="signature" type="xs:string"/> <xs:element name="postscriptum" type="xs:string" minOccurs="0" maxOccurs="3"/> </xs:sequence> </xs:complexType>
Allow embedded tags in text descriptions of lectures, as in the following fragment.
<description>Defining structure of XML documents (defining <term>XML applications</term>): DTD, <link href="http://www.w3.org/TR/xmlschema-0">XML Schema</link>, <link href="http://relaxng.org">Relax NG</link>.</description>
Specify elements which have the following role:
link
– hyperlink to location specified in href
attributeterm
– a term / name / keywordstrong
– strong emphasiscode
– code fragmentAllow the same type of content in item
elements of lecture program.
Allow the elements to be embedded.
Prepare an example document (or a fragment) related to your assessment project.
Start defining your schema and validating document fragments you have.