CS 639 Recursive XML Example  1/30/12

See examples online at www.cs.umb.edu/cs639/validate, or from your Linux shell, $cs639/validate, where $cs639 is set up in your .profile as described in DevelopmentSetup.html

book.xml:
like book1.xml, but without the DOCTYPE, i.e., plain XML

book1.xml:  with DOCTYPE to specify its DTD

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE book SYSTEM "book.dtd">

<book>

  <title>Data on the Web</title>

  <author>Serge Abiteboul</author>

  <author>Peter Buneman</author>

  <author>Dan Suciu</author>

  <section>

    <title>Introduction</title>

    <p>Text ... </p>

    <section>

      <title>Audience</title>

      <p>Text ... </p>

    </section>

    <section>

      <title>Web Data and the Two Cultures</title>

      <p>Text ... </p>

      <figure>

        <title>Traditional client/server architecture</title>

        <image source="csearch.gif"/>

      </figure>

      <p>Text ... </p>

    </section>

  </section>

  <section>

    <title>A Syntax For Data</title>

    <p>Text ... </p>

    <figure>

      <title>Graph representations of structures</title>

      <image source="graphs.gif"/>

    </figure>

    <p>Text ... </p>

    <section>

      <title>Base Types</title>

      <p>Text ... </p>

    </section>

    <section>

      <title>Representing Relational Databases</title>

      <p>Text ... </p>

      <figure>

        <title>Examples of Relations</title>

        <image source="relations.gif"/>

      </figure>

      <p> Conclusion... </p>

    </section>

    <section>

      <title>Representing Object Databases</title>

      <p>Text ... </p>

    </section>

  </section>

</book>


 

 

book.dtd

<!ELEMENT book (title, author+, section*)>

<!ELEMENT title (#PCDATA)>

<!ELEMENT figure (title, image)>

<!ELEMENT image (#PCDATA)>

<!ATTLIST image source CDATA "x.gif">

<!ELEMENT c (#PCDATA)>

<!ELEMENT p (#PCDATA)>

<!ELEMENT author (#PCDATA)>

<!ELEMENT section (title,p,(figure,p)*,section*)>

 

 

book2.xml: same except with specification of XML Schema--

<?xml version="1.0" encoding="ISO-8859-1"?>

<book xsi:noNamespaceSchemaLocation="book.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <title>Data on the Web</title>

  <author>Serge Abiteboul</author>

  <author>Peter Buneman</author>

  <author>Dan Suciu</author>

  <section>

  …

 

book.xsd

<?xml version="1.0"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <xsd:element name="book">

    <xsd:complexType>

      <xsd:sequence>

        <xsd:element name="title" type="xsd:string"/>

        <xsd:element name="author" type="xsd:string" maxOccurs="unbounded"/>

        <xsd:element name="section" type="SectionType" maxOccurs="unbounded"/>

      </xsd:sequence>

    </xsd:complexType>

  </xsd:element>

  <xsd:complexType name="SectionType">

    <xsd:sequence>

       <xsd:element name="title" type="xsd:string"/>

       <xsd:element name="p" type="xsd:string"/>

       <xsd:element name="figure" type="FigureType" minOccurs="0"/>

       <xsd:element name="p" type="xsd:string" minOccurs="0"/>

       <xsd:element name="section" type="SectionType" minOccurs="0" maxOccurs="unbounded"/>

    </xsd:sequence>

  </xsd:complexType>

  <xsd:complexType name="FigureType">

    <xsd:sequence>

       <xsd:element name="title" type="xsd:string"/>

       <xsd:element name="image" type="ImageType"/>

    </xsd:sequence>

  </xsd:complexType>

  <xsd:complexType name="ImageType">

    <xsd:attribute name="source" type="xsd:string"/>

  </xsd:complexType>

</xsd:schema>