10.2 XML Standards

   

The World Wide Web Consortium, a group of individuals that participate in the establishment of web-related standards, has created many XML- related standards, including XML 1.0, XML's first formal specification, and more recently, XML Schema. Oracle Application Server provides support for these established XML standards both in the database via the mod_plsql module and in the application server for web-based applications written in any of the following:

  • C or C++ that runs in mod_fastcgi

  • Java that runs in OC4J

  • Web Services

10.2.1 XML

XML Version 1.0 is XML's first formal specification (recommendation) from the W3C. It defines the syntax used to create a well- formed XML document. In addition, it defines the structure of a DTD, a schema that, in turn , can validate one of its XML document instances.

Oracle Application Server is XML 1.0-compliant, which means that the server's internal use of XML, along with the tools and APIs it provides, all comply with the XML Version 1.0 recommendation from the W3C.

10.2.2 XML Namespaces

XML Namespaces exist to eliminate potentially ambiguous XML element (tag) names when XML applications are combined to create a new XML application. An XML Namespace associates a URI with a namespace prefix. The prefix is added to an element name in an XML document to maintain the element name 's uniqueness within the document. This qualification becomes necessary when element names from two different XML applications used in another XML application use the same element name. Without the prefix, the elements with the same name collide; this creates ambiguity that, in turn, causes confusion about the element's meaning. The associated namespace URI creates a context for an otherwise ambiguous element.

The XML Namespace Version 1.0 recommendation isn't part of the XML 1.0 recommendation. It post-dates XML 1.0 and isn't a dependent specification. XML Namespaces may be used if necessary, but they are by no means required for an XML document to be compliant with the 1.0 recommendation.

Oracle Application Server supports the XML Namespace's 1.0 recommendation from the W3C.

10.2.3 XML Path Language

XML Path Language is a non-XML based language that identifies a particular part, or parts , of an XML document. XPath treats an XML document and its content as a tree structure , in much the same way operating systems treat file systems. By doing so, it allows you to write an expression that identifies a specific element, attribute, text, comment, processing instruction, or namespace within an XML document. XPath expressions can also specify Boolean values, numbers , or strings.

Oracle Application Server supports XPath Version 1.0.

10.2.4 Extensible Stylesheet Language Transformations

EXtensible Stylesheet Language for Transformations (XSLT) is an XML application that allows you to specify a set of rules that transform an XML document into another document format. Although typically used for XML-to-XML document transformation, XSLT can be used to create a text document of any kind.

An XSLT stylesheet is an XML document that contains rules for transformation. The rules in an XSL stylesheet use XPath notation to identify the targets of rules. Using an XSL stylesheet, an XSLT processor transforms an input XML document to another format using the rules specified in a stylesheet.

Oracle Application Server supports XSLT Version 1.0.

10.2.5 XML Schemas

An XML Schema is an XML document that describes the composition of a valid XML document in much greater detail than is possible using a DTD. An XML Schema adds the concepts of datatypes (both simple and complex), datatype inheritance, and element and attribute constraints to the structural capabilities of a DTD. However, XML Schemas improve on DTDs at the expense of additional complexity.

Oracle Application Server provides support for parts 0-2 of the W3C's XML Schema recommendation from May 2, 2001.

10.2.6 XML Parsers

XML parsers can read an XML document from an operating system file or stream and present the XML document's information as a tree structure in memory after the entire file is read, or in an event-based fashion as a document is read. Each approach has its strengths and weaknesses:


Tree-structured approach, or document model

This approach makes it feasible to query any part of an XML document at any time. It also allows you to modify an XML document, but it can require a great deal of memory.


Event-based model

This approach conserves memory consumption, but it can process a document only as it is read.

Because of the opposing constraints, two types of XML parsers exist: Document Object Model (DOM) parsers and Simple API for XML (SAX) parsers.

10.2.6.1 Document Object Model

The Document Object Model (DOM) is a specification for reading and modifying (and saving) an XML document as a tree structure. The elements that make up a particular XML document create a hierarchical structure that can be represented as a tree with the first element of an XML document as the root. In many ways, this tree structure, shown in Figure 10-1, is similar to the one presented by most modern operating systems' file systems.

Figure 10-1. A tree of DOM nodes for Example 10-1
figs/oas_1001.gif

At its core , DOM is a set of APIs that represent an XML document as a set of object nodes, as in Figure 10-1. A node type exists for each kind of XML structural and content syntax. DOM's strength is that it allows random access to any part of an XML document.

Oracle Application Server supports DOM Version 2.0. It provides DOM APIs for C, C++, Java, and PL/SQL.

10.2.6.2 Simple API for XML

The Simple API for XML (SAX) is a specification for reading an XML document that reports each XML artifact ”for example, an element or an attribute ”as an event as a document is read. The events are reported by calling the callback functions of a programmatically registered document handler. SAX's strength is its low memory consumption.

Example 10-4 lists the callback events generated when parsing the XML document from Example 10-1. The events in this list are named using their corresponding function names in the Java interface org.sax.xml.ContentHandler . Any values passed to the callback functions are shown after the function names.

Example 10-4. A list of SAX events for Example 10-1
 setDocumentLocator startDocument startElement: localName=person, qualifiedName=person ignorableWhitespace:  startElement: localName=name, qualifiedName=name ignorableWhitespace:  startElement: localName=last_name, qualifiedName=last_name characters: Doe ignorableWhitespace:  startElement: localName=first_name, qualifiedName=first_name characters: Jane ignorableWhitespace:  ignorableWhitespace:  startElement: localName=birth_date, qualifiedName=birth_date characters: 1980-01-01 ignorableWhitespace:  startElement: localName=gender, qualifiedName=gender characters: Female ignorableWhitespace:  endDocument 

Oracle Application Server supports SAX Version 2.0. It provides SAX APIs for languages that support callback functions: C, C++, and Java.

   


Oracle Application Server 10g Essentials
Oracle Application Server 10g Essentials
ISBN: 0596006217
EAN: 2147483647
Year: 2004
Pages: 120

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net