Download presentation
Presentation is loading. Please wait.
1
1 XML and Data Management XML Processors Hachim Haddouti Al Akhawayn University SSE H.Haddouti@alakhawayn.ma http://mail.alakhawayn.ma/~H.Haddouti
2
H. Haddouti 2 TOC Intro SAX – event oriented processing DOM – Tree Structure Use of DOM and SAX Implementations Literatur
3
H. Haddouti 3 XML Prozessors n To make the content of an XML Document available for an application n Standardized Interfaces for several programming languages (Java, Phyton, C, C++,...) n Embedding of libraries n Expansion of Entities n Non validated / validated processors in relation to DTD or XML Schema
4
H. Haddouti 4 SAX – event-oriented Processing actions are caused by components of the document sequential processing stateless startDocument() <hotel id= Warnemünde endElement("ort") endElement("adresse") 0381/548230 Strand Hotel Hübner endElement("hotelname") characters(char[], start, length) endElement("hotel") endDocument()... startElement("adresse", null) startElement("ort", null) startElement("hotel", AttributeList( startElement("hotelname", null) length=1, {name= value=
5
H. Haddouti 5 DOM - Manipulation of Tree W3C Recommendation describe interfaces to the access to XML Documents and to the change of structure and contents it is not defined the underlying implementation and storage of the XML- Dokumente!
6
H. Haddouti 6 Methods Class: Node n All of document components are based on this class n The class contains –Methods to identify the node types –Methods to navigate thru document structure –Methods to manipualte document structure
7
H. Haddouti 7 DOM (Document Object Model) – Navigation thru Document XML Document as Tree Access only by navigation update of the document structure also possible 1 65 4 32 Starting from this node The following methods of class node Provide nodes or node list as result: 6 - getNextSibling() 4 - getChildren() 3 - getLastChild() 2 - getFirstChild() 1 - getParentNode() 5 - getPreviousSibling()
8
H. Haddouti 8 DOM – Manipulation of the Structure Delete, add, change etc. document components insertBefore (newChild, refChild) refChild appendChild (newChild) newChild refChild oldChild newChild removeChild (oldChild) oldChild replaceChild (newChild, oldChild)
9
H. Haddouti 9 Interface NodeList n The Calss NodeList allows processing node list. n Methods of NodeList Interfaces are: –item(index) to access a single node, the index start with 0. –getLength() provides the number of nodes in list.
10
H. Haddouti 10 Interface NamedNodeMap n Methods of NamedNodeMap: –getLength() – number of nodes in list –item(index) – access singles nodes in list –getNamedItem(name) and –removeNamedItem(name) read and delete of an element node resp.
11
H. Haddouti 11 Class: Element n The following methods allow reading and updating the information store din Element. –getTagName() Tag name of an element –getAttribute(name) –setAttribute(name, value) update an attribute –removeAttribute(name) delete an attribute –getElementsByTagName(tagname) –getElementsByTagName(*) return all elements.
12
H. Haddouti 12 Method of Class Attribute n Using these methods to get information about attributes: –getName() –getValue() –setValue(value).
13
H. Haddouti 13 Methods of Class Character Data n Read, Set and Update of text components n Methods of Character Data are: –getLength() length of text component –getData() whole text –substringData(start,count) subset of text, which begins with Start and goes for the specified length –appendData(text) –replaceData(offset,count,text) –insertData(offset,text) –deleteData(offset,count)
14
H. Haddouti 14 DOM vs. SAX nach Roland Böndgen DOM Parser SAX DTD XML- Document startDocument startElement endElement endDocument... Anwendung, implemen- tiert Document Handler
15
H. Haddouti 15 Use of SAX and DOM SAX n simple access n for simple structured and equaly structured Documents n suitable for large XML- Documents n Access to few parts of a documents DOM n Navigation thru Document structure n therefore context dependent access n Manipulation of the structure n not well suitable for very large XML Documents n
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.