- 111 -
Figure 4.19:
Allowable nodes under the Notation node.
DOM Applications
You might be wondering why the DOM is needed to display
an XML document in a
browser. In fact, the DOM doesn’t always need to be used when accessing XML data. A
Web page that simply wants to display the contents of an XML document can just point
the URL to that page. An XSL stylesheet can be associated with that XML document to
provide a certain view of the data. Also, CSS can be used to
render the display of the
XML document. The DOM comes into play from a script when the XML document needs
to be modified or when the script needs access to some of this data. For example, a
script might need to calculate the tax on a given item at an online shopping site. Any
application that requires the manipulation of the data contained within
an XML document
needs to use the DOM interfaces.
On the server side, the DOM is used heavily to process XML documents. For example,
the online shopping application included with this book
sends an XML document that
represents a client’s order down to the server. The object on the server uses the DOM to
view the contents of this document and then applies the necessary business logic to
complete the transaction.
Another server-side application would be to provide a translation mechanism
from legacy
databases to XML (see Figure 4.20). The DOM interfaces can be implemented on top of
this database to make it seem like an XML document to users of this data. In effect, the
users of this database don’t need to know that the data is not natively stored in XML.