org.xwiki.rendering.wikimodel.xml
Class XmlUtil

java.lang.Object
  extended by org.xwiki.rendering.wikimodel.xml.XmlUtil

public class XmlUtil
extends Object

This class contains various utility methods used to manipulate with DOM nodes.

Since:
4.0M1
Version:
$Id: d675e011571ce74e423a29848cefacbb40428a78 $

Constructor Summary
XmlUtil()
           
 
Method Summary
static void formatXML(Document xml, Document xsl, URIResolver resolver, Writer output)
           
static void formatXML(Document xml, Document xsl, Writer output)
           
static void formatXML(Reader xml, Reader xsl, URIResolver resolver, Writer output)
           
static void formatXML(Reader xml, Reader xsl, Writer output)
           
static void formatXML(Source xmlSource, Source xslSource, URIResolver resolver, Result result)
           
static String lookupNamespaceURI(Node root, String specifiedPrefix)
           
static
<E extends Node>
E
newCopy(Document doc, E node)
          Returns a new copy of the given node using the specified document as a factory for new nodes.
static Document newDocument()
          Creates and returns a new empty DOM document.
static Element newTemplate(String xml)
           
static Document readXML(InputStream input)
          Parses the given input stream and returns the corresponding desirialized XML document.
static Document readXML(Reader reader)
          Parses the given input stream and returns the corresponding desirialized XML document.
static Document readXML(String str)
           
static String write(Document doc)
           
static String write(Element e)
           
static void write(Element root, OutputStream os)
           
static void write(Element root, Writer writer)
           
static void write(Reader reader, XMLReader parser, Result output)
           
static void write(Reader reader, XMLReader parser, Writer writer)
           
static void write(Source input, Result output)
           
static void write(Source input, Result output, boolean indent)
           
static void write(Source input, Writer writer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlUtil

public XmlUtil()
Method Detail

formatXML

public static void formatXML(Document xml,
                             Document xsl,
                             URIResolver resolver,
                             Writer output)
                      throws Exception
Throws:
Exception

formatXML

public static void formatXML(Document xml,
                             Document xsl,
                             Writer output)
                      throws Exception
Throws:
Exception

formatXML

public static void formatXML(Reader xml,
                             Reader xsl,
                             URIResolver resolver,
                             Writer output)
                      throws Exception
Throws:
Exception

formatXML

public static void formatXML(Reader xml,
                             Reader xsl,
                             Writer output)
                      throws Exception
Throws:
Exception

formatXML

public static void formatXML(Source xmlSource,
                             Source xslSource,
                             URIResolver resolver,
                             Result result)
                      throws TransformerFactoryConfigurationError,
                             TransformerConfigurationException,
                             TransformerException
Parameters:
xmlSource -
xslSource -
resolver -
output -
Throws:
TransformerFactoryConfigurationError
TransformerConfigurationException
TransformerException

lookupNamespaceURI

public static String lookupNamespaceURI(Node root,
                                        String specifiedPrefix)

newCopy

public static <E extends Node> E newCopy(Document doc,
                                         E node)
Returns a new copy of the given node using the specified document as a factory for new nodes.

Parameters:
doc - the document used as a factory for new nodes
node - the node to copy
Returns:
a new copy of the given node using the specified document as a factory for new nodes.

newDocument

public static Document newDocument()
                            throws ParserConfigurationException
Creates and returns a new empty DOM document.

Returns:
a newly created DOM document
Throws:
ParserConfigurationException

newTemplate

public static Element newTemplate(String xml)
                           throws Exception
Throws:
Exception

readXML

public static Document readXML(InputStream input)
                        throws Exception
Parses the given input stream and returns the corresponding desirialized XML document.

Parameters:
input - the input stream containing the serialized XML document
Returns:
the deserialized DOM document
Throws:
Exception

readXML

public static Document readXML(Reader reader)
                        throws Exception
Parses the given input stream and returns the corresponding desirialized XML document.

Parameters:
reader - the reader containing the serialized XML document
Returns:
the deserialized DOM document
Throws:
Exception

readXML

public static Document readXML(String str)
                        throws Exception
Throws:
Exception

write

public static String write(Document doc)
                    throws Exception
Throws:
Exception

write

public static String write(Element e)
                    throws Exception
Throws:
Exception

write

public static void write(Element root,
                         OutputStream os)
                  throws Exception
Throws:
Exception

write

public static void write(Element root,
                         Writer writer)
                  throws TransformerConfigurationException,
                         TransformerFactoryConfigurationError,
                         TransformerException
Parameters:
root -
writer -
Throws:
TransformerConfigurationException
TransformerFactoryConfigurationError
TransformerException

write

public static void write(Reader reader,
                         XMLReader parser,
                         Result output)
                  throws TransformerConfigurationException,
                         TransformerFactoryConfigurationError,
                         TransformerException
Parameters:
reader -
parser -
output -
Throws:
TransformerConfigurationException
TransformerFactoryConfigurationError
TransformerException

write

public static void write(Reader reader,
                         XMLReader parser,
                         Writer writer)
                  throws TransformerConfigurationException,
                         TransformerFactoryConfigurationError,
                         TransformerException
Parameters:
parser -
writer -
Throws:
TransformerConfigurationException
TransformerFactoryConfigurationError
TransformerException

write

public static void write(Source input,
                         Result output)
                  throws TransformerConfigurationException,
                         TransformerFactoryConfigurationError,
                         TransformerException
Throws:
TransformerConfigurationException
TransformerFactoryConfigurationError
TransformerException

write

public static void write(Source input,
                         Result output,
                         boolean indent)
                  throws TransformerConfigurationException,
                         TransformerFactoryConfigurationError,
                         TransformerException
Throws:
TransformerConfigurationException
TransformerFactoryConfigurationError
TransformerException

write

public static void write(Source input,
                         Writer writer)
                  throws TransformerConfigurationException,
                         TransformerFactoryConfigurationError,
                         TransformerException
Parameters:
input -
os -
Throws:
TransformerConfigurationException
TransformerFactoryConfigurationError
TransformerException


Copyright © 2004-2012 XWiki. All Rights Reserved.