Home > J2EE > XML

XML

DOM (Document Object Model)

The XML DOM defines a standard way for accessing and manipulating XML documents.

The DOM presents an XML document as a tree-structure.

Knowing the XML DOM is a must for anyone working with XML.

SAX

Simple API for XML (SAX)

for the events-based parsing of XML documents

Difference

SAX parsers operate on each piece of the XML document sequentially while the DOM operates on the document as a whole.

The quantity of memory that a SAX parser must use in order to function is typically much smaller than that of a DOM parser.

DOM parsers must have the entire tree in memory before any processing can begin, so the amount of memory used by a DOM parser depends entirely on the size of the input data. The memory footprint of a SAX parser, by contrast, is based only on the maximum depth of the XML file (the maximum depth of the XML tree) and the maximum data stored in XML attributes on a single XML element

JDOM

The JDOM is open source Java API for manipulating XML files within Java Program.

it allow writing Java programs that can read, manipulate and output XML data

The JDOM API is faster than DOM API and it simplifies the interaction with the XML.

JDOM’s provide XPath support.

StAX 

goal of the StAX API is to give “parsing control to the programmer by exposing a simple iterator based API

Namespace

When a namespace is defined for an element, all child elements with the same prefix are associated with the same namespace.

Defining a default namespace for an element saves us from using prefixes in all the child elements. It has the following syntax:

<root
xmlns:h=”http://www.w3.org/TR/html4/”
xmlns:f=”http://www.w3schools.com/furniture”>

<h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>

<f:table>
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>

</root>

CDATA

All text in an XML document will be parsed by the parser.

But text inside a CDATA section will be ignored by the parser.

service contract

= data contract + operational contract

data contract will define the messages going in and out of the service.

operational contract will define the operations that our service will perform.

WSDL file contains both:-

1) contains an embedded xsd file that defines data contract.

2) The rest of he WSDL file defines the opeartional contract,including one or more <wsdl:operation> elements within the <wsdl:binding> element

XPath

is used for identifying or extracting parts of an XML structure.

You could say that XPath is to XML what SQL is to relation database.

Categories: J2EE
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.