|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectno.sintef.xml.XmlHelper
XML helper class.
Method Summary | |
static org.w3c.dom.Document |
createDocument(org.w3c.dom.Element elem)
Create XML Document with the specified root element. |
static org.w3c.dom.Document |
createDocument(java.lang.String namespaceUri,
java.lang.String namespacePrefix,
java.lang.String rootElement,
org.w3c.dom.DocumentType doctype)
Create XML Document of the specified DocumentType and with a root Element with the specified namespace, namespace prefix and name. |
static java.lang.String |
genID()
Generate unique identifier. |
static org.w3c.dom.Document |
getDocument(java.net.URL url)
Get XML Document from the specified URL. |
static java.util.List |
getElements(org.w3c.dom.Element parent,
java.lang.String namespaceURI,
java.lang.String localName)
Get child Elements matching the specified name and namespace. |
static org.w3c.dom.Element |
getFirstElement(org.w3c.dom.Element parent,
java.lang.String namespaceURI,
java.lang.String localName)
Get first child Element matching the specified name and namespace. |
static javax.xml.transform.Transformer |
getIdentityTransformation()
Get the identity (null) transformation. |
static org.w3c.dom.Element |
getRootElement(org.w3c.dom.Node node)
Get document root element if Node is Document, otherwise cast node to Element if appropriate. |
static java.lang.String |
getText(org.w3c.dom.Element element)
Get text content of element. |
static java.lang.String |
getText(org.w3c.dom.Element parent,
java.lang.String namespaceURI,
java.lang.String localName)
Get text content of first child element matching the specified name and namespace. |
static javax.xml.transform.Transformer |
getTransformer(java.net.URL url,
org.apache.log4j.Logger logger)
Get the XSLT transformation from the specified URL. |
static org.w3c.dom.Document |
parse(org.xml.sax.InputSource is)
Parse XML Document from InputSource. |
static byte[] |
xmlToUtf8(org.w3c.dom.Node node,
boolean outputHeader)
Serialize XML node to byte array in UTF-8 format. |
static void |
xmlToUtf8(org.w3c.dom.Node node,
java.io.OutputStream os,
boolean outputHeader)
Serialize XML node to specified output stream in UTF-8 format. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static org.w3c.dom.Element getRootElement(org.w3c.dom.Node node)
node
- node to get Element for
public static org.w3c.dom.Element getFirstElement(org.w3c.dom.Element parent, java.lang.String namespaceURI, java.lang.String localName)
parent
- parent ElementnamespaceURI
- the URI of the namespace to matchlocalName
- the local name to match
public static java.util.List getElements(org.w3c.dom.Element parent, java.lang.String namespaceURI, java.lang.String localName)
parent
- parent ElementnamespaceURI
- the URI of the namespace to matchlocalName
- the local name to match
public static java.lang.String getText(org.w3c.dom.Element element)
element
- the element
public static java.lang.String getText(org.w3c.dom.Element parent, java.lang.String namespaceURI, java.lang.String localName)
parent
- parent elementnamespaceURI
- the URI of the namespace to matchlocalName
- the local name to match
public static org.w3c.dom.Document parse(org.xml.sax.InputSource is) throws XmlException, java.io.IOException
is
- the InputSource to parse from.
XmlException
- if XML document was malformed or other XML parsing error occured
java.io.IOException
- if IO error occured reading from InputSourcepublic static java.lang.String genID()
public static org.w3c.dom.Document createDocument(java.lang.String namespaceUri, java.lang.String namespacePrefix, java.lang.String rootElement, org.w3c.dom.DocumentType doctype)
namespaceUri
- URI of namespace for root elementnamespacePrefix
- prefix to use for root element namespacerootElement
- local name of root elementdoctype
- DocumentType of document
public static org.w3c.dom.Document createDocument(org.w3c.dom.Element elem)
elem
- the root element
public static javax.xml.transform.Transformer getTransformer(java.net.URL url, org.apache.log4j.Logger logger) throws XmlException
url
- URL to get the XSLT transformation from, or null to get identity (null) transformationlogger
- Logger to use for error messages
XmlException
- if error occurspublic static javax.xml.transform.Transformer getIdentityTransformation()
public static byte[] xmlToUtf8(org.w3c.dom.Node node, boolean outputHeader)
node
- the Node to serializeoutputHeader
- true if XML header should be added, false otherwise
public static void xmlToUtf8(org.w3c.dom.Node node, java.io.OutputStream os, boolean outputHeader)
node
- the Node to serializeos
- the OutputStream to serialize tooutputHeader
- true if XML header should be added, false otherwisepublic static org.w3c.dom.Document getDocument(java.net.URL url) throws XmlException
url
- URL to parse from
XmlException
- if error occurs
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |