Notizen
Bildschirmpräsentation
Gliederung
1
The Document Object Model (DOM)
  • And its Role for Application Development
2
Overview
  • The need for a Document Object Model
  • Brief explanation of the DOM model
  • DOM and the system architecture
  • Pros and Cons of the DOM model
  • Decision Criteria
3
Application Development
  • Broad view
    • Product definition
    • Specifications …
    • Implementation
    • Product Life Cycle
  • Narrow view
    • Application Implementation
    • Software Engineering Part
    • Source Code Generation
  • Product Definition
  • Product Requirements
  • Application Specification
    • System Design
    • System Architecture
    • System Definition
    • Functional Specification
  • Implementation
  • Maintenance
4
Justifying Document Model Standards
  • Pre SGML era
    • WinWord, RTF, AmiPro, MIF, Ventura Publisher,  …
    • Hard to reuse for developers
    • Converter writing was/is an “art” – lack of documentation, proprietary interfaces
  • SGML/XML era:
    • (X)HTML, DHTML, XML
    • Support for scripting languages in dynamic web pages
    • Document generation / production / publishing
    • XML standards
      • Science - Math XML, Astronomy …
      • Publishing, technical documentation, DocBook
      • Translation
    • Data centric vs document centric XML
    • Information exchange/control in and between applications
      • Application control through ini/properties File
  • Internet
    •  – http - enabled applications
    • XML-RPC
    • WebDAV
    • SOAP, UDDI, OWL, WSDL, RDF …
    • Tomcat - servlets

5
Restricting … What is DOM?
  • Acronym: “Document Object Model”
    • „The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents. ...“
    • The Document Object Model (DOM) is an application programming interface (API) for valid HTML and well-formed XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.
    • W3C - http://www.w3.org/DOM/
  • Initially as tool for modeling for DHTML in browsers
  • Several Levels
    • 1 – 3
    • Current Working Draft: DOM Level 3
6
What does DOM provide?
  • The DOM kernel is a set of APIs (definitions)
    • Not an implementation
    • Defined using IDL (OMG)
    • Different programming languages need to realize those API definitions
  • Provides an object-based interface
    • Tree based
    • In contrast to an event-based ones like SAX (Simple API for XML)
  • DOM interface is specified in several modules
    • Core, XML, HTML …
  • Suppliers may support only some modules
    • This is important when choosing a specific implementation!
7
DOM Levels 1-3
8
DOM Model Implementation
  • Represents the XML document as a tree based data structure
  • One step parsing
  • Whole XML document is kept in main memory
  • Allows “(randomly) accessing/manipulating” of XML documents
    • In contrast to other models like SAX
  • Parser realizes the DOM model for applications


9
Application examples using DOM
  • Editors
    • Tools which edit XML documents
  • Web Browsers
    • IE, Netscape …
  • Publishing Tools
  • Internet enabled applications
    • WebDAV, SOAP
  • Servlet Engines
    • Tomcat …
  • Configuration Management
    • Eclipse
  • GUI Building
    • GNOME project


10
XML Application Integration
  • XML logic is part of the application logic
11
DOM and Application Integration
  • XML logic is separated using a DOM parser and API methods from the application logic
12
Pros and Cons
  • Standard
  • No need to write own parser and complex data structures to hold the xml data
  • Easy to implement
  • Several alternative implementations available for different programming languages
  • Immediate access to different parts of the document
    • Read / write support
  • Memory Usage
    • High
    • “deferred DOM”
  • Computational efficiency
    • Low
  • Persistence needs to be handled manually
    • Use of db’s like eXist, Xindice, Tamino
    • Level 3 ?

13
Decision Criteria - XML
  • Dealing mainly with document or data centric XML objects?
    • Address book, databases vs. technical documentation, articles, books
    • Ideal for document centric applications
      • Browsers, editors
    • Document size; > 10 MB??
  • Complex DTD / XML data?
    • For simple restricted data centric XML use SAX, JDOM, regular expressions …
  • Mixed content support
  • Support of XML Schema required?
14
Decision Criteria – Access Functionality
  • Direct access to the various document parts needed?
    • Choose DOM
    • Random access to all document elements
  • For sequential access SAX is more efficient
  • Manipulating XML document?
    • Use DOM
    • Supports creating / changing content
15
Decision Criteria – Document Size
  • Intended document size supported?
    • May require tests
    • Dependency on main memory available
    • Server / client architecture?
    • “deferred DOM”
    • PDOM as a commercial alternative (Infonyte)
  • Necessity to handle huge documents or several documents at a time?
    • May require a lot of memory if several documents are loaded at the same time
    • Example: Diff’s between several documents
16
Decision Criteria – Persistence
  • How is the DOM object serialized?
  • Approaches
    • DOM Level 3
    • Simple file
    • DB APIs
    • XML databases
      • Xindice
      • eXist
      • Tamino
      • Relational databases …
17
Decision Criteria - Language Support
  • Availability for several programming languages
    • Strength of DOM
    • Xerces: Java, C++, Perl
  • Java Script
    • Through browsers – mostly built-in
  • Java
    • Many Open Source projects
  • C++, C
  • Perl
  • Visual Basic
  • …
18
Decision Criteria – Implementation Phase
  • DOM is popular for scripting languages
    • JavaScript, web sites
    • built-in
  • Performance
    • DOM is not as memory / time efficient as SAX
19
Decision Criteria – DOM Level Support
  • Which parser is used?
  • Which level and modules are supported by a specific parser?
20
Summary: Why to use the DOM Model
  • Intuitive (tree based) standard model for document centric applications
    • Object oriented representation
  • Makes writing re-usable / multi-usable documents for application writing a reality
  • Simple way to access XML document structures
    • Writing own parsers is complex
    • Basic document model and access functions
  • Based on a Component Approach
    • Simply exchange the DOM parsers
  • Internet enabled applications
    • Implicitly in
  • Greatly simplifies writing XML based applications