|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.semaine.util.XMLTool
public class XMLTool
Utility methods for working wth XML documents.
| Constructor Summary | |
|---|---|
XMLTool()
|
|
| Method Summary | |
|---|---|
static org.w3c.dom.Element |
appendChildElement(org.w3c.dom.Node node,
java.lang.String childName)
Create a child element with the given name and append it below node. |
static org.w3c.dom.Element |
appendChildElement(org.w3c.dom.Node node,
java.lang.String childName,
java.lang.String childNamespace)
Create a child element with the given name and namespace, and append it below node. |
static org.w3c.dom.Element |
createElement(org.w3c.dom.Document doc,
java.lang.String elementName)
In the given document, create a new element of the given name, with the same namespace as the document element. |
static org.w3c.dom.Element |
createElement(org.w3c.dom.Document doc,
java.lang.String elementName,
java.lang.String namespace)
In the given document, create a new element with the given name and the given namespace. |
static java.lang.String |
document2String(org.w3c.dom.Document document)
Document type to String format conversion |
static java.lang.String |
getAttributeIfAvailable(org.w3c.dom.Element e,
java.lang.String attributeName)
For the given element, return the value of the given attribute if it exists, or null if it doesn't exist. |
static org.w3c.dom.Element |
getChildElementByTagNameNS(org.w3c.dom.Node node,
java.lang.String childName,
java.lang.String childNamespace)
Get the direct child of node that is an element with the given tag name and namespace. |
static java.util.List<org.w3c.dom.Element> |
getChildrenByTagNameNS(org.w3c.dom.Node node,
java.lang.String childName,
java.lang.String childNamespace)
Get a list of all direct children with the given tag name and namespace. |
static boolean |
isSameNamespace(java.lang.String namespaceA,
java.lang.String namespaceB)
Determine whether the two namespaces are the same. |
static java.lang.String |
mergeTwoXMLFiles(java.lang.String xmlFileContent1,
java.lang.String xmlFileContent2,
java.io.InputStream xmlStyleSheet,
java.lang.String refCodeName)
Merge two XML files using XSLT |
static java.lang.String |
needAttribute(org.w3c.dom.Element e,
java.lang.String attributeName)
For the given element, return the value of the given attribute if it exists, or complain with a MessageFormatException if it doesn't exist. |
static org.w3c.dom.Element |
needChildElementByTagNameNS(org.w3c.dom.Node node,
java.lang.String childName,
java.lang.String childNamespace)
Same as getChildElementByTagNameNS(Node, String, String), but
throw a MessageFormatException if there is no such child element. |
static org.w3c.dom.Document |
newDocument(java.lang.String rootTagname,
java.lang.String namespace)
Create a new document with the given name and namespace for the root element. |
static org.w3c.dom.Document |
newDocument(java.lang.String rootTagname,
java.lang.String namespace,
java.lang.String version)
Create a new document with the given name and namespace for the root element, and set the 'version' attribute of the root element to the given value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XMLTool()
| Method Detail |
|---|
public static org.w3c.dom.Document newDocument(java.lang.String rootTagname,
java.lang.String namespace)
rootTagname - namespace - the namespace URI, e.g. http://www.w3.org/2003/04/emma,
or null if no namespace is to be associated with the new element.
public static org.w3c.dom.Document newDocument(java.lang.String rootTagname,
java.lang.String namespace,
java.lang.String version)
rootTagname - namespace - the namespace URI, e.g. http://www.w3.org/2003/04/emma,
or null if no namespace is to be associated with the new element.version - a value to add to the 'version' attribute of the root element
public static org.w3c.dom.Element createElement(org.w3c.dom.Document doc,
java.lang.String elementName)
doc - a documentelementName - the name of the new element
java.lang.NullPointerException - if doc or elementName is null.
public static org.w3c.dom.Element createElement(org.w3c.dom.Document doc,
java.lang.String elementName,
java.lang.String namespace)
doc - elementName - namespace - the namespace URI, e.g. http://www.w3.org/2003/04/emma,
or null if no namespace is to be associated with the new element.
java.lang.NullPointerException - if doc or elementName is null.
public static org.w3c.dom.Element appendChildElement(org.w3c.dom.Node node,
java.lang.String childName)
node - childName -
public static org.w3c.dom.Element appendChildElement(org.w3c.dom.Node node,
java.lang.String childName,
java.lang.String childNamespace)
node - childName - childNamespace - the namespace of the child, or null if no namespace is desired.
public static org.w3c.dom.Element getChildElementByTagNameNS(org.w3c.dom.Node node,
java.lang.String childName,
java.lang.String childNamespace)
node - childName - childNamespace -
public static org.w3c.dom.Element needChildElementByTagNameNS(org.w3c.dom.Node node,
java.lang.String childName,
java.lang.String childNamespace)
throws MessageFormatException
getChildElementByTagNameNS(Node, String, String), but
throw a MessageFormatException if there is no such child element.
node - childName - childNamespace -
MessageFormatException - if there is no such child,
i.e. when getChildElementByTagNameNS() would return null.
public static java.lang.String needAttribute(org.w3c.dom.Element e,
java.lang.String attributeName)
throws MessageFormatException
e - the element whose attribute to returnattributeName - the name of the attribute to look up.
MessageFormatException - if the attribute doesn't exist.
public static java.lang.String getAttributeIfAvailable(org.w3c.dom.Element e,
java.lang.String attributeName)
e - attributeName -
public static java.util.List<org.w3c.dom.Element> getChildrenByTagNameNS(org.w3c.dom.Node node,
java.lang.String childName,
java.lang.String childNamespace)
node - childName - childNamespace -
MessageFormatException
public static boolean isSameNamespace(java.lang.String namespaceA,
java.lang.String namespaceB)
namespaceA - a string representing a namespace, or nullnamespaceB - a string representing a namespace, or null
public static java.lang.String mergeTwoXMLFiles(java.lang.String xmlFileContent1,
java.lang.String xmlFileContent2,
java.io.InputStream xmlStyleSheet,
java.lang.String refCodeName)
throws java.lang.Exception,
java.io.FileNotFoundException
xmlFileContent1, - first XML file contentxmlFileContent2, - second XML file contentxmlStyleSheet, - XSL style sheet as a inputstreamrefCodeName, - code name used in xsl sheet to refer xmlFile2 (example: semaine.mary.intonation )
java.lang.Exception
java.io.FileNotFoundException
public static java.lang.String document2String(org.w3c.dom.Document document)
throws SystemConfigurationException
document -
java.lang.Exception
java.io.FileNotFoundException
SystemConfigurationException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||