de.init.its.util
Class XMLUtil

java.lang.Object
  extended by de.init.its.util.XMLUtil

public class XMLUtil
extends java.lang.Object

Some useful XML utils

Author:
mkandora

Constructor Summary
XMLUtil()
           
 
Method Summary
static boolean containsAttributeWithPrefix(org.w3c.dom.Node node, java.lang.String prefix)
          Returns true, if node has an attribute with provided prefix
static org.w3c.dom.Node copyFrom(org.w3c.dom.Document doc, org.w3c.dom.Node node, java.lang.String namespaceprefix)
          Creates a copy from the given node
static org.w3c.dom.Element createItsNode(org.w3c.dom.Document doc, org.w3c.dom.Node bookmarkNode, ItsElementManager manager)
          Creates a new itsNode
static java.util.Map<java.lang.String,java.lang.String> extractAttributes(org.w3c.dom.Node node)
          Extracts all attributes from a given node and returns it as a map
static java.lang.String extractId(org.w3c.dom.Node node)
          Extracts the its id from a given bookmark node
static void fetchNS(org.w3c.dom.Document doc, java.util.Map<java.lang.String,java.lang.String> map)
          Retrieves all namespaces as defined by the root element from given Document Beta function to get all available namespacess from root element.
static boolean hasAttribute(org.w3c.dom.Element e, java.lang.String attributeName)
          Returns true, if element has desired attribute
static void setAttribute(java.lang.String name, java.lang.String value, org.w3c.dom.Node... node)
          Sets the same attribute for multiple elements
static void setAttributeNS(java.lang.String namespaceURI, java.lang.String name, java.lang.String value, org.w3c.dom.Node... node)
          Sets a namespace attribute
 
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

fetchNS

public static void fetchNS(org.w3c.dom.Document doc,
                           java.util.Map<java.lang.String,java.lang.String> map)
Retrieves all namespaces as defined by the root element from given Document Beta function to get all available namespacess from root element. FIX if there is a better option.

Parameters:
doc - the document
map - a map container to store all namespaces

extractAttributes

public static java.util.Map<java.lang.String,java.lang.String> extractAttributes(org.w3c.dom.Node node)
Extracts all attributes from a given node and returns it as a map

Parameters:
node - the node to retrieve all attributes
Returns:

setAttribute

public static void setAttribute(java.lang.String name,
                                java.lang.String value,
                                org.w3c.dom.Node... node)
Sets the same attribute for multiple elements

Parameters:
name - the name of the attribute
value - the value of the attribute
node - the nodes to set the same attribute for

setAttributeNS

public static void setAttributeNS(java.lang.String namespaceURI,
                                  java.lang.String name,
                                  java.lang.String value,
                                  org.w3c.dom.Node... node)
Sets a namespace attribute

Parameters:
namespaceURI -
name -
value -
node -

hasAttribute

public static boolean hasAttribute(org.w3c.dom.Element e,
                                   java.lang.String attributeName)
Returns true, if element has desired attribute

Parameters:
e - the element to look for specific attribute
attributeName - the attribute name
Returns:
true, if attribute exists

containsAttributeWithPrefix

public static boolean containsAttributeWithPrefix(org.w3c.dom.Node node,
                                                  java.lang.String prefix)
Returns true, if node has an attribute with provided prefix

Parameters:
node - the node to look for desired attribute prefix
prefix - the attribute prefix
Returns:
true, if attribute with prefix exists

extractId

public static java.lang.String extractId(org.w3c.dom.Node node)
Extracts the its id from a given bookmark node

Parameters:
node -
Returns:

copyFrom

public static org.w3c.dom.Node copyFrom(org.w3c.dom.Document doc,
                                        org.w3c.dom.Node node,
                                        java.lang.String namespaceprefix)
Creates a copy from the given node

Parameters:
doc -
node -
Returns:

createItsNode

public static org.w3c.dom.Element createItsNode(org.w3c.dom.Document doc,
                                                org.w3c.dom.Node bookmarkNode,
                                                ItsElementManager manager)
Creates a new itsNode

Parameters:
doc -
bookmarkNode -
manager -
Returns: