15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

School of Engineering <strong>&amp</strong>; <strong>Science</strong><br />

. . .<br />

. . .<br />

<br />

<br />

XML Documents as Trees<br />

Idea: An XML Document is a Tree<br />

<br />

<br />

The number<br />

<br />

<br />

<br />

is irrational.<br />

<br />

<br />

c○: Michael Kohlhase 392<br />

xml:id foo<br />

xml:lang en<br />

text<br />

The number<br />

name pi<br />

omtext<br />

CMP<br />

om:OMOBJ<br />

om:OMS<br />

cd nums1<br />

xmlns . . .<br />

xmlns:om . . .<br />

text<br />

is irrational.<br />

Definition 588 The XML document tree is made up of element nodes, attribute nodes,<br />

text nodes (and namespace declarations, comments,. . . )<br />

Definition 589 For communication this tree is serialized into a balanced bracketing structure,<br />

where<br />

an element el is represented by the brackets (called the opening tag) and <br />

(called the closing tag).<br />

The leaves of the tree are represented by empty elements (serialized as , which<br />

can be abbreviated as <br />

and text nodes (serialized as a sequence of UniCode characters).<br />

An element node can be annotated by further information using attribute nodes — serialized<br />

as an attribute in its opening tag<br />

Note: As a document is a tree, the XML specification mandates that there must be a unique<br />

document root.<br />

The Document Object Model<br />

c○: Michael Kohlhase 393<br />

Definition 590 The document object model (DOM) is a data structure for storing documents<br />

as marked-up documents as document trees together with a standardized set of access<br />

methods for manipulating them.<br />

c○: Michael Kohlhase 394<br />

One of the great advantages of viewing marked-up documents as trees is that we can describe<br />

subsets of its nodes.<br />

XPath, A Language for talking about XML Tree Fragments<br />

225

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!