Document%20Object%20Model%20(DOM):%20%20An%20Abstract%20Data%20Structure%20for%20XML%20data - PowerPoint PPT Presentation

About This Presentation
Title:

Document%20Object%20Model%20(DOM):%20%20An%20Abstract%20Data%20Structure%20for%20XML%20data

Description:

Insertion of nodes in into the DOM Tree. Traversal of the DOM Tree. DOM Type Structure ... Node cloneNode(in boolean deep) DOM Type Structure. interface Node ... – PowerPoint PPT presentation

Number of Views:72
Avg rating:3.0/5.0
Slides: 27
Provided by: a15344
Category:

less

Transcript and Presenter's Notes

Title: Document%20Object%20Model%20(DOM):%20%20An%20Abstract%20Data%20Structure%20for%20XML%20data


1
Document Object Model (DOM) An Abstract Data
Structure for XML data
  • Alex Dekhtyar

Department of Computer Science University of
Kentucky
2
About
  • Jobs for B.S. graduates often require work with
    XML
  • Teach XML in undergraduate curriculum
  • Databases
  • Web Programming
  • Data Structures

3
Outline
  • XML Syntax
  • XML as a tree
  • Document Object Model (DOM)
  • DOM API

4
XML
ltfacultygt ltnamegt ltfirstgt
lt/firstgt ltmiddlegt
lt/middlegt ltlastgt
lt/lastgt lt/namegt ltdeptgt
lt/deptgt ltcoursegt ltsemgt
lt/semgt ltcodegt
lt/codegt lttitlegt

lt/titlegt lt/coursegt lt/facultygt
Meta-language for encoding information
Alexander M.
Dekhtyar Computer Science Spring 2007
CS405 Database systems
Information, content
XML elements
Opening tags ltnamegt Closing tags ltname/gt Emply
elements ltp/gt
ordered
5
XML
ltfaculty id 27 gt ltname
originUkrainegt ltfirstgt
lt/firstgt ltmiddlegt
lt/middlegt ltlastgt
lt/lastgt lt/namegt ltdeptgt
lt/deptgt ltcoursegt ltsemgt
lt/semgt ltcodegt
lt/codegt lttitlegt

lt/titlegt lt/coursegt lt/facultygt
Meta-language for encoding information
Alexander M.
Dekhtyar Computer Science Spring 2007
CS405 Database systems
Information, content
XML elements
Opening tags ltnamegt Closing tags ltname/gt Emply
elements ltp/gt
ordered
Attributes
Additional information unordered
6
XML
ltfaculty id 27 gt ltname
originUkrainegt ltfirstgt
lt/firstgt ltmiddlegt
lt/middlegt ltlastgt
lt/lastgt lt/namegt ltdeptgt
lt/deptgt ltcoursegt ltsemgt
lt/semgt ltcodegt
lt/codegt lttitlegt

lt/titlegt lt/coursegt lt/facultygt
  • Structure
  • nested elements
  • Well-formed XML
  • correctly nested elements
  • World Wide Web Consortium (W3C)
  • recommendation
  • XML 1.0, 1998

Alexander M.
Dekhtyar Computer Science Spring 2007
CS405 Database systems
7
XML and applications
Parser
data
8
XML and applications
Parser
data
application
9
XML and applications
Document Object Model (DOM)
  • W3C standard
  • www.w3c.org/DOM

API
DOM Level 1 (core) for XML DOME Level 1 (HTML)
for HTML
10
Trees for XML
faculty
dept
name
course
11
Trees for XML
faculty
Id27
name
dept
course
title
code
sem
first
middle
last
Computer Science
Database Systems
Alexander
M.
Dekhtyar
Spring 2007
CS 405
originUkraine
12
Trees for XML
- Root node
- Element node
faculty
name
Computer Science
- Text node
Id27
- Attribute node
13
Document Object Model
  • Abstract Data Type
  • Object-oriented
  • System of types/interfaces
  • Attributes
  • Methods

14
Functionality
Creation of nodes
Insertion of nodes in into the DOM Tree
Traversal of the DOM Tree
15
DOM Type Structure
interface NodeList
list of
interface Node
interface Document
subtype
interface NamedNodeMap
interface Element
set of
interface Attr
interface DocumentType
interface Comment
interface Text
interface DocumentType
interface CDATASection
and a few more
16
interface Node
document
faculty
DOMString nodeName DOMString nodeValue short
nodeType Node parentNode NodeList childNodes
Node firstChild Node lastChild Node
previousSibling Node nextSibling NamedNodeMap
attributes Document ownerDocument
name
dept
middle
first
originUkraine
17
Node Types
nodeName
nodeValue
nodeType
interface Node
9 1 2 10 8 3 6 4
interface Document
subtype
interface Element
Tag null
interface Attr
AttName AttValue
interface DocumentType
interface Comment
text content
interface Text
interface Entity
interface CDATASection
and a few more
(12 nodetypes altogether)
18
interface Node methods
Node insertBefore(in Node newChild, in Node
refChild) Node replaceChild(in Node newChild, in
Node oldChild) Node removeChild(in Node
oldChild) Node appendChild(in Node newChild)
boolean hasChildNodes() Node cloneNode(in
boolean deep)
19
DOM Type Structure
interface NodeList
list of
interface Node
interface Document
subtype
interface NamedNodeMap
interface Element
set of
interface Attr
interface DocumentType
interface Comment
interface Text
interface DocumentType
interface CDATASection
and a few more
20
interface Document
document
doctype
Attributes
root
DTD
ltagt
ltagt
ltagt
ltagt
Methods
Element createElement(in DOMString
tagName) DocumentFragment createDocumentFragment()
Text createTextNode(in DOMString
data) Comment createComment(in DOMString
data) CDATASection createCDATASection(in
DOMString data) Attr
createAttribute(in DOMString name) NodeList
getElementsByTagName(in DOMString tagname)
21
DOM Type Structure
interface NodeList
list of
interface Node
interface Document
subtype
interface NamedNodeMap
interface Element
set of
interface Attr
interface DocumentType
interface Comment
interface Text
interface DocumentType
interface CDATASection
and a few more
22
interface Element
interface Element Node DOMString tagName
DOMString getAttribute(in DOMString name)
void setAttribute(in DOMString name, in
DOMString value) void removeAttribute(in
DOMString name) Attr getAttributeNode(in
DOMString name) Attr setAttributeNode(in Attr
newAttr) Attr removeAttributeNode(in Attr
oldAttr) NodeList getElementsByTagName(in
DOMString name)
Attribute management
23
DOM Type Structure
interface NodeList
list of
interface Node
interface Document
subtype
interface NamedNodeMap
interface Element
set of
interface Attr
interface DocumentType
interface Comment
interface Text
interface DocumentType
interface CDATASection
and a few more
24
DOM Type Structure
interface NodeList
list of
interface Node
interface Document
subtype
interface NamedNodeMap
interface Element
set of
interface Attr
interface DocumentType
interface Comment
interface Text
interface DocumentType
interface CDATASection
and a few more
25
interface NodeList
interface NodeList Node item(in unsigned
long index) unsigned long length
interface NamedNodeMap
interface NamedNodeMap Node getNamedItem(in
DOMString name) Node setNamedItem(in Node
arg) Node removeNamedItem(in DOMString name)
Node item(in unsigned long index)
unsigned long length
26
Next
Implementations of DOM interfaces
1. Using pointers
3. Wrappers over legacy implementations
Write a Comment
User Comments (0)
About PowerShow.com