|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectDOMutil
public class DOMutil
Tools for dealing with XML files
| Nested Class Summary | |
|---|---|
private static class |
DOMutil.MyErrorHandler
Error handling of the validation Set valid to false in the case of a fatal error or an error |
| Field Summary | |
|---|---|
private static java.lang.StringBuffer |
blanks
|
private static long |
start
|
private static boolean |
valid
|
| Constructor Summary | |
|---|---|
DOMutil()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
attribute(org.w3c.dom.Element node,
java.lang.String name)
Return the value of the attribute of an element |
private static java.lang.String |
blanks(int n)
|
static java.util.List<org.w3c.dom.Element> |
child(org.w3c.dom.Element node,
java.lang.String name)
Return a list of Elements that are immediate children of a node whose name matches name |
static void |
compact(org.w3c.dom.Node node,
java.lang.String indent)
Output a "compact" form of a DOM node and its descendants taken from http://www.iro.umontreal.ca/~lapalme/ForestInsteadOfTheTrees/programs/Java/DOMCompact.java This is more informative than the standard toString() on Node(s) |
static org.w3c.dom.Element |
firstChildElement(org.w3c.dom.Node node)
Return the first child element (skipping non element node) of a node |
static java.lang.String |
getText(org.w3c.dom.Element node)
Get the text context of the first child node |
static boolean |
isValid()
Indicates if last parsed document was valid |
static org.w3c.dom.Element |
nextElement(org.w3c.dom.Node node)
Return the next sibling element of a node (skipping non element node) |
static org.w3c.dom.Element |
parseXMLdoc(java.lang.String fileName)
Parse an XML file without validation |
static org.w3c.dom.Element |
parseXMLdoc(java.lang.String fileName,
java.lang.String schemaFileName)
Parse an XML document with validation and return the root element |
static void |
setStartTime()
Set timing start |
static java.lang.String |
showTime()
Show time elapsed since call to setStartTime |
static void |
stripSpace(org.w3c.dom.Node node)
Remove empty text nodes (ie nothing else than spaces and carriage return) and nodes that are not text or element ones |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static boolean valid
private static long start
private static java.lang.StringBuffer blanks
| Constructor Detail |
|---|
public DOMutil()
| Method Detail |
|---|
public static void setStartTime()
public static java.lang.String showTime()
public static org.w3c.dom.Element parseXMLdoc(java.lang.String fileName,
java.lang.String schemaFileName)
fileName - name of the XML fileschemaFileName - name of the schema file if null, no validation
type of validation depends on the extension of the file name (.dtd, .xsd, .rnc)
public static org.w3c.dom.Element parseXMLdoc(java.lang.String fileName)
fileName - name of XML file
public static boolean isValid()
public static void stripSpace(org.w3c.dom.Node node)
node -
public static java.lang.String attribute(org.w3c.dom.Element node,
java.lang.String name)
node - the elementname - name of the attribute
public static java.util.List<org.w3c.dom.Element> child(org.w3c.dom.Element node,
java.lang.String name)
node - the elementname - regexp for the name of the children to return
public static org.w3c.dom.Element nextElement(org.w3c.dom.Node node)
node - node
public static org.w3c.dom.Element firstChildElement(org.w3c.dom.Node node)
node - the element
public static java.lang.String getText(org.w3c.dom.Element node)
node - the element
public static void compact(org.w3c.dom.Node node,
java.lang.String indent)
node - node to start compacting fromindent - current indentationprivate static java.lang.String blanks(int n)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||