Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mule.module.xml.util
Class XMLUtils

    java.lang.Object
      org.mule.util.XMLUtils
          org.mule.module.xml.util.XMLUtils

    public class XMLUtils

extends XMLUtils

General utility methods for working with XML.

Field Summary
`static String` | `APACHE_XML_FEATURES_VALIDATION_SCHEMA`
`static String` | `APACHE_XML_FEATURES_VALIDATION_SCHEMA_FULL_CHECKING`
`static String` | `JAXP_PROPERTIES_SCHEMA_LANGUAGE`
`static String` | `JAXP_PROPERTIES_SCHEMA_LANGUAGE_VALUE`
`static String` | `JAXP_PROPERTIES_SCHEMA_SOURCE`
`static String` | `TRANSFORMER_FACTORY_JDK5`

Constructor Summary
`XMLUtils()`

Method Summary
`static void` | `copy(javax.xml.stream.XMLStreamReader reader, javax.xml.stream.XMLStreamWriter writer)` Copies the reader to the writer.
`static void` | `copy(javax.xml.stream.XMLStreamReader reader, javax.xml.stream.XMLStreamWriter writer, boolean fragment)`
`static Transformer` | `getTransformer()`
`static List<Node>` | `select(String xpath, Node node)` Select a set of Node objects using the Xpath expression
`static Node` | `selectOne(String xpath, Node node)` Select a single XML node using an Xpath
`static String` | `selectValue(String xpath, Node node)` Select a single XML String value using an Xpath
`static org.dom4j.Document` | `toDocument(Object obj, MuleContext muleContext)`
`static org.dom4j.Document` | `toDocument(Object obj, String externalSchemaLocation, MuleContext muleContext)` Converts an object of unknown type to an org.dom4j.Document if possible.
`static Source` | `toStreamSource(javax.xml.stream.XMLInputFactory xmlInputFactory, boolean useStaxSource, InputStream stream)`
`static Document` | `toW3cDocument(Object payload)` Converts a payload to a `Document` representation.
`static String` | `toXml(Document dom)` Converts a DOM to an XML string.
`static Source` | `toXmlSource(javax.xml.stream.XMLInputFactory xmlInputFactory, boolean useStaxSource, Object src)` Convert our object to a Source type efficiently.
`static javax.xml.stream.XMLStreamReader` | `toXMLStreamReader(javax.xml.stream.XMLInputFactory factory, Object obj)` Returns an XMLStreamReader for an object of unknown type if possible.

Methods inherited from class org.mule.util.XMLUtils
`attributeName, elementToString, getTextChild, isLocalName`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TRANSFORMER_FACTORY_JDK5

    public static final String TRANSFORMER_FACTORY_JDK5

See Also:
  Constant Field Values

### APACHE_XML_FEATURES_VALIDATION_SCHEMA

    public static final String APACHE_XML_FEATURES_VALIDATION_SCHEMA

See Also:
  Constant Field Values

### APACHE_XML_FEATURES_VALIDATION_SCHEMA_FULL_CHECKING

    public static final String APACHE_XML_FEATURES_VALIDATION_SCHEMA_FULL_CHECKING

See Also:
  Constant Field Values

### JAXP_PROPERTIES_SCHEMA_SOURCE

    public static final String JAXP_PROPERTIES_SCHEMA_SOURCE

See Also:
  Constant Field Values

### JAXP_PROPERTIES_SCHEMA_LANGUAGE

    public static final String JAXP_PROPERTIES_SCHEMA_LANGUAGE

See Also:
  Constant Field Values

### JAXP_PROPERTIES_SCHEMA_LANGUAGE_VALUE

    public static final String JAXP_PROPERTIES_SCHEMA_LANGUAGE_VALUE

See Also:
  Constant Field Values

Constructor Detail

### XMLUtils

    public XMLUtils()

Method Detail

### toXml

    public static String toXml(Document dom)

  Converts a DOM to an XML string.

  Parameters:
    `dom` - the dome object to convert
  Returns:
    A string representation of the document

