Class XmlUtils

java.lang.Object
org.craftercms.core.util.XmlUtils

public class XmlUtils extends Object
Author:
Sumer Jabri, Alfonso Vásquez
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    documentToPrettyString(org.dom4j.Document document)
    Returns the given document as a XML string in a "pretty" format.
    static List<org.dom4j.Node>
    selectNodes(org.dom4j.Node node, String xpathQuery, Map<String,String> namespaceUris)
    Executes the specified namespace aware XPath query as a multiple node query, returning the resulting list of nodes.
    static List<String>
    selectNodeValues(org.dom4j.Node node, String xpathQuery)
    Executes the specified XPath query as a multiple node query, returning the text values of the resulting list of nodes.
    static List<String>
    selectNodeValues(org.dom4j.Node node, String xpathQuery, Map<String,String> namespaceUris)
    Executes the specified namespace aware XPath query as a multiple node query, returning the text values of the resulting list of nodes.
    static Object
    selectObject(org.dom4j.Node node, String xpathQuery)
    Executes an XPath query to retrieve an object.
    static org.dom4j.Node
    selectSingleNode(org.dom4j.Node node, String xpathQuery, Map<String,String> namespaceUris)
    Executes the specified namespace aware XPath query as a single node query, returning the resulting single node.
    static String
    selectSingleNodeValue(org.dom4j.Node node, String xpathQuery)
    Executes the specified XPath query as a single node query, returning the text value of the resulting single node.
    static String
    selectSingleNodeValue(org.dom4j.Node node, String xpathQuery, Map<String,String> namespaceUris)
    Executes the specified namespace aware XPath query as a single node query, returning the text value of the resulting single node.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • XmlUtils

      public XmlUtils()
  • Method Details

    • selectObject

      public static Object selectObject(org.dom4j.Node node, String xpathQuery)
      Executes an XPath query to retrieve an object. Normally, if the XPath result doesn't have a result, an empty collection is returned. This object checks that case and returns null accordingly.
    • selectSingleNodeValue

      public static String selectSingleNodeValue(org.dom4j.Node node, String xpathQuery)
      Executes the specified XPath query as a single node query, returning the text value of the resulting single node.
    • selectSingleNodeValue

      public static String selectSingleNodeValue(org.dom4j.Node node, String xpathQuery, Map<String,String> namespaceUris)
      Executes the specified namespace aware XPath query as a single node query, returning the text value of the resulting single node.
    • selectNodeValues

      public static List<String> selectNodeValues(org.dom4j.Node node, String xpathQuery)
      Executes the specified XPath query as a multiple node query, returning the text values of the resulting list of nodes.
    • selectNodeValues

      public static List<String> selectNodeValues(org.dom4j.Node node, String xpathQuery, Map<String,String> namespaceUris)
      Executes the specified namespace aware XPath query as a multiple node query, returning the text values of the resulting list of nodes.
    • selectSingleNode

      public static org.dom4j.Node selectSingleNode(org.dom4j.Node node, String xpathQuery, Map<String,String> namespaceUris)
      Executes the specified namespace aware XPath query as a single node query, returning the resulting single node.
    • selectNodes

      public static List<org.dom4j.Node> selectNodes(org.dom4j.Node node, String xpathQuery, Map<String,String> namespaceUris)
      Executes the specified namespace aware XPath query as a multiple node query, returning the resulting list of nodes.
    • documentToPrettyString

      public static String documentToPrettyString(org.dom4j.Document document)
      Returns the given document as a XML string in a "pretty" format.
      Parameters:
      document -
      Returns:
      the document as an XML string