org.apache.taglibs.standard.util
Class XmlUtil

java.lang.Object
  extended by org.apache.taglibs.standard.util.XmlUtil

public class XmlUtil
extends Object

Utilities for working with JAXP and SAX.


Nested Class Summary
static class XmlUtil.JstlEntityResolver
          JSTL-specific implementation of EntityResolver, used by parsers.
static class XmlUtil.JstlUriResolver
          JSTL-specific implementation of URIResolver, used by transformers.
 
Constructor Summary
XmlUtil()
           
 
Method Summary
static DocumentBuilder newDocumentBuilder()
          Create a new DocumentBuilder configured for namespaces but not validating.
static Document newEmptyDocument()
          Create a new empty document.
static InputSource newInputSource(Reader reader, String systemId)
          Create an InputSource from a Reader.
static SAXSource newSAXSource(Reader reader, String systemId, XmlUtil.JstlEntityResolver entityResolver)
          Create a SAXSource from a Reader.
static Transformer newTransformer(Source source)
          Create a new Transformer from an XSLT.
static TransformerHandler newTransformerHandler()
          Create a new TransformerHandler.
static XMLReader newXMLReader(XmlUtil.JstlEntityResolver entityResolver)
          Create an XMLReader that resolves entities using JSTL semantics.
 
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

newEmptyDocument

public static Document newEmptyDocument()
Create a new empty document.

Returns:
a new empty document

newDocumentBuilder

public static DocumentBuilder newDocumentBuilder()
Create a new DocumentBuilder configured for namespaces but not validating.

Returns:
a new, configured DocumentBuilder

newTransformerHandler

public static TransformerHandler newTransformerHandler()
                                                throws TransformerConfigurationException
Create a new TransformerHandler.

Returns:
a new TransformerHandler
Throws:
TransformerConfigurationException

newTransformer

public static Transformer newTransformer(Source source)
                                  throws TransformerConfigurationException
Create a new Transformer from an XSLT.

Parameters:
source - the source of the XSLT.
Returns:
a new Transformer
Throws:
TransformerConfigurationException - if there was a problem creating the Transformer from the XSLT

newInputSource

public static InputSource newInputSource(Reader reader,
                                         String systemId)
Create an InputSource from a Reader. The systemId will be wrapped for use with JSTL's EntityResolver and UriResolver.

Parameters:
reader - the source of the XML
systemId - the system id
Returns:
a configured InputSource

newXMLReader

public static XMLReader newXMLReader(XmlUtil.JstlEntityResolver entityResolver)
                              throws ParserConfigurationException,
                                     SAXException
Create an XMLReader that resolves entities using JSTL semantics.

Parameters:
entityResolver - for resolving using JSTL semantics
Returns:
a new XMLReader
Throws:
ParserConfigurationException - if there was a configuration problem creating the reader
SAXException - if there was a problem creating the reader

newSAXSource

public static SAXSource newSAXSource(Reader reader,
                                     String systemId,
                                     XmlUtil.JstlEntityResolver entityResolver)
                              throws ParserConfigurationException,
                                     SAXException
Create a SAXSource from a Reader. Any entities will be resolved using JSTL semantics.

Parameters:
reader - the source of the XML
systemId - the system id
entityResolver - for resolving using JSTL semamtics
Returns:
a new SAXSource
Throws:
ParserConfigurationException - if there was a configuration problem creating the source
SAXException - if there was a problem creating the source


Copyright © 2001-2015 The Apache Software Foundation. All Rights Reserved.