Example of combine XML Schema and DTDs?

I noticed that the item "Can I combine XML Schema and DTDs?" of
"XML Schema FAQ" (http://www.schemavalid.com/faq/xml-schema.html#a)
cited Prof. Thompson statement:
"[Henry Thompson] DTD processing and XML Schema processing are
completely independent, hence combinable: just make sure your schema
processor
includes a validating XML parser as its first stage."

I am relatively new in XML and not sure how I can make it work in
Microsoft Visual Studio .NET 2003. For example, if there is a XML file
like this
(horse.xml):

--------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<pets xmlns="http://tempuri.org/horse2.xsd">
    <horse	name="lightening"
			weight="1300"
			birthDate="June 14, 2003">
    </horse>
    <familyHistory>horseFamilyHistory.txt</familyHistory>
    <photo>myHorse.jpg</photo>
</pets>
-----------------------------------------------------------------------------

I can use Visual Studio to automatically generate the following XSD
schema
(horse.xsd):

-----------------------------------------------------------------------------
<?xml version="1.0"?>
<xs:schema id="NewDataSet"
targetNamespace="http://tempuri.org/horse2.xsd"
xmlns:mstns="http://tempuri.org/horse2.xsd"
xmlns="http://tempuri.org/horse2.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:element name="pets">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="familyHistory" type="xs:string" minOccurs="0"
/>
        <xs:element name="photo" type="xs:string" minOccurs="0" />
        <xs:element name="horse" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:attribute name="name" form="unqualified"
type="xs:string" />
            <xs:attribute name="weight" form="unqualified"
type="xs:string" />
            <xs:attribute name="birthDate" form="unqualified"
type="xs:string"
/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:EnforceConstraints="False">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element ref="pets" />
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>
-------------------------------------------------------------------------------

Then, I can modify horse.xsd to set weight's type decimal, etc.

However, since myHorse.jpg is unparsed (non-XML) data, it seems that
it can be best represented using DTD's unparsed external entities.
Also, horseFamilyHistory.txt is a big, external, ACSII file.

Question 1: Currently, is it possible to handle both myHorse.jpg and
horseFamilyHistory.txt using "pure" XSD schema?

Question 2: If yes, how to do it?

Question 3: If not, how to combine the XSD schema with DTD?


Question 4: How to perform XML validation of the above (modified) XML
using, say, C# within Microsoft Visual Studio .NET?

Your kind help would be greatly appreciated.
Bill

Received on Wednesday, 23 November 2005 01:07:53 UTC