com.ibm.commons.xml.drivers
Interface XMLParserDriver


public interface XMLParserDriver

XML Parser driver. This driver encapsulate the actual parser, and the non standard methods.


Method Summary
 org.w3c.dom.Document createDocument(java.lang.String namespaceURI, java.lang.String qualifiedName, org.w3c.dom.DocumentType doctype)
          Creates a DOM Document object given the uri, qualified name, and Document type.
 org.w3c.dom.DocumentType createDocumentType(java.lang.String qualifiedName, java.lang.String publicId, java.lang.String systemId)
          Creates an empty DocumentType node.
 java.lang.Object createXPath(java.lang.String xpath)
          Creates an XPage expression based on the provided String
 com.ibm.commons.xml.XResult evaluateXPath(org.w3c.dom.NodeList nodeList, java.lang.Object xpath, com.ibm.commons.xml.NamespaceContext nsContext)
          Evaluate the xpath relative to the given NodeList and namespace context
 com.ibm.commons.xml.XResult evaluateXPath(org.w3c.dom.Node node, java.lang.Object xpath, com.ibm.commons.xml.NamespaceContext nsContext)
          Evaluate the xpath relative to the given node and namespace context
 org.w3c.dom.traversal.DocumentTraversal getDocumentTraversal(org.w3c.dom.Document doc)
          Returns a DocumentTraversal object that can be used on the provided document object
 org.w3c.dom.DOMImplementation getDOMImplementation()
          Returns the W3C DomImplementation
 com.ibm.commons.xml.NamespaceContext getNamespaceContext(org.w3c.dom.Document doc)
          Get the selection NamespaceContext use during the XPath evaluation on the document.
 com.ibm.commons.xml.XPathContext getXPathContext(org.w3c.dom.Document doc)
          Returns the XPath context associated to an XML document
 org.w3c.dom.Document parse(java.io.InputStream is, boolean ignoreBlanks, boolean resolveEntities, boolean validate)
          Creates a W3C DOM Document based on the inputstream provided.
 org.w3c.dom.Document parse(java.io.Reader reader, boolean ignoreBlanks, boolean resolveEntities, boolean validate)
          Creates a W3C DOM Document based on the Reader provided.
 void popXPathContext(org.w3c.dom.Document doc)
          Remove the latest XPath context that has been set to the document An XML document contains a base XPath that is used when evaluating XPath against a node.
 void pushXPathContext(org.w3c.dom.Document doc, java.lang.String xpath)
          Push an XPath context to an existing document.
 void serialize(java.io.OutputStream os, org.w3c.dom.Node node, com.ibm.commons.xml.Format format)
          Saves the provided node to the given stream, using the given formatter.
 void serialize(java.io.Writer writer, org.w3c.dom.Node node, com.ibm.commons.xml.Format format)
          Saves the provided node to the given stream, using the given formatter.
 void setNamespaceContext(org.w3c.dom.Document doc, com.ibm.commons.xml.NamespaceContext ns)
          Set the namespaces map use during the XPath evaluation on the document.
 

Method Detail

getDOMImplementation

org.w3c.dom.DOMImplementation getDOMImplementation()
Returns the W3C DomImplementation

Returns:

createDocument

org.w3c.dom.Document createDocument(java.lang.String namespaceURI,
                                    java.lang.String qualifiedName,
                                    org.w3c.dom.DocumentType doctype)
                                    throws XMLException
Creates a DOM Document object given the uri, qualified name, and Document type.

Parameters:
namespaceURI - a fully qualified namespace URI
qualifiedName - The qualified name of the document element to be created or null.
doctype - The type of document to be created or null. When doctype is not null, its Node.ownerDocument attribute is set to the document being created.
Returns:
A new Document object with its document element. If the NamespaceURI, qualifiedName, and doctype are null, the returned Document is empty with no document element.
Throws:
XMLException - throws an XML exception when invalid input is given

createDocumentType

org.w3c.dom.DocumentType createDocumentType(java.lang.String qualifiedName,
                                            java.lang.String publicId,
                                            java.lang.String systemId)
                                            throws XMLException
Creates an empty DocumentType node. Entity declarations and notations are not made available. Entity reference expansions and default attribute additions do not occur!

Parameters:
qualifiedName - the qualified name of the document type
publicId - the public identifier
systemId - the system identifier
Returns:
a new document type based on the parameters provided
Throws:
XMLException - throws an XMLException if the parameters contain illegal XML input

parse

org.w3c.dom.Document parse(java.io.InputStream is,
                           boolean ignoreBlanks,
                           boolean resolveEntities,
                           boolean validate)
                           throws XMLException
Creates a W3C DOM Document based on the inputstream provided.

Parameters:
is - an input stream which contains a DOM document
ignoreBlanks - ignore blanks (spaces and tabs) in the provided stream
resolveEntities - resolve entities in the provided stream
validate - validate the resulting document
Returns:
a document built from the provided input stream
Throws:
XMLException - throws an exception if the provided inputstream contains illegal XML markup

