1 / 16

Tutorial 5

Tutorial 5. XML. Contents. XML Exercises Question 1: Tree Representation Question 2: Create XML Document Question 3: Create a DTD. XML Exercises. Question 1: Tree Representation. Draw a Tree Diagram of the following XML Document: < dblp >

mmahon
Download Presentation

Tutorial 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tutorial 5 XML

  2. Contents • XML Exercises • Question 1: Tree Representation • Question 2: Create XML Document • Question 3: Create a DTD

  3. XML Exercises

  4. Question 1: Tree Representation • Draw a Tree Diagram of the following XML Document: <dblp> <inproceedings key="conf/adbis/DarcySS11" mdate="2011-09-14"> <author>Peter Darcy</author> <author>BelaStantic</author> <author>Abdul Sattar</author> <title> A Novel Integrated Classifier for Handling Data Warehouse Anomalies </title> <pages>98-110</pages> <year>2011</year> <booktitle>ADBIS</booktitle> <ee>http://dx.doi.org/10.1007/978-3-642-23737-9_8</ee> <crossref>conf/adbis/2011</crossref> <url>db/conf/adbis/adbis2011.html#DarcySS11</url> </inproceedings> </dblp>

  5. Question 1: Tree Representation dblp inproceedings author author author url ‘db/conf/adbis/adbis2011.html#DarcySS11’ ‘Abdul Sattar’ ‘Peter Darcy’ ‘Bela Stantic’ pages title ‘98-110’ crossref ‘A Novel Integrated Classifier for Handling Data Warehouse Anomalies’ year ‘conf/adbis/2011’ ‘2011’ booktitle ‘ADBIS’ ee ‘http://dx.doi.org/10.1007/978-3-642-23737-9_8’

  6. Question 2: Create XML Documents • Create a serialized (XML) document representation of the following XML Tree:

  7. Question 2: Create XML Documents XML: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Pro PUBLIC "ProjectID" "Pro.dtd" > <CompanyProjects> </CompanyProjects>

  8. Question 2: Create XML Documents XML: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Pro PUBLIC "ProjectID" "Pro.dtd" > <CompanyProjects> <Project> </Project> <Project> </Project> </CompanyProjects>

  9. Question 2: Create XML Documents XML: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Pro PUBLIC "ProjectID" "Pro.dtd" > <CompanyProjects> <Project> <Name>Product X</Name> <Number>1</Number> <Location>Ballaire</Location> <Worker> </Worker> <Worker> </Worker> </Project> <Project> </Project> </CompanyProjects>

  10. Question 2: Create XML Documents XML: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Pro PUBLIC "ProjectID" "Pro.dtd" > <CompanyProjects> <Project> <Name>Product X</Name> <Number>1</Number> <Location>Ballaire</Location> <Worker> <Ssn>123456789</Ssn> <Last_Name>Smith</Last_Name> <Hours>32.5</Hours> </Worker> <Worker> <Ssn>435435435</Ssn> <First_Name>Joyce</First_Name> <Hours>20.0</Hours> </Worker> </Project> <Project> </Project> </CompanyProjects>

  11. Question 3: Create a DTD • Create a valid DTD document for the following XML Tree:

  12. Question 3: Create a DTD DTD: <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT CompanyProjects (Project*)> <!ELEMENT Project (Name?, Number?, Location?, Worker*)>

  13. Question 3: Create a DTD DTD: <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT CompanyProjects (Project*)> <!ELEMENT Project (Name?, Number?, Location?, Worker*)> <!ELEMENT Name (#PCDATA)> <!ELEMENT Number (#PCDATA)> <!ELEMENT Location (#PCDATA)> <!ELEMENT Worker (Ssn, Last_Name?, First_Name?, Hours)>

  14. Question 3: Create a DTD DTD: <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT CompanyProjects (Project*)> <!ELEMENT Project (Name?, Number?, Location?, Worker*)> <!ELEMENT Name (#PCDATA)> <!ELEMENT Number (#PCDATA)> <!ELEMENT Location (#PCDATA)> <!ELEMENT Worker (Ssn, Last_Name?, First_Name?, Hours)> <!ELEMENT Ssn (#PCDATA)> <!ELEMENT Last_Name (#PCDATA)> <!ELEMENT First_Name (#PCDATA)> <!ELEMENT Hours (#PCDATA)>

  15. Question 3: Create a DTD --Note: There are no attributes but I could show them some attributes, for examples: <!ATTLIST element_nameattribute_nameattribute_typedefault_value> <!ATTLIST Project startTime CDATA #REQUIRED> <!ATTLIST Worker gender CDATA> --Element allowable_contents (#PCDATA) can also be EMPTY, ANY, Children elements or MIXED CONTENT (#PCDATA with Children) --#REQUIRED can be #IMPLIED or #FIXED --CData = Character Data --PCData = Passed Character Data

  16. Questions?

More Related