Class XMLUtils

java.lang.Object
es.uji.crypto.xades.jxades.util.XMLUtils

public final class XMLUtils extends Object
Common XML Tasks
  • Field Details

    • charset

      private static Charset charset
  • Constructor Details

    • XMLUtils

      public XMLUtils()
  • Method Details

    • getAttributeByName

      public static String getAttributeByName(Node node, String name)
      Get the attribute with given name's value
      Parameters:
      node - the node which attribute's value is returned
      name - name of the attribute
      Returns:
      the value af the attribute
    • getElementTextValueDeprecated

      public static String getElementTextValueDeprecated(Element parentNode)
      Get the data of the element , no matter whether it is TXT ot CDATA
      Parameters:
      parentNode - the node which data is returned
      Returns:
      the TEXT or CDATA of the parentNode
    • setElementTextValue

      public static void setElementTextValue(Element e, String data)
      Sets element TEXT data
      Parameters:
      e - the element
      data - the new data
    • setElementCDataValue

      public static void setElementCDataValue(Element e, String data)
      Sets element CDATA data
      Parameters:
      e - the lement
      data - the new data
    • getElementCDataValue

      public static String getElementCDataValue(Element e)
      Gets CDATA value of an element
      Parameters:
      e - the element
      Returns:
      CDATA value of element e
    • getElementCDataNode

      public static CDATASection getElementCDataNode(Element element)
      Returns element's CDATA Node
      Parameters:
      element - the element which CDATA node is returned
      Returns:
      CDATA node
    • getElementTextNode

      public static Text getElementTextNode(Element element)
      Returns element's TEXT Node
      Parameters:
      element - the element which TEXT node is returned
      Returns:
      TEXT node
    • getChildNodeByType

      private static Node getChildNodeByType(Element element, short nodeType)
    • writeXML

      public static void writeXML(File file, Node node) throws FileNotFoundException
      Throws:
      FileNotFoundException
    • writeXML

      public static void writeXML(OutputStream outStream, Node node)
    • writeXML

      public static void writeXML(OutputStream outStream, Node node, boolean indent)
    • writeXML

      public static void writeXML(Writer writer, Node node, boolean indent)
      Writes the specified document to the given file. The default encoding is UTF-8.
      Parameters:
      out - the output File
      document - the document to be writen
    • writeXML

      public static void writeXML(Writer writer, Document document, String doctypeSystem, String doctypePublic)
    • getChildElementByChain

      public static Element getChildElementByChain(Element element, String[] chain, boolean create)
      Returns the element which is at the end of the specified chain ...
      Parameters:
      element -
      chain -
      Returns:
    • createLastPathComponent

      public static Element createLastPathComponent(Document doc, String[] path)
      Creates (only if necessary) and returns the element which is at the end of the specified path.
      Parameters:
      doc - the target document where the specified path should be created
      path - a dot separated string indicating the path to be created
      Returns:
      the component at the end of the newly created path.
    • getChildElementByTagNameNS

      public static Element getChildElementByTagNameNS(Element parent, String tagName, String nsName)
    • getChildElementByTagName

      public static Element getChildElementByTagName(Element parent, String tagName)
      Returns the child element with the specified tagName for the specified parent element
      Parameters:
      parent -
      tagName -
      Returns:
    • getChildElementsByTagNameNS

      public static List<Element> getChildElementsByTagNameNS(Element parent, String tagName, String nsName)
    • getChildElementsByTagName

      public static List<Element> getChildElementsByTagName(Element parent, String tagName)
    • printChildElements

      public static void printChildElements(Element parent, PrintStream out, boolean deep, String prefix)
      Used for debuging
      Parameters:
      parent - Element
      out - PrintStream
      deep - boolean
      prefix - String