parse

org.w3c.dom.Document parse(java.io.Reader reader,
                           boolean ignoreBlanks,
                           boolean resolveEntities,
                           boolean validate)
                           throws XMLException
Creates a W3C DOM Document based on the Reader provided.

Parameters:
reader - an reader which contains a DOM document
ignoreBlanks - ignore blanks (spaces and tabs) in the provided reader
resolveEntities - resolve entities in the provided stream
validate - validate the resulting document
Returns:
a document built from the provided reader
Throws:
XMLException - throws an exception if the provided reader contains illegal XML markup

serialize

void serialize(java.io.OutputStream os,
               org.w3c.dom.Node node,
               com.ibm.commons.xml.Format format)
               throws XMLException
Saves the provided node to the given stream, using the given formatter.

Parameters:
os - the stream where the DOM Node is to be saved (serialized) to
node - a DOM Node that is to be serialized
format - a formatter that is used to format the Node when serialized
Throws:
XMLException - throws an exception if the node is illegal or if the stream is not accessible

serialize

void serialize(java.io.Writer writer,
               org.w3c.dom.Node node,
               com.ibm.commons.xml.Format format)
               throws XMLException
Saves the provided node to the given stream, using the given formatter.

Parameters:
os - the stream where the DOM Node is to be saved (serialized) to
node - a DOM Node that is to be serialized
format - a formatter that is used to format the Node when serialized
Throws:
XMLException - throws an exception if the node is illegal or if the stream is not accessible

createXPath

java.lang.Object createXPath(java.lang.String xpath)
                             throws com.ibm.commons.xml.xpath.XPathException
Creates an XPage expression based on the provided String

Parameters:
xpath - the XPath we wish to encapsulate
Returns:
an object describing the provided xpath
Throws:
com.ibm.commons.xml.xpath.XPathException

evaluateXPath

com.ibm.commons.xml.XResult evaluateXPath(org.w3c.dom.Node node,
                                          java.lang.Object xpath,
                                          com.ibm.commons.xml.NamespaceContext nsContext)
                                          throws com.ibm.commons.xml.xpath.XPathException
Evaluate the xpath relative to the given node and namespace context

Parameters:
node - a node that we wish to evaluate using the given XPath
xpath - a namespace context to be used when evaluting the XPath
nsContext -
Returns:
an object based on the given XPath
Throws:
com.ibm.commons.xml.xpath.XPathException

evaluateXPath

com.ibm.commons.xml.XResult evaluateXPath(org.w3c.dom.NodeList nodeList,
                                          java.lang.Object xpath,
                                          com.ibm.commons.xml.NamespaceContext nsContext)
                                          throws com.ibm.commons.xml.xpath.XPathException
Evaluate the xpath relative to the given NodeList and namespace context

Parameters:
nodeList - a node list that we wish to evaluate using the given XPath
xpath - a namespace context to be used when evaluting the XPath
nsContext -
Returns:
an object based on the given XPath
Throws:
com.ibm.commons.xml.xpath.XPathException

getXPathContext

com.ibm.commons.xml.XPathContext getXPathContext(org.w3c.dom.Document doc)
Returns the XPath context associated to an XML document

Parameters:
doc - a DOM Document
Returns:

pushXPathContext

void pushXPathContext(org.w3c.dom.Document doc,
                      java.lang.String xpath)
                      throws XMLException
Push an XPath context to an existing document. An XML document contains a base XPath that is used when evaluating XPath against a node. This base XPath is composed by the aggregating all the XPath contexts

Parameters:
doc - the document where the xpath is to be set
xpath - the xpath to set
Throws:
XMLException

popXPathContext

void popXPathContext(org.w3c.dom.Document doc)
                     throws XMLException
Remove the latest XPath context that has been set to the document An XML document contains a base XPath that is used when evaluating XPath against a node. This base XPath is composed by the aggregating all the XPath contexts pushed to the document.

Parameters:
doc - the source document
Throws:
XMLException

getNamespaceContext

com.ibm.commons.xml.NamespaceContext getNamespaceContext(org.w3c.dom.Document doc)
Get the selection NamespaceContext use during the XPath evaluation on the document.

Parameters:
doc - the source document
Returns:
a NamespaceContext

setNamespaceContext

void setNamespaceContext(org.w3c.dom.Document doc,
                         com.ibm.commons.xml.NamespaceContext ns)
Set the namespaces map use during the XPath evaluation on the document.

Parameters:
doc - the source document
selectionNS - the NamespaceContext used during XPath evaluation on the document in order to resolve namespaces.

getDocumentTraversal

org.w3c.dom.traversal.DocumentTraversal getDocumentTraversal(org.w3c.dom.Document doc)
Returns a DocumentTraversal object that can be used on the provided document object

Parameters:
doc -
Returns: