160 likes | 168 Views
Learn how to draw XML tree diagrams, create XML documents, and develop valid DTDs with step-by-step exercises in this comprehensive tutorial.
E N D
Tutorial 5 XML
Contents • XML Exercises • Question 1: Tree Representation • Question 2: Create XML Document • Question 3: Create a DTD
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>
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’
Question 2: Create XML Documents • Create a serialized (XML) document representation of the following XML Tree:
Question 2: Create XML Documents XML: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Pro PUBLIC "ProjectID" "Pro.dtd" > <CompanyProjects> </CompanyProjects>
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>
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>
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>
Question 3: Create a DTD • Create a valid DTD document for the following XML Tree:
Question 3: Create a DTD DTD: <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT CompanyProjects (Project*)> <!ELEMENT Project (Name?, Number?, Location?, Worker*)>
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)>
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)>
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