railo.runtime.text.xml
Class XMLUtil

java.lang.Object
  extended by railo.runtime.text.xml.XMLUtil

public final class XMLUtil
extends Object


Field Summary
static Collection.Key XMLATTRIBUTES
           
static Collection.Key XMLCDATA
           
static Collection.Key XMLCHILDREN
           
static Collection.Key XMLCOMMENT
           
static Collection.Key XMLNAME
           
static Collection.Key XMLNODES
           
static Collection.Key XMLNSPREFIX
           
static Collection.Key XMLNSURI
           
static Collection.Key XMLPARENT
           
static Collection.Key XMLROOT
           
static Collection.Key XMLTEXT
           
static Collection.Key XMLTYPE
           
static Collection.Key XMLVALUE
           
 
Constructor Summary
XMLUtil()
           
 
Method Summary
static int childNodesLength(Node node, short type, boolean caseSensitive, String filter)
           
static XMLReader createXMLReader(String oprionalDefaultSaxParser)
           
static String escapeXMLString(String xmlStr)
           
static Element[] getChildElementsAsArray(Node node)
          return all Element Children of a node
static Node getChildNode(Node node, short type, boolean caseSensitive, String filter, int index)
           
static ArrayNodeList getChildNodes(Node node, short type)
          return all Children of a node by a defined type as Node List
static ArrayNodeList getChildNodes(Node node, short type, boolean caseSensitive, String filter)
           
static Node[] getChildNodesAsArray(Node node, short type)
          return all Children of a node by a defined type as Node Array
static Node[] getChildNodesAsArray(Node node, short type, boolean caseSensitive, String filter)
           
static List<Node> getChildNodesAsList(Node node, short type, boolean caseSensitive, String filter)
           
static Element getChildWithName(String name, Element el)
           
static Document getDocument(Node node)
          return the Owner Document of a Node
static Document getDocument(NodeList nodeList)
          return the Owner Document of a Node List
static Node getParentNode(Node node, boolean caseSensitive)
           
static Object getProperty(Node node, Collection.Key key)
           
static Object getProperty(Node node, Collection.Key k, boolean caseSensitive)
          returns a property from a XMl Node
static Object getProperty(Node node, Collection.Key k, boolean caseSensitive, Object defaultValue)
          returns a property from a XMl Node (Expression Less)
static Object getProperty(Node node, Collection.Key key, Object defaultValue)
           
static Element getRootElement(Node node, boolean caseSensitive)
          return the root Element from a node
static TransformerFactory getTransformerFactory()
           
static String getTypeAsString(Node node, boolean cftype)
          returns the Node Type As String
static boolean isCaseSensitve(Node node)
           
static boolean nameEqual(Node node, String name, boolean caseSensitive)
          check if given name is equal to name of the element (with and without namespace)
static Document newDocument()
          returns a new Empty XMl Document
static Document parse(InputSource xml, InputSource validator, boolean isHtml)
          parse XML/HTML String to a XML DOM representation
static void prependChild(Element parent, Element child)
          adds a child at the first place
static Object removeProperty(Node node, Collection.Key k, boolean caseSensitive)
          removes child from a node
static void replaceChild(Node newChild, Node oldChild)
           
static void setFirst(Node parent, Node node)
           
static Object setProperty(Node node, Collection.Key k, Object value)
          sets a node to a node
static Object setProperty(Node node, Collection.Key k, Object value, boolean caseSensitive)
           
static Object setProperty(Node node, Collection.Key key, Object value, boolean caseSensitive, Object defaultValue)
           
static Object setPropertyEL(Node node, Collection.Key key, Object value)
          sets a node to a node (Expression Less)
static InputSource toInputSource(PageContext pc, Object value)
           
static InputSource toInputSource(PageContext pc, String xml)
           
static InputSource toInputSource(PageContext pc, String xml, boolean canBePath)
           
static InputSource toInputSource(Resource res)
           
static String transform(Document doc, InputSource xsl)
          transform a XML Document to a other format, with help of a XSL Stylesheet
static String transform(Document doc, InputSource xsl, Map parameters)
          transform a XML Document to a other format, with help of a XSL Stylesheet
static String transform(InputSource xml, InputSource xsl)
          transform a XML Object to a other format, with help of a XSL Stylesheet
static String transform(InputSource xml, InputSource xsl, Map parameters)
          transform a XML Object to a other format, with help of a XSL Stylesheet
static String unescapeXMLString(String str)
           
static String unescapeXMLString2(String str)
           
static Struct validate(InputSource xml, InputSource schema, String strSchema)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XMLCOMMENT

public static final Collection.Key XMLCOMMENT

XMLTEXT

public static final Collection.Key XMLTEXT

XMLCDATA

public static final Collection.Key XMLCDATA

XMLCHILDREN

public static final Collection.Key XMLCHILDREN

XMLNODES

public static final Collection.Key XMLNODES

XMLNSURI

public static final Collection.Key XMLNSURI

XMLNSPREFIX

public static final Collection.Key XMLNSPREFIX

XMLROOT

public static final Collection.Key XMLROOT

XMLPARENT

public static final Collection.Key XMLPARENT

XMLNAME

public static final Collection.Key XMLNAME

XMLTYPE

public static final Collection.Key XMLTYPE

XMLVALUE

public static final Collection.Key XMLVALUE

XMLATTRIBUTES

public static final Collection.Key XMLATTRIBUTES
Constructor Detail

XMLUtil

public XMLUtil()
Method Detail

unescapeXMLString

public static String unescapeXMLString(String str)

unescapeXMLString2

public static String unescapeXMLString2(String str)

escapeXMLString

public static String escapeXMLString(String xmlStr)

getTransformerFactory

public static TransformerFactory getTransformerFactory()
Returns:
returns a singelton TransformerFactory

parse

public static final Document parse(InputSource xml,
                                   InputSource validator,
                                   boolean isHtml)
                            throws SAXException,
                                   IOException
parse XML/HTML String to a XML DOM representation

Parameters:
xml - XML InputSource
isHtml - is a HTML or XML Object
Returns:
parsed Document
Throws:
SAXException
IOException
ParserConfigurationException

setPropertyEL

public static Object setPropertyEL(Node node,
                                   Collection.Key key,
                                   Object value)
sets a node to a node (Expression Less)

Parameters:
node -
key -
value -
Returns:
Object set

setProperty

public static Object setProperty(Node node,
                                 Collection.Key key,
                                 Object value,
                                 boolean caseSensitive,
                                 Object defaultValue)

setProperty

public static Object setProperty(Node node,
                                 Collection.Key k,
                                 Object value)
                          throws PageException
sets a node to a node

Parameters:
node -
key -
value -
Returns:
Object set
Throws:
PageException

setProperty

public static Object setProperty(Node node,
                                 Collection.Key k,
                                 Object value,
                                 boolean caseSensitive)
                          throws PageException
Throws:
PageException

replaceChild

public static void replaceChild(Node newChild,
                                Node oldChild)

getProperty

public static Object getProperty(Node node,
                                 Collection.Key key,
                                 Object defaultValue)

getProperty

public static Object getProperty(Node node,
                                 Collection.Key k,
                                 boolean caseSensitive,
                                 Object defaultValue)
returns a property from a XMl Node (Expression Less)

Parameters:
node -
key -
caseSensitive -
Returns:
Object matching key

getProperty

public static Object getProperty(Node node,
                                 Collection.Key key)
                          throws SAXException
Throws:
SAXException

getProperty

public static Object getProperty(Node node,
                                 Collection.Key k,
                                 boolean caseSensitive)
                          throws SAXException
returns a property from a XMl Node

Parameters:
node -
key -
caseSensitive -
Returns:
Object matching key
Throws:
SAXException

nameEqual

public static boolean nameEqual(Node node,
                                String name,
                                boolean caseSensitive)
check if given name is equal to name of the element (with and without namespace)

Parameters:
node -
k -
caseSensitive -
Returns:

isCaseSensitve

public static boolean isCaseSensitve(Node node)

removeProperty

public static Object removeProperty(Node node,
                                    Collection.Key k,
                                    boolean caseSensitive)
removes child from a node

Parameters:
node -
key -
caseSensitive -
Returns:
removed property

getRootElement

public static Element getRootElement(Node node,
                                     boolean caseSensitive)
return the root Element from a node

Parameters:
node - node to get root element from
caseSensitive -
Returns:
Root Element

getParentNode

public static Node getParentNode(Node node,
                                 boolean caseSensitive)

newDocument

public static Document newDocument()
                            throws ParserConfigurationException,
                                   FactoryConfigurationError
returns a new Empty XMl Document

Returns:
new Document
Throws:
ParserConfigurationException
FactoryConfigurationError

getDocument

public static Document getDocument(NodeList nodeList)
                            throws XMLException
return the Owner Document of a Node List

Parameters:
nodeList -
Returns:
XML Document
Throws:
XMLException

getDocument

public static Document getDocument(Node node)
return the Owner Document of a Node

Parameters:
node -
Returns:
XML Document

getChildNodes

public static ArrayNodeList getChildNodes(Node node,
                                          short type)
return all Children of a node by a defined type as Node List

Parameters:
node - node to get children from
type - type of returned node
filter -
caseSensitive -
Returns:
all matching child node

childNodesLength

public static int childNodesLength(Node node,
                                   short type,
                                   boolean caseSensitive,
                                   String filter)

getChildNodes

public static ArrayNodeList getChildNodes(Node node,
                                          short type,
                                          boolean caseSensitive,
                                          String filter)

getChildNodesAsList

public static List<Node> getChildNodesAsList(Node node,
                                             short type,
                                             boolean caseSensitive,
                                             String filter)

getChildNode

public static Node getChildNode(Node node,
                                short type,
                                boolean caseSensitive,
                                String filter,
                                int index)

getChildNodesAsArray

public static Node[] getChildNodesAsArray(Node node,
                                          short type)
return all Children of a node by a defined type as Node Array

Parameters:
node - node to get children from
type - type of returned node
filter -
caseSensitive -
Returns:
all matching child node

getChildNodesAsArray

public static Node[] getChildNodesAsArray(Node node,
                                          short type,
                                          boolean caseSensitive,
                                          String filter)

getChildElementsAsArray

public static Element[] getChildElementsAsArray(Node node)
return all Element Children of a node

Parameters:
node - node to get children from
Returns:
all matching child node

transform

public static String transform(InputSource xml,
                               InputSource xsl)
                        throws TransformerException,
                               SAXException,
                               IOException
transform a XML Object to a other format, with help of a XSL Stylesheet

Parameters:
xml - xml to convert
xsl - xsl used to convert
Returns:
resulting string
Throws:
TransformerException
SAXException
IOException

transform

public static String transform(InputSource xml,
                               InputSource xsl,
                               Map parameters)
                        throws TransformerException,
                               SAXException,
                               IOException
transform a XML Object to a other format, with help of a XSL Stylesheet

Parameters:
xml - xml to convert
xsl - xsl used to convert
parameters - parameters used to convert
Returns:
resulting string
Throws:
TransformerException
SAXException
IOException

transform

public static String transform(Document doc,
                               InputSource xsl)
                        throws TransformerException
transform a XML Document to a other format, with help of a XSL Stylesheet

Parameters:
xml - xml to convert
xsl - xsl used to convert
Returns:
resulting string
Throws:
TransformerException
SAXException
IOException

transform

public static String transform(Document doc,
                               InputSource xsl,
                               Map parameters)
                        throws TransformerException
transform a XML Document to a other format, with help of a XSL Stylesheet

Parameters:
xml - xml to convert
xsl - xsl used to convert
parameters - parameters used to convert
Returns:
resulting string
Throws:
TransformerException
SAXException
IOException

getTypeAsString

public static String getTypeAsString(Node node,
                                     boolean cftype)
returns the Node Type As String

Parameters:
node -
cftype -
Returns:

getChildWithName

public static Element getChildWithName(String name,
                                       Element el)

toInputSource

public static InputSource toInputSource(Resource res)
                                 throws IOException
Throws:
IOException

toInputSource

public static InputSource toInputSource(PageContext pc,
                                        Object value)
                                 throws IOException,
                                        ExpressionException
Throws:
IOException
ExpressionException

toInputSource

public static InputSource toInputSource(PageContext pc,
                                        String xml)
                                 throws IOException,
                                        ExpressionException
Throws:
IOException
ExpressionException

toInputSource

public static InputSource toInputSource(PageContext pc,
                                        String xml,
                                        boolean canBePath)
                                 throws IOException,
                                        ExpressionException
Throws:
IOException
ExpressionException

validate

public static Struct validate(InputSource xml,
                              InputSource schema,
                              String strSchema)
                       throws XMLException
Throws:
XMLException

prependChild

public static void prependChild(Element parent,
                                Element child)
adds a child at the first place

Parameters:
parent -
child -

setFirst

public static void setFirst(Node parent,
                            Node node)

createXMLReader

public static XMLReader createXMLReader(String oprionalDefaultSaxParser)
                                 throws SAXException
Throws:
SAXException


Copyright © 2012 Railo