avignon.xml
Class XMLDocumentFactory

java.lang.Object
  extended byavignon.xml.XMLDocumentFactory

public class XMLDocumentFactory
extends java.lang.Object

Helper class for making org.w3c.dom.Document objects out of strings and vice versa. Also provides methods for getting the text of a node.


Method Summary
 org.w3c.dom.Document buildDocument(java.lang.String xmlText)
          Returns an org.w3c.dom.Document representing the given text.
static XMLDocumentFactory getInstance()
           
 java.io.InputStream getMockInputStream()
           
 java.lang.String getNodeText(org.w3c.dom.Node root, java.lang.String tag)
          Finds an element based on the given XPath expression and returns the text of the first child.
 java.lang.String getXMLText(org.w3c.dom.Node node)
          Returns the text of the node and all its children.
 void outputDocument(org.w3c.dom.Document document, java.io.Writer output)
          Writes the text of the document to the output after having closed any input, link or meta tags.
 void setMockInputStream(java.io.InputStream aMockInputStream)
           
 javax.xml.transform.dom.DOMResult transform(org.w3c.dom.Document input, java.lang.String transformer)
          Transforms the input document by the XSL stored in transformer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static XMLDocumentFactory getInstance()

buildDocument

public org.w3c.dom.Document buildDocument(java.lang.String xmlText)
Returns an org.w3c.dom.Document representing the given text. Any parsing or other exceptions will result in RuntimeExceptions being thrown.

Parameters:
xmlText - Well formed XML text.
Returns:
A Document representing the DOM version of the XML text.

getNodeText

public java.lang.String getNodeText(org.w3c.dom.Node root,
                                    java.lang.String tag)
Finds an element based on the given XPath expression and returns the text of the first child.

Parameters:
root - Position at which to start the search.
tag - An XPath expression describing where to find the node. (Note that this method always starts from the root node and searches all children.)
Returns:
The text of the element or attribute specified by the XPath expression.

getXMLText

public java.lang.String getXMLText(org.w3c.dom.Node node)
Returns the text of the node and all its children.

Parameters:
node - Node to convert to text.
Returns:
Text version of the node.

outputDocument

public void outputDocument(org.w3c.dom.Document document,
                           java.io.Writer output)
Writes the text of the document to the output after having closed any input, link or meta tags.

Parameters:
document - Document to output.
output - Destination for the output.

transform

public javax.xml.transform.dom.DOMResult transform(org.w3c.dom.Document input,
                                                   java.lang.String transformer)
Transforms the input document by the XSL stored in transformer.

Parameters:
input - Document to be transformed.
transformer - Text of a valid XSL stylesheet.
Returns:
The DOMResult of the transformation.

getMockInputStream

public java.io.InputStream getMockInputStream()

setMockInputStream

public void setMockInputStream(java.io.InputStream aMockInputStream)

SourceForge.net Logo