Você está na página 1de 53

eXtensible Markup Language

Lecturer: Phan Vo Minh Thang MSc.


eXtensible Markup Language
Document Object Model 1.0
<?xml version=1.0>
<course startdate=February 06, 2006>
<title> eXtensible Markup Language </title>
<lecturer>Phan Vo Minh Thang</lecturer>
</course>
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
A Piece of XML
<seq id="my_seq" name="NUCLEAR RIBONUCLEOPROTEIN">
<dbxref>
<database>SWISS-PROT</database>
<unique_id>P09651</unique_id>
</dbxref>
<residues type="aa">
SKSESPKEPEQLRKLFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNTKRS
RGFGFVTYATVEEVDAAMNARPHKVDGRVVEPKRAVSREDSQRPGAHLTVKKI
FVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFDDHDSVD
KIVIQKYHTVNGHNCEVRKALSKQEMASASSSQRGRSGSGNFGGGRGGGFGGN
DNFGRGGNFSGRGGFGGSRGGGGYGGSGDGYNGFGNDGGYGGGGPGYSGGSRG
YGSGGQGYGNQGSGYGGSGSYDSYNNGGGRGFGGGSGSNFGGGGSYNDFGNYN
NQSSNFGPMKGGNFGGRSSGPYGGGGQYFAKPRNQGGYGGSSSSSSYGSGRRF
</residues>
</seq>
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
An XML DTD
<?xml version='1.0' encoding="US-ASCII"?>
<!DOCTYPE biosequence [
<!ELEMENT seq (dbxref*, residues?) >
<!ATTLIST seq id ID #REQUIRED
name CDATA #IMPLIED
length CDATA #IMPLIED >
<!ELEMENT residues (#PCDATA)>
<!ATTLIST residues type (dna | rna | aa) #REQUIRED>
]>
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Using a XML Parser
Three basic steps to using an XML parser
Create a parser object
Pass your XML document to the parser
Process the results
Generally, writing out XML is outside scope of parsers
(though some may implement proprietary mechanisms)
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Types of Parser
There are several different ways to categorise parsers:
Validating versus non-validating parsers
Parsers that support the Document Object Model (DOM)
Parsers that support the Simple API for XML (SAX)
Parsers written in a particular language (Java, C++, Perl, etc.)
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Non-validating Parsers
Speed and efficiency
It takes a significant amount of effort for an XML parser to process
a DTD and make sure that every element in an XML document
follows the rules of the DTD.
If only want to find tags and extract information - use non-
validating
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Structure of XML
Logical Structure
Elements
Physical Structure
Entities
Document
Unit
Sub-unit
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
XML Hierarchy
Document
Unit
Sub-unit
Document
Unit
Sub-unit
N.B. All elements must be nested
XML can be described in a
tree hierarchy
Parent
Child
Sibling
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Parsing XML
Two established API's
SAX (Simple API for XML)
Define handlers containing methods as XML parsed
DOM (Document Object Model)
Defines a logical tree representing the parsed XML
Apps that don't require complex manipulation can use
SAX
Apps that need structural manipulations of many XML
tokens should use DOM
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
DOM
Document Object Model
Set of interfaces for an application that
reads an XML file into memory and stores it
as a tree structure
The abstract API allows for constructing,
accessing and manipulating the structure
and content of XML and HTML documents
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Advantages of DOM
When you parse an XML document
with a DOM parser, you get back a
tree structure that contains all of the
elements of your document
The DOM provides a variety of
functions you can use to examine the
contents and structure of the
document
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Why use the DOM?
Task of writing parsers is reduced to coding against an
API for the document structure
Domain-specific frameworks will be written on top of DOM
Tag data in XML - Code against DOM interfaces to access
application data
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
DOM versus SAX
If your document is very large and
you only need a few elements -
use SAX
If you need to process many
elements and perform operations
on XML - use DOM
If you need to access the XML
many times - use DOM
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
DOM Standard
DOM 1.0 standard from www.w3.org
Assumes an object-oriented approach
Composed of number of interfaces
org.w3c.dom.*
Central class is 'Document' (DOM tree)
Standard does not include
Tree walking
Writing out XML format
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Creating a DOM Tree
A DOM implementation will have a method to pass a XML
file to a factory object that will return a Document object
that represents root element of whole document
After this, may use DOM standard interface to interact with
XML structure
DOM Parser DOM Tree XML File
A
P
I
Application
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Creating a DOM Tree (2)
import org.w3c.dom.*; //DOM interfaces
import com.sun.xml.tree.*; //Using Sun classes
import org.xml.sax.*; //Need SAX classes
public class myClass {

Document myDoc; //Document object


try {
//if 'true' -> validate
myDoc =
XmlDocument.createXmlDocument("file:/doc.xml", true);
} catch (IOException err) {}
catch (SAXException err) {}
catch (DOMException err) {}
//If no exceptions, should have a 'Document' object
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
DOM Interfaces and Classes
DocumentFragment
Document
CharacterData
Text
Comment
CDATASection
Attr
Element
DocumentType
Notation
Entity
EntityReference
ProcessingInstruction
Node
NodeList
NamedNodeMap
DocumentType
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
DOM Interfaces
The DOM defines several Java interfaces
Node The base data type of the DOM
ElementRepresents element
Attr Represents an attribute of an element
Text The content of an element or attribute
Document Represents the entire XML
document. A Document object is
often referred to as a DOM tree
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Node Interface
Basic object of DOM (single node in tree)
Nodes describe
Node collections
NodeList, NamedNodeMap, DocumentFragment
Several nodes extend the Node interface
Elements
Attributes
Text
Comments
CDATA sections
Entity declarations
Entity references
Notation declarations
Entire documents
Processing instructions
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Node Methods
Three categories of methods
Node characteristics
name, type, value
Contextual location and access to relatives
parents, siblings, children, ancestors, descendants
Node modification
Edit, delete, re-arrange child nodes
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Node Methods (2)
short getNodeType();
String getNodeName();
String getNodeValue() throws DOMException;
void setNodeValue(String value) throws DOMException;
boolean hasChildNodes();
NamedNodeMap getAttributes();
Document getOwnerDocument();
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Node Types - getNodeType()
ELEMENT_NODE = 1
ATTRIBUTE_NODE = 2
TEXT_NODE = 3
CDATA_SECTION_NODE = 4
ENTITY_REFERENCE_NODE = 5
ENTITY_NODE = 6
PROCESSING_INSTRUCTION_NODE = 7
COMMENT_NODE = 8
DOCUMENT_NODE = 9
DOCUMENT_TYPE_NODE = 10
DOCUMENT_FRAGMENT_NODE = 11
NOTATION_NODE = 12
if (myNode.getNodeType() == Node.ELEMENT_NODE) {
//process node

}
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Node Names and Values
Every node has a name and possibly a value
Name is not a unique identifier (only location)
Type Interface Name Name Value
ATTRIBUTE_NODE Attr Attribute name Attribute value
DOCUMENT_NODE Document #document NULL
DOCUMENT_FRAGMENT_NODE DocumentFragment #document-fragment NULL
DOCUMENT_TYPE_NODE DocumentType DOCTYPE name NULL
CDATA_SECTION_NODE CDATASection #cdata-section CDATA content
COMMENT_NODE Comment Entity name Content string
ELEMENT_NODE Element Tag name NULL
ENTITY_NODE Entity Entity name NULL
ENTITY_REFERENCE_NODE EntityReference Entity name NULL
NOTATION_NODE Notation Notation name NULL
PROCESSING_INSTRUCTION_
NODE
ProcessingInstruction Target string Content string
TEXT_NODE Text #text Text string

Table as from The XML Companion - Neil Bradley
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Child Nodes
Most Nodes cannot have children, except
Document, DocumentFragment, Element
Can check for presence of children
if (myNode.hasChildNodes()) {
//process children of myNode

}
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Node Navigation
Every node has a specific location in tree
Node interface specifies methods to find surrounding
nodes
Node getFirstChild();
Node getLastChild();
Node getNextSibling();
Node getPreviousSibling();
Node getParentNode();
NodeList getChildNodes();
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Node Navigation (2)
getFirstChild()
getPreviousSibling()
getChildNodes()
getNextSibling()
getLastChild()
getParentNode()
Node parent = myNode.getParentNode();
if (myNode.hasChildren()) {
NodeList children = myNode.getChildNodes();
}
Figure as from The XML Companion - Neil Bradley
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Node Manipulation
Children of a node in a DOM tree can be manipulated -
added, edited, deleted, moved, copied, etc.
Node removeChild(Node old) throws DOMException;
Node insertBefore(Node new, Node ref) throws DOMException;
Node appendChild(Node new) throws DOMException;
Node replaceChild(Node new, Node old) throws DOMException;
Node cloneNode(boolean deep);
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Node Manipulation (2)
Ref
New
insertBefore
Old
New
replaceChild
cloneNode
Shallow 'false'
Deep 'true'
Figure as from The XML Companion - Neil Bradley
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Document::Node Interface
Represents entire XML document (tree root)
Methods
//Information from DOCTYPE - See 'DocumentType'
DocumentType getDocumentType();
//Information about capabilities of DOM implementation
DOMImplementation getImplementation();
//Returns reference to root node element
Element getDocumentElement();
//Searches for all occurrences of 'tagName' in nodes
NodeList getElementsByName(String tagName);
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Document::Node Interface (2)
Factory methods for node creation
Element createElement(String tagName) throws DOMException;
DocumentFragment createDocumentFragment();
Text createTextNode(String data);
Comment createComment(String data);
CDATASection createCDATASection(String data) throws
DOMException;
ProcessingInstruction createProcessingInstruction(
String target, String data) throws DOMException;
Attr createAttribute(String name) throws DOMException;
EntityReference createEntityReference(String name)
throws DOMException;
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
DocumentType::Node Interface
Information about document encapsulated in DTD
representation
DOM 1.0 doesnt allow editing of this node
//Returns name of document
String getName();
//Returns general entities declared in DTD
NamedNodeList getEntities();
//Returns notations declared in DTD
NamedNodeList getNotations();
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Element::Node Interface
Two categories of methods
General element methods
Attribute management methods
String getTagName();
NodeList getElementsByTagName();
void normalize();
String getAttribute(String name);
void setAttribute(String name, String value)
throws DOMException;
void removeAttribute(String name)
throws DOMException;
Attr getAttributeNode(String name);
void setAttributeNode(Attr new)
throws DOMException;
void removeAttributeNode(Attr old)
throws DOMException;
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Element::Node Interface (2)
Only Element objects have attributes but attribute
methods of Element are simple
Need name of attribute
Cannot distinguish between default value specified in DTD
and given in XML file
Cannot determine attribute type [String]
Instead use getAttributes() method of Node
Returns Attr objects in a NamedNodeMap
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Attr::Node Interface
Interface to objects holding attribute data
Entity ref's are children of attribute's
//Get name of attribute
String getName();
//Get value of attribute
String getValue();
//Change value of attribute
void setValue(String value);
//if 'true' - attribute defined in element, else in DTD
boolean getSpecified();
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Attr::Node Interface (2)
Attributes not considered part of DOM
parentNode, previousSibling and nextSibling have
null value for Attr object
Create attribute objects using factory method of
Document
//Create the empty Attribute node
Attr newAttr = myDoc.createAttribute("status");
//Set the value of the attribute
newAttr.setValue("secret");
//Attach the attribute to an element
myElement.setAttributeNode(newAttr);
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
CharacterData::Node Interface
Useful general methods for dealing with text
Not used directly
sub-classed to Text and Comment Node types
String getData() throws DOMException;
void setData(String data) throws DOMException;
int getLength();
void appendData(String data) throws DOMException;
String substringData(int offset, int length)
throws DOMException;
void insertData(int offset, String data)
throws DOMException;
void deleteData(int offser, int length)
throws DOMException;
void replaceData(int offset, int length, String data)
throws DOMException;
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Text::Node Interface
Represents textual content of Element or Attr
Usually children of these nodes
Always leaf nodes
Single method added to CharacterData
Text splitText(int offset) throws DOMException
Factory method in Document for creation
Calling normalize() on an Element merges its Text
objects
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
CDATASection::Text Interface
Represents CDATA that is not to be interpreted as
markup (only delimiter recognised is the "]]>" string
that ends the CDATA section)
The DOMString attribute of the Text node holds the
text of the CDATA section
No methods added to CharacterData
Factory method in Document for creation
CDATASection newCDATA =
myDoc.createDATASection("press <<<ENTER>>>");
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Comment::Text Interface
Represents comments
all the characters between starting '<!--' and ending '--
>'
No methods added to CharacterData
Factory method in Document for creation
Comment newComment =
myDoc.createComment(" my comment "); //Note spaces
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
ProcessingInstruction::Node Interface
Represent processing instruction declarations
Name of node is target application name
Value of node is target application command
Factory method in Document for creation
ProcessingInstruction newPI =
myDoc.createProcessingInstruction("ACME",
"page-break");
//Get the content of the processing instruction
String getData()
//Set the content of the processing instruction
void setData(String data)
//The target of this processing instruction
String getTarget();
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
EntityReference::Node Interface
DOM includes interfaces for handling notations, entities
and entity references
If the entities have not been replaced by the parser
Element Text
Text
EntityReference Text
An
value
xml
eXtensible
Markup
Language
<!ENTITY xml "eXtensible Markup Language">
<para>An &xml; value</para>
value
name
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Entity::Node Interface
Represents an entity, either parsed or unparsed, in an
XML document
Parser may replace entity references, or create
EntityReference nodes
Must retain Entity for non-parsable data
Extends Node interface and adds methods
For non-parsable entities - can get notation name
String getPublicId();
String getSystemId();
String getNotationName();
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Entity::Node Interface (2)
A parsable Entity may have children that represent
the replacement value of the entity
All entities of a Document accessed with getEntities()
method in DocumentType
Entity Text
Text EntityReference
xml
eXtensible
Markup
Language
name
xml
eXtensible
Markup
Language
<!ENTITY MyBoat PUBLIC "BOAT" SYSTEM "boat.gif" NDATA GIF>
String publicId = ent.getPublicId(); //BOAT
String systemId = ent.getSystemId(); //boat.gif
String notation = ent.getNotationName(); //GIF
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Notation::Node Interface
Each notation declaration in DTD represented by a
Notation node
Methods added to Node interface
All notations of a Document accessed with
getNotations() method in DocumentType object
//Returns content of PUBLIC identifier
String getPublicId();
//Returns content of SYSTEM identifier
String getSystemId();
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
NodeList Interface
Holds collection of ordered Node objects
Two methods
//Find number of Nodes in NodeList
int getLength();
//Return the i-th Node
Node item(int index);
-------------------------------------------------
Node child;
NodeList children = element.getChildNodes()'
for (int i = 0; i < children.getLength(); i++) {
child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
System.out.println(child.getNodeName());
}
}
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
NamedNodeMap Interface
Holds collection of unordered Node objects
E.g. Attribute, Entity and Notation
Unique names are essential as nodes are accessed by
name
NamedNodeMap myAttributes = myElement.getAttributes();
NamedNodeMap myEntities = myDocument.getEntities();
NamedNodeMap myNotations = myDocument.getNotations();
------------------------------------------------------
int getLength();
Node item(int index);
Node getNamedItem(String name);
Node setNamedItem(Node node) throws DOMException;//Node!
Node removeNamedItem(String name) throws DOMException;
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
DocumentFragment::Node Interface
Fragment of Document can be temporarily stored in
DocumentFragment node
Lightweight object, e.g. for 'cut-n-paste'
When attached to another Node - destroys itself (very
useful for adding siblings to tree)
DocumentFragment
DOM tree
New DOM tree
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
DOMImplementation Interface
Interface to determine level of support in DOM parser
hasFeature(String feature, String version);
if (theParser.hasFeature("XML", "1.0") {
//XML is supported

}
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
DOM Objects
DOM object compiled XML
Can save time and effort if send and receive DOM objects
instead of XML source
Saves having to parse XML files into DOM at sender and receiver
But, DOM object may be larger than XML source
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
DOM versus XSL
If you want to do complicated sorting or
restructuring that's beyond the realm of XSL,
use DOM
In this method, you parse the XML
document, then write Java code to
manipulate the DOM tree in whatever way
you wish. Your code has complete access to
the DOM and all of its methods, so you're not
bound by the limitations or design decisions
of XSL
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
DOM and XSL
An XSL processor can transform an input XML document
to an XML or HTML output document based on rules in a
second XML document
A DOM implementation of XSL/XSLT such as LotusXSL processor
is useful here
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Practical
eXtensible Markup Language
Lecturer: Phan Vo Minh Thang MSc.
<?xml version=1.0> <material> XML Lectures Notes <section id=07> Document Object Model </section> </material>
Info
Course name:
Special Selected Topic in
Information System
Section: Document Object Model 1.0
Number of slides: 53
Updated date: 12/02/2006
Contact: Mr.Phan Vo Minh Thang
(minhthangpv@hcmuaf.edu.vn)

Você também pode gostar