### getTransformer

    public static Transformer getTransformer()
                                      throws TransformerConfigurationException

  Returns:
    a new XSLT transformer
  Throws:
    `TransformerConfigurationException` - if no TransformerFactory can be located in the runtime environment.

### toDocument

    public static org.dom4j.Document toDocument(Object obj,
                                                MuleContext muleContext)
                                         throws Exception

  Throws:
    `Exception`

### toDocument

    public static org.dom4j.Document toDocument(Object obj,
                                                String externalSchemaLocation,
                                                MuleContext muleContext)
                                         throws Exception

  Converts an object of unknown type to an org.dom4j.Document if possible.

  Returns:
    null if object cannot be converted
  Throws:
    `org.dom4j.DocumentException` - if an error occurs while parsing
    `Exception`

### toW3cDocument

    public static Document toW3cDocument(Object payload)
                                  throws Exception

  Converts a payload to a `Document` representation.

  Reproduces the behavior from `toDocument(Object, MuleContext)` which works converting to `Document`.

  Parameters:
    `payload` - the payload to convert.
  Returns:
    a document from the payload or null if the payload is not a valid XML document.
  Throws:
    `Exception`

### toXMLStreamReader

    public static javax.xml.stream.XMLStreamReader toXMLStreamReader(javax.xml.stream.XMLInputFactory factory,
                                                                     Object obj)
                                                              throws javax.xml.stream.XMLStreamException

  Returns an XMLStreamReader for an object of unknown type if possible.

  Returns:
    null if no XMLStreamReader can be created for the object type
  Throws:
    `javax.xml.stream.XMLStreamException`

### toXmlSource

    public static Source toXmlSource(javax.xml.stream.XMLInputFactory xmlInputFactory,
                                     boolean useStaxSource,
                                     Object src)
                              throws Exception

  Convert our object to a Source type efficiently.

  Throws:
    `Exception`

### toStreamSource

    public static Source toStreamSource(javax.xml.stream.XMLInputFactory xmlInputFactory,
                                        boolean useStaxSource,
                                        InputStream stream)
                                 throws javax.xml.stream.XMLStreamException

  Throws:
    `javax.xml.stream.XMLStreamException`

### copy

    public static void copy(javax.xml.stream.XMLStreamReader reader,
                            javax.xml.stream.XMLStreamWriter writer)
                     throws javax.xml.stream.XMLStreamException

  Copies the reader to the writer. The start and end document methods must be handled on the writer manually. TODO: if the namespace on the reader has been declared previously to where we are in the stream, this probably won't work.

  Parameters:
    `reader` -
    `writer` -
  Throws:
    `javax.xml.stream.XMLStreamException`

### copy

    public static void copy(javax.xml.stream.XMLStreamReader reader,
                            javax.xml.stream.XMLStreamWriter writer,
                            boolean fragment)
                     throws javax.xml.stream.XMLStreamException

  Throws:
    `javax.xml.stream.XMLStreamException`

### selectOne

    public static Node selectOne(String xpath,
                                 Node node)
                          throws XPathExpressionException

  Select a single XML node using an Xpath

  Parameters:
    `xpath` - the XPath expression to evaluate
    `node` - the node (or document) to exaluate on
  Returns:
    the result of the evaluation.
  Throws:
    `XPathExpressionException` - if the XPath expression is malformed and cannot be parsed

### selectValue

    public static String selectValue(String xpath,
                                     Node node)
                              throws XPathExpressionException

  Select a single XML String value using an Xpath

  Parameters:
    `xpath` - the XPath expression to evaluate
    `node` - the node (or document) to evaluate on
  Returns:
    the result of the evaluation.
  Throws:
    `XPathExpressionException` - if the XPath expression is malformed and cannot be parsed

### select

    public static List<Node> select(String xpath,
                                    Node node)
                             throws XPathExpressionException

  Select a set of Node objects using the Xpath expression

  Parameters:
    `xpath` - the XPath expression to evaluate
    `node` - the node (or document) to evaluate on
  Returns:
    the result of the evaluation.
  Throws:
    `XPathExpressionException` - if the XPath expression is malformed and cannot be parsed

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2010 MuleSoft, Inc.. All Rights Reserved.