net.sf.sdedit.util
Class DocUtil

java.lang.Object
  extended by net.sf.sdedit.util.DocUtil

public class DocUtil
extends Object

Author:
Markus Strauch

Nested Class Summary
static class DocUtil.XMLException
          An XMLException is thrown when an XML document is not well-formed or not valid.
 
Method Summary
static String evaluateCDATA(Document document, String xPath)
           
static Node evalXPathAsNode(Document document, String expression)
           
static NodeList evalXPathAsNodeList(Document document, String expression)
           
static String evalXPathAsString(Document document, String expression)
           
static Document newDocument()
          Returns an empty Document.
static Document readDocument(InputStream in, String encoding)
          Creates a Document instance from a Reader reading an XML input stream.
static void writeDocument(Document document, String encoding, OutputStream out)
          Writes the XML representation of a Document object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

evalXPathAsString

public static String evalXPathAsString(Document document,
                                       String expression)
                                throws DocUtil.XMLException
Throws:
DocUtil.XMLException

evaluateCDATA

public static String evaluateCDATA(Document document,
                                   String xPath)
                            throws DocUtil.XMLException
Throws:
DocUtil.XMLException

evalXPathAsNode

public static Node evalXPathAsNode(Document document,
                                   String expression)
                            throws DocUtil.XMLException
Throws:
DocUtil.XMLException

evalXPathAsNodeList

public static NodeList evalXPathAsNodeList(Document document,
                                           String expression)
                                    throws DocUtil.XMLException
Throws:
DocUtil.XMLException

newDocument

public static Document newDocument()
Returns an empty Document.

Returns:
an empty Document

writeDocument

public static void writeDocument(Document document,
                                 String encoding,
                                 OutputStream out)
                          throws IOException,
                                 DocUtil.XMLException
Writes the XML representation of a Document object.

Parameters:
document - the Document instance
encoding - the encoding to be used
out - the output stream to be used
Throws:
DocUtil.XMLException
IOException

readDocument

public static Document readDocument(InputStream in,
                                    String encoding)
                             throws IOException,
                                    DocUtil.XMLException
Creates a Document instance from a Reader reading an XML input stream.

Parameters:
in - an XML input stream
Returns:
the Document object created from the XML code
Throws:
IOException - if the Reader cannot read
DocUtil.XMLException


Copyright © 2011. All Rights Reserved.