wt.dataops.util.xml
Class XMLHelper

java.lang.Object
  extended bywt.dataops.util.xml.XMLHelper

public class XMLHelper
extends Object


Nested Class Summary
protected static class XMLHelper.DictionaryDTDResolver
           
protected static class XMLHelper.ObjectColDTDResolver
           
 
Field Summary
static String DEFAULT_AS_DICT_DTD_PATH
           
static String DEFAULT_OBJCOL_DTD_PATH
           
protected static String dict_dtd
           
static String DICTIONARY_DTD_NAME
           
static String DICTIONARY_DTD_PATH
           
static String DICTIONARY_DTD_RESOLVER
           
static String EMPTY
           
protected static String objcol_dtd
           
static String OBJECTCOL_CRITERIONDEF_DTD
           
static boolean VERBOSE
           
protected static String wt_codebase
           
static String WT_CODEBASE
           
protected static String wt_home
           
static String WT_HOME
           
protected static String wt_temp
           
static String WT_TEMP
           
 
Constructor Summary
XMLHelper()
           
 
Method Summary
static void addAttribute(XMLNode elem, String attrName, String attrVal)
           
static XMLNode addElement(XMLNode elem, Element ch)
           
static XMLNode addElement(XMLNode elem, String elName, String elVal)
           
static XMLNode addValue(XMLNode elem, String elVal)
           
static Document createDocument(String rootElem)
           
static XMLLob createXMLLob(File f)
           
static XMLLob createXMLLob(InputStream in)
           
static List findAllNamedChildren(Element parent, String childName)
           
static Element findFirstChildElement(Element parent)
           
static Element findFirstNamedChildElement(Element parent, String elemName)
           
static Element findFirstNamedChildElementWithAttr(Element parent, String elemName, String attrName, String attrVal)
           
static Node findMatchingSubNode(String name, Node node, String content)
           
static List findNamedChildrenWithAttr(Element parent, String childName, String attrName)
           
static List findNamedChildrenWithAttr(Element parent, String childName, String attrName, String attrVal)
           
static Node findSubNode(String name, Node node)
          Find the named subnode in a node's sublist.
static String getAttribute(Element elem, String attrName)
           
static boolean getBooleanAttribute(Element e, String attrName)
           
static String getContent(Element element)
           
static String getContentForChild(Element parent, String childname)
           
static Element getNextSiblingElement(Element sibling)
           
static String getText(Node node)
          Return the text that a node contains.
static boolean matchElement(Element parent, String elemName)
           
static boolean matchText(Node node, String text)
           
static Document read(File file)
           
static Document read(InputStream in)
           
static Document read(String filename)
           
static Document readDocument(String fileName, String resolverClass)
           
static XMLNode removeElement(XMLNode elem)
           
protected static File resolveFile(String name)
           
static void writeDocument(String outPath, String fName)
           
static InputStream writeOut(Document doc, String dtd)
           
static void writeOut(File file, Document doc, String dtd)
           
static Document xmlLobToDocument(XMLLob xmllob)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wt_home

protected static String wt_home

wt_temp

protected static String wt_temp

wt_codebase

protected static String wt_codebase

objcol_dtd

protected static String objcol_dtd

dict_dtd

protected static String dict_dtd

VERBOSE

public static boolean VERBOSE

EMPTY

public static final String EMPTY
See Also:
Constant Field Values

WT_HOME

public static final String WT_HOME
See Also:
Constant Field Values

WT_TEMP

public static final String WT_TEMP
See Also:
Constant Field Values

WT_CODEBASE

public static final String WT_CODEBASE
See Also:
Constant Field Values

DEFAULT_OBJCOL_DTD_PATH

public static final String DEFAULT_OBJCOL_DTD_PATH

DEFAULT_AS_DICT_DTD_PATH

public static final String DEFAULT_AS_DICT_DTD_PATH

OBJECTCOL_CRITERIONDEF_DTD

public static final String OBJECTCOL_CRITERIONDEF_DTD
See Also:
Constant Field Values

DICTIONARY_DTD_PATH

public static final String DICTIONARY_DTD_PATH
See Also:
Constant Field Values

DICTIONARY_DTD_NAME

public static final String DICTIONARY_DTD_NAME
See Also:
Constant Field Values

DICTIONARY_DTD_RESOLVER

public static final String DICTIONARY_DTD_RESOLVER
See Also:
Constant Field Values
Constructor Detail

XMLHelper

public XMLHelper()
Method Detail

xmlLobToDocument

public static Document xmlLobToDocument(XMLLob xmllob)
                                 throws WTException
Throws:
WTException

createXMLLob

public static XMLLob createXMLLob(File f)
                           throws WTException
Throws:
WTException

createXMLLob

public static XMLLob createXMLLob(InputStream in)
                           throws WTException
Throws:
WTException

read

public static Document read(String filename)
                     throws WTException
Throws:
WTException

read

public static Document read(File file)
                     throws WTException
Throws:
WTException

read

public static Document read(InputStream in)
                     throws WTException
Throws:
WTException

resolveFile

protected static File resolveFile(String name)
                           throws FileNotFoundException
Throws:
FileNotFoundException

findFirstNamedChildElement

public static Element findFirstNamedChildElement(Element parent,
                                                 String elemName)
                                          throws NoSuchDomElementException
Throws:
NoSuchDomElementException

findFirstNamedChildElementWithAttr

public static Element findFirstNamedChildElementWithAttr(Element parent,
                                                         String elemName,
                                                         String attrName,
                                                         String attrVal)
                                                  throws NoSuchDomElementException
Throws:
NoSuchDomElementException

matchElement

public static boolean matchElement(Element parent,
                                   String elemName)

findAllNamedChildren

public static List findAllNamedChildren(Element parent,
                                        String childName)
                                 throws NoSuchDomElementException
Throws:
NoSuchDomElementException

findNamedChildrenWithAttr

public static List findNamedChildrenWithAttr(Element parent,
                                             String childName,
                                             String attrName)
                                      throws NoSuchDomElementException
Throws:
NoSuchDomElementException

findNamedChildrenWithAttr

public static List findNamedChildrenWithAttr(Element parent,
                                             String childName,
                                             String attrName,
                                             String attrVal)
                                      throws NoSuchDomElementException
Throws:
NoSuchDomElementException

getAttribute

public static String getAttribute(Element elem,
                                  String attrName)
                           throws NoSuchAttributeOnElementException
Throws:
NoSuchAttributeOnElementException

getBooleanAttribute

public static boolean getBooleanAttribute(Element e,
                                          String attrName)
                                   throws NoSuchAttributeOnElementException
Throws:
NoSuchAttributeOnElementException

findFirstChildElement

public static Element findFirstChildElement(Element parent)
                                     throws NoSuchDomElementException
Throws:
NoSuchDomElementException

getNextSiblingElement

public static Element getNextSiblingElement(Element sibling)
                                     throws NoSuchDomElementException
Throws:
NoSuchDomElementException

getContentForChild

public static String getContentForChild(Element parent,
                                        String childname)
                                 throws NoSuchDomElementException
Throws:
NoSuchDomElementException

getContent

public static String getContent(Element element)

createDocument

public static Document createDocument(String rootElem)

readDocument

public static Document readDocument(String fileName,
                                    String resolverClass)

writeDocument

public static void writeDocument(String outPath,
                                 String fName)

findSubNode

public static Node findSubNode(String name,
                               Node node)
Find the named subnode in a node's sublist.
  • Ignores comments and processing instructions.
  • Ignores TEXT nodes (likely to exist and contain ignorable whitespace, if not validating.
  • Ignores CDATA nodes and EntityRef nodes.
  • Examines element nodes to find one with the specified name.

    Parameters:
    name - the tag name for the element to find
    node - the element node to start searching from
    Returns:
    the Node found

  • findMatchingSubNode

    public static Node findMatchingSubNode(String name,
                                           Node node,
                                           String content)

    getText

    public static String getText(Node node)
    Return the text that a node contains. This routine:

    Parameters:
    node - a DOM node
    Returns:
    a String representing its contents

    matchText

    public static boolean matchText(Node node,
                                    String text)

    addElement

    public static XMLNode addElement(XMLNode elem,
                                     String elName,
                                     String elVal)

    addElement

    public static XMLNode addElement(XMLNode elem,
                                     Element ch)

    addValue

    public static XMLNode addValue(XMLNode elem,
                                   String elVal)

    removeElement

    public static XMLNode removeElement(XMLNode elem)

    addAttribute

    public static void addAttribute(XMLNode elem,
                                    String attrName,
                                    String attrVal)

    writeOut

    public static InputStream writeOut(Document doc,
                                       String dtd)

    writeOut

    public static void writeOut(File file,
                                Document doc,
                                String dtd)