Hello All,
If anyone has any experience with XML Schema's I have a question for you.
I wrote this XML:
Code:
<?xml version="1.0"?>
<content xmlns="http://www.michaelsica.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.michaelsica.com content.xsd">
<meta>
<title>The Title</title>
<author>Michael Sica</author>
<date>2003-05-23</date>
</meta>
<item>
<para id="1">
Here is the first paragraph.
It contains a
<link address="http://www.google.com" title="Search
Engine">link</link> in the second sentence.
</para>
<para id="2">
Here is the second paragraph.
<image align="right">
http://www.google.com/images/logo.gif</image>
It has an image in it. Aligned to the right.
</para>
<para id="3">
Here is the third paragraph. It has both a
<link address="">link</link> and an
<image align="left">http://www.google.com/images/logo.gif</image>
image in it. But this image is aligned to the left.
</para>
</item>
</content>
And I have been trying to write a schema for it. I run into trouble with the "para" tags because they are an element that contians other elements and character data. Here is the schema I wrote...
Code:
<?xml version="1.0"?>
<xs:schema targetNamespace="http://www.michaelsica.com"
xmlns="http://www.michaelsica.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="content">
<xs:complexType>
<xs:sequence>
<xs:element name="meta">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="date" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="item">
<xs:complexType>
<xs:sequence>
<xs:element name="para" minOccurs="0" maxOccurs="unbounded">
<xs:complexType mixed="true">
<xs:sequence>
<xs:any/>
</xs:sequence>
<xs:attribute name="id" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I've tried using a couple of software packages (free trial of XMLSpy and a few others) and they all give me a warning that the "link" tag is used but not declared.
Is this ok or do I have to do more?
I tried using the following,
Code:
<xs:element name="link" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="address" type="xs:anyURI"/>
<xs:attribute name="title" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="image" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attribute name="align" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
But if I put this inside an <xs:all> tag set then I can't have more than 1 occurence of the tags inside the "para" tag.
Have I completly missed something?
Thanks for any help,
-michael.