No xml is ordered 4 31113 cs480 principles of

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ent email 3123453 <state id = “s2”> <scode> NE </scode> <sname> Nevada </sname> </sname> <city id = “c2”> <ccode> CCN</ccode> <cname> Carson City </cname> <state-of idref=“s2”/> </city> person name Spring 2013   Represen�ng graph data phone “Alan” CS480 Principles of Data Management Using references in XML person name Spring 2013 XML Graph Model Difficulties in reconciling XML and ssd           CS480 Principles of Data Management agg@abc.com –  In the SSD graph?   Allow us to build representa�ons of cyclic/recursive data structures CS480 Principles of Data Management Spring 2013 CS480 Principles of Data Management Order Person:{firstname:”John”, lastname:”Smith”} Person:{lastname:”Smith”,”firstname:”John”}   Are these the same data in SSD? –  Yes. –  SSD model is an unordered collec�on Spring 2013 Order <person> <firstname>John <firstname/> <lastname> Smith<lastname/> </person> <person> <lastname> Smith</lastname> <firstname> John </firstname> </person>   Are these same data in XML? –  No. –  XML is ordered. 4 3/11/13 CS480 Principles of Data Management Spring 2013 CS480 Principles of Data Management   Interpret the structure of XML document Spring 2013 Document Object Model (DOM parser) Parsing XML document with APIs   API for XML documents –  Document Object Model (DOM) –  Simple API for XML (SAX) –  Streaming Model (Pull parsing)   Provides an object-­‐oriented view of the XML document –  Each document component defines an interface specifying its behavior –  Data can be access only via interface –  Tree with nodes represen�ng contents in the document –  org.w3c.dom.Node   Subinterfaces –  A�r, CDATASec�on, CharacterData, Comment, Element, Document, Text   Memory intensive   En�re document loaded in the memory CS480 Principles of Data Management Spring 2013 CS480 Principles of Data Management Simple API for XML (SAX)         Spring 2013 SAX parser example Detects parsing events Directly reports to the applica�on (callback) Does not maintain an internal tree Drawbacks SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = factory.newSAXParser(); public void startElement(String uri, String localName,String qName, Attributes attributes) throws SAXException { � �System.out.println("Start Element :" + qName); � �if (qName.equalsIgnoreCase("FIRSTNAME")) {� �bfname = true;� �} � �if (qName.equalsIgnoreCase("LASTNAME")) {� �blname = true;� �} � �if (qName.equalsIgnoreCase("NICKNAME")) {� �bnname = true;� �}� .� .� –  Valida�on is not possible   Cannot a...
View Full Document

This note was uploaded on 02/11/2014 for the course CS 480 taught by Professor Staff during the Spring '08 term at Colorado State.

Ask a homework question - tutors are online