|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.bbk.dcs.automed.xml.utilities.XMLUtilities
public class XMLUtilities
Implements useful operation on nodes.
Field Summary | |
---|---|
private static java.lang.String |
XML_ENCODING
|
private static java.lang.String |
XML_VERSION
|
Constructor Summary | |
---|---|
XMLUtilities()
|
Method Summary | |
---|---|
static org.w3c.dom.Document |
addGenericRoot(org.w3c.dom.Document doc,
java.lang.String newRootName)
Method that adds a generic root named newRootName on top of the old root and returns the new document. |
static void |
collapseWhiteSpace(org.w3c.dom.Node n)
|
static java.lang.String |
collapseWhitespace(java.lang.String s)
|
static org.w3c.dom.Document |
createDOMDocument(org.w3c.dom.Element root,
java.lang.String filePath,
java.lang.String fileName)
Creates a new file named "fileName" in path "filePath", with only the root, named "rootName", and returns its DOM representation. |
static org.w3c.dom.Document |
duplicateDOM(org.w3c.dom.Document doc)
Method that creates and returns a new DOM representation of the input one - no validation on either doc. |
static org.w3c.dom.Document |
duplicateDOM(java.lang.String URI,
boolean validating)
|
static int |
findPath(org.w3c.dom.Node supposedChild,
org.w3c.dom.Node supposedParent,
java.util.LinkedList goingUpPath,
java.util.LinkedList goingDownPath)
IMPORTANT: Both goingUpPath and goingDownPath lists contain the common ancestor. |
static float |
getAverageFanOut(org.w3c.dom.Document document)
|
static int |
getChildCount(org.w3c.dom.Node parentNode)
Counts the children of the given node. |
private static javax.xml.parsers.DocumentBuilderFactory |
getDBFactory()
|
static int |
getDepth(org.w3c.dom.Document document)
|
static int |
getElementChildCount(org.w3c.dom.Node parentNode)
Counts the element children of the given node. |
static java.util.List |
getElementChildren(org.w3c.dom.Element e)
|
static java.util.List |
getElementChildren(org.w3c.dom.Element e,
java.lang.String tagName)
|
static java.util.List |
getElementLevel(org.w3c.dom.Node n,
int level)
Returns all the element nodes in a given level. |
static int |
getElementNodeOrder(org.w3c.dom.Element n)
Returns the order of element node n in its parent's children NodeList - takes into account only elements. |
static java.lang.String |
getElementPathExpression(org.w3c.dom.Element e)
|
static org.w3c.dom.Document |
getEmptyDocument(java.lang.String rootName)
|
static org.w3c.dom.Document |
getEmptyDOM(java.lang.String rootName)
|
static java.util.List |
getLevel(org.w3c.dom.Node n,
int level)
Returns all the nodes in a given level. |
static int |
getNodeDepth(org.w3c.dom.Node n)
Returns the depth of node n. |
static int |
getNodeOrder(org.w3c.dom.Node n)
|
static int |
getTextChildCount(org.w3c.dom.Node parentNode)
Counts the number of text chidren of the input node. |
static java.util.List |
getTextChildren(org.w3c.dom.Element e)
|
static int |
getTextNodeOrder(org.w3c.dom.Node n)
|
static java.util.List |
getTextNodes(org.w3c.dom.Element e)
|
static int |
getTransformationPathwayLength(java.lang.String sourceSchemaName,
java.lang.String targetSchemaName)
Prints out the transformation pathway created by the schema transformation algorithm. |
static boolean |
hasTextNodes(org.w3c.dom.Element n)
|
private static void |
helpGetElementLevel(java.util.List levelList,
org.w3c.dom.Node currentNode,
int level)
Method complementary to getLevel |
private static void |
helpGetLevel(java.util.List levelList,
org.w3c.dom.Node currentNode,
int level)
Method complementary to getLevel |
static boolean |
isCDataNode(org.w3c.dom.Node n)
Returns true if node n is a CData node, false otherwise |
static boolean |
isElementNode(org.w3c.dom.Node n)
Returns true if node n is an element node, false otherwise |
static boolean |
isPCDataNode(org.w3c.dom.Node n)
Returns true if node n is a PCData node, false otherwise |
static boolean |
isTextNode(org.w3c.dom.Node n)
Returns true if node n is a text node, false otherwise |
static org.w3c.dom.Document |
parseFile(java.lang.String inputFile,
boolean validating)
Parses the input file and returns its DOM representation |
static org.w3c.dom.Document |
parseFileNS(java.lang.String inputFile,
boolean validating)
Parses the input file and returns its DOM representation |
static org.w3c.dom.Document |
parseString(java.lang.String inputString,
boolean validating)
|
static org.w3c.dom.Document |
parseStringNS(java.lang.String inputString,
boolean validating)
|
static void |
writeDOM(org.w3c.dom.Document doc,
java.io.File f)
|
static void |
writeDOM(org.w3c.dom.Document doc,
java.lang.String url)
Serializes the input DOM representation into file "url". |
static void |
writeDOM(org.w3c.dom.Document doc,
java.lang.String filePath,
java.lang.String fileName)
Serializes the input DOM representation into file "fileName" in path "filePath". |
static void |
writeDOM(org.w3c.dom.Node doc,
java.io.File f)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String XML_VERSION
private static final java.lang.String XML_ENCODING
Constructor Detail |
---|
public XMLUtilities()
Method Detail |
---|
public static java.util.List getElementChildren(org.w3c.dom.Element e)
public static java.util.List getTextChildren(org.w3c.dom.Element e)
public static java.util.List getElementChildren(org.w3c.dom.Element e, java.lang.String tagName)
public static java.lang.String getElementPathExpression(org.w3c.dom.Element e)
n
- the input node
public static int findPath(org.w3c.dom.Node supposedChild, org.w3c.dom.Node supposedParent, java.util.LinkedList goingUpPath, java.util.LinkedList goingDownPath)
supposedChild
- the node from where the path beginssupposedParent
- the node the path ends atgoingUpPath
- a LinkedList object containing the nodes from supposedChild to supposedParent, if indeed supposedChild is in the
same branch with supposed parent and is deeper than supposedParent. In this case, it is returned full. As the
name suggests, this list represents going up the schema.goingDownPath
- a LinkedList object containing the nodes from common ancestor to supposedParent or from supposedChild to
supposedParent, if they are in the same branch and supposedParent is deeper than supposedChild. supposedParent
is always the last node in the list. As the name suggests, this list represents going up the schema.
public static java.util.List getLevel(org.w3c.dom.Node n, int level)
n
- the root of the subtree - will accept a Document variablelevel
- the needed level - remember that the root has a level of 0
public static java.util.List getTextNodes(org.w3c.dom.Element e)
private static void helpGetLevel(java.util.List levelList, org.w3c.dom.Node currentNode, int level)
public static java.util.List getElementLevel(org.w3c.dom.Node n, int level)
n
- the root of the subtree - will accept a Document variablelevel
- the needed level - remember that the root has a level of 0
private static void helpGetElementLevel(java.util.List levelList, org.w3c.dom.Node currentNode, int level)
public static float getAverageFanOut(org.w3c.dom.Document document)
public static int getDepth(org.w3c.dom.Document document)
document
- the input document
public static int getNodeDepth(org.w3c.dom.Node n)
public static int getChildCount(org.w3c.dom.Node parentNode)
public static int getElementChildCount(org.w3c.dom.Node parentNode)
public static int getTextChildCount(org.w3c.dom.Node parentNode)
public static int getNodeOrder(org.w3c.dom.Node n)
n
- the input node
public static int getTextNodeOrder(org.w3c.dom.Node n) throws XMLException
n
- the text node (PCData or CData)
XMLException
public static int getElementNodeOrder(org.w3c.dom.Element n)
public static boolean isTextNode(org.w3c.dom.Node n)
public static boolean isPCDataNode(org.w3c.dom.Node n)
public static boolean isCDataNode(org.w3c.dom.Node n)
public static boolean isElementNode(org.w3c.dom.Node n)
public static boolean hasTextNodes(org.w3c.dom.Element n)
public static org.w3c.dom.Document getEmptyDOM(java.lang.String rootName)
public static org.w3c.dom.Document getEmptyDocument(java.lang.String rootName)
public static org.w3c.dom.Document parseFile(java.lang.String inputFile, boolean validating)
inputFile
- the location of the input filevalidating
- whether the parser should consult the accompanying (?) schema
public static org.w3c.dom.Document parseString(java.lang.String inputString, boolean validating)
public static org.w3c.dom.Document parseFileNS(java.lang.String inputFile, boolean validating)
inputFile
- the location of the input filevalidating
- whether the parser should consult the accompanying (?) schema
public static org.w3c.dom.Document parseStringNS(java.lang.String inputString, boolean validating)
public static void writeDOM(org.w3c.dom.Document doc, java.io.File f)
public static void writeDOM(org.w3c.dom.Node doc, java.io.File f)
public static void writeDOM(org.w3c.dom.Document doc, java.lang.String url)
public static void writeDOM(org.w3c.dom.Document doc, java.lang.String filePath, java.lang.String fileName)
public static org.w3c.dom.Document createDOMDocument(org.w3c.dom.Element root, java.lang.String filePath, java.lang.String fileName)
public static org.w3c.dom.Document duplicateDOM(org.w3c.dom.Document doc)
public static org.w3c.dom.Document duplicateDOM(java.lang.String URI, boolean validating)
URI
- the location of the XML filevalidating
- set to true to turn validation on for the input document
public static org.w3c.dom.Document addGenericRoot(org.w3c.dom.Document doc, java.lang.String newRootName)
private static javax.xml.parsers.DocumentBuilderFactory getDBFactory()
public static int getTransformationPathwayLength(java.lang.String sourceSchemaName, java.lang.String targetSchemaName)
sourceSchemaName
- the name of the source schematargetSchemaName
- the name of the target schemapublic static void collapseWhiteSpace(org.w3c.dom.Node n) throws XMLException
d
- removes all whitespace (as in XML Schema's collapse whitespace) in the input document
XMLException
public static java.lang.String collapseWhitespace(java.lang.String s)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |