Digital Libraries & XML-Relational Data Binding

by Rene Reitsma, Brandon Whitehead, & Venkata Satya Gokul Suryadevara



Listing One



<?xml version="1.0" ?>

<rdf:Description rdf:about="" xmlns:dcterms="http://purl.org/dc/terms/"

        mlns:dc="http://purl.org/dc/elements/1.1/"

        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

    <dc:title xml:lang="en-US">A House is a House for Me</dc:title>

    <dc:creator>TeachEngineering.com</dc:creator>

    <dc:subject>adobe, climate, region, structural design, hut, igloo, lodge,

           pagoda, tepee , treehouse, wigwam</dc:subject>

    <dc:description xml:lang="en-US">Students brainstorm and discuss the

           different types of materials used to build houses in various

           climates. Small models of houses are built and tested against

           different climates.</dc:description>

    <dc:publisher>TeachEngineering.com</dc:publisher>

    <dc:type xsi:type="dcterms:DCMIType">Collection</dc:type>

    <dc:type>Activity</dc:type>

    <dc:format xsi:type="dcterms:IMT">text/xml</dc:format>

    <dc:identifier xsi:type="dcterms:URI">http://www.teachengineering.com/

           collection/wpi_/activities/wpi_a_house_for_me/a_house_for_me.xml<

           /dc:identifier>

    <dc:language xsi:type="dcterms:RFC1766">en-US</dc:language>

    <dc:coverage xsi:type="dcterms:TGN">United States</dc:coverage>

    <dc:rights>TeachEngineering.com</dc:rights>

    <dc:created xsi:type="dcterms:W3CDTF">2004-12-14</dc:created>

    </rdf:Description>





Listing Two



XML2Relational(XMLDocument) {

    String titleData = XMLParse("title", XMLDocument);

    String authorData = XMLParse("author", XMLDocument);

    SQLTransaction("INSERT INTO documentTable VALUES ('" + titleData + "',

         '" + authorData + "')");

}

Listing Three



<?xml version="1.0" encoding="UTF-8">

<activity>

     ...

     <title>A TeachEngineering Activity</title>

     <author>University of Colorado at Boulder</author>

     <pub_year>2004</pub_year>

     ...

     <text_section name="Section 1">

          <text_block>A block of text in section 1.</text_block>

          <text_block>Another block of text in section 1.</text_block>

     </text_section>

     ...

     <text_section name="Section 2">

          <text_block>A block of text in section 2.</text_block>

          <text_block>Another block of text in section 2.</text_block>

     </text_section>

     ...

</activity>





Listing Four



XPathRootHandler ('activity', '/activity')

  XPathExpressionHandler ('title', '/title', 'no', 'string','varchar(200)')

  XPathExpressionHandler ('author', '/author','yes', 'string', 'varchar(100)')

  XPathExpressionHandler ('year', '/pub_year', 'no', 'number', 'int(10)')

  XPathGroupHandler('text_section', '/text_section')

    XPathExpressionHandler ('text_section_name', '/@name',

          'yes', 'string', 'varchar(50)')

    XPathGroupHandler ('text_block', '/text_block')

       XPathExpressionHandler ('text', '', 'yes', 'string', 'text')





Listing Five



/activity[1]/title ("A TeachEngineering Activity")

/activity[1]/author ("University of Colorado at Boulder")

/activity[1]/pub_year (2004)

count(/activity/text_section) (2)

   /activity/text_section[1]/@text_section_title ("Section 1")

   count(/activity/text_section[1]/text_block) (2)

     /activity/text_section[1]/text_block[1] ("A block of text in section 1.")

     /activity/text_section[1]/text_block[2] ("Another block of text

         in section 2.")

   /activity/text_section[2]/@text_section_title ("Section 1")

   count(/activity/text_section[2]/text_block) (2)

     /activity/text_section[2]/text_block[1] ("A block of text in section 1.")

     /activity/text_section[2]/text_block[2] ("Another block of text  in section 2.")



Listing Six



INSERT INTO activity (id, filename, title, author, year)

       VALUES (1, 'activity.xml', 'A TeachEngineering Activity',

      'University of Colorado at Boulder', 2004)

INSERT INTO text_section (id, parentName, parentID, index, text_section_name)

      VALUES (1, 'activity', 1, 1, 'Section 1')

INSERT INTO text_block (id, parentName, parentID, index, text)

      VALUES (1, 'text_section', 1, 1, 'A block of text in section 1.')

INSERT INTO text_block (id, parentName, parentID, index, text)

      VALUES (2, 'text_section', 1, 2, 'Another block of text in section 1.')

INSERT INTO text_section (id, parentName, parentID, index, text_section_name)

      VALUES (2, 'activity', 1, 2, 'Section 2')

INSERT INTO text_block (id, parentName, parentID, index, text)

      VALUES (3, 'text_section', 2, 1, 'A block of text in section 2.')

INSERT INTO text_block (id, parentName, parentID, index, text)

      VALUES (4, 'text_section', 2, 2, 'Another block of text in section 2.')

