nl.justobjects.toolkit.xml
Class DOMUtil

java.lang.Object
  |
  +--nl.justobjects.toolkit.xml.DOMUtil

public class DOMUtil
extends java.lang.Object

Utility methods for working with a DOM tree. $Id: DOMUtil.java,v 1.16 2003/01/06 00:23:49 just Exp $

Author:
$Author: just $ - Just van den Broecke - Just Objects B.V. ©

Constructor Summary
DOMUtil()
           
 
Method Summary
static void clearDocument(org.w3c.dom.Document document)
          Clears all childnodes in document
static void copyAttributes(org.w3c.dom.Element elementFrom, org.w3c.dom.Element elementTo)
          Copies all attributes from one element to another in the official way.
static org.w3c.dom.Document createDocument()
          Create empty document TO BE DEBUGGED!.
static void document2File(org.w3c.dom.Document document, java.lang.String fileName)
          Write Document structure to XML file.
static void expandIds(java.lang.String tag, org.w3c.dom.Element targetDocument, org.w3c.dom.Document contentDocument)
          Expands by inserting the elements from the content document
static void expandIncludes(org.w3c.dom.Document document)
          Expands statements by inserting the files in the document
static void expandIncludes(org.w3c.dom.Document document, java.lang.String rootDir, java.lang.String fileDir)
          Expands statements by inserting the files in the document
static org.w3c.dom.Element getElementById(org.w3c.dom.Document document, java.lang.String id)
           
static org.w3c.dom.Element getElementById(org.w3c.dom.Element element, java.lang.String id)
           
static org.w3c.dom.Element getElementById(org.w3c.dom.NodeList nodeList, java.lang.String id)
          Get Element that has attribute id="xyz".
static org.w3c.dom.Element getFirstElementByTagName(org.w3c.dom.Document document, java.lang.String tag)
           
static void main(java.lang.String[] args)
           
static void p(java.lang.String s)
           
static org.w3c.dom.Document parse(java.lang.String uri)
          Parses the specified URI without DTD validation and returns the document.
static org.w3c.dom.Document parse(java.lang.String uri, boolean validate)
          Parses the specified URI and returns the document.
static void printAsHTML(org.w3c.dom.Document document, java.io.PrintWriter printWriter)
          Prints an XHTML DOM as browser-compliant HTML
static void printAsXML(org.w3c.dom.Document document, java.io.PrintWriter printWriter)
          Prints an XML DOM.
static void replaceElement(org.w3c.dom.Element newElement, org.w3c.dom.Element oldElement)
          Replaces an element in document.
private static void testCreateDocument()
           
private static void testReplaceElement()
           
private static void testXMLFile(java.lang.String fileName)
           
static void warn(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

DOMUtil

public DOMUtil()
Method Detail

clearDocument

public static void clearDocument(org.w3c.dom.Document document)
Clears all childnodes in document

createDocument

public static org.w3c.dom.Document createDocument()
Create empty document TO BE DEBUGGED!.

copyAttributes

public static void copyAttributes(org.w3c.dom.Element elementFrom,
                                  org.w3c.dom.Element elementTo)
Copies all attributes from one element to another in the official way.

expandIds

public static void expandIds(java.lang.String tag,
                             org.w3c.dom.Element targetDocument,
                             org.w3c.dom.Document contentDocument)
Expands by inserting the elements from the content document

expandIncludes

public static void expandIncludes(org.w3c.dom.Document document)
Expands statements by inserting the files in the document

expandIncludes

public static void expandIncludes(org.w3c.dom.Document document,
                                  java.lang.String rootDir,
                                  java.lang.String fileDir)
Expands statements by inserting the files in the document

getFirstElementByTagName

public static org.w3c.dom.Element getFirstElementByTagName(org.w3c.dom.Document document,
                                                           java.lang.String tag)

getElementById

public static org.w3c.dom.Element getElementById(org.w3c.dom.Document document,
                                                 java.lang.String id)

getElementById

public static org.w3c.dom.Element getElementById(org.w3c.dom.Element element,
                                                 java.lang.String id)

getElementById

public static org.w3c.dom.Element getElementById(org.w3c.dom.NodeList nodeList,
                                                 java.lang.String id)
Get Element that has attribute id="xyz".

parse

public static org.w3c.dom.Document parse(java.lang.String uri,
                                         boolean validate)
                                  throws java.lang.Exception
Parses the specified URI and returns the document.

parse

public static org.w3c.dom.Document parse(java.lang.String uri)
                                  throws java.lang.Exception
Parses the specified URI without DTD validation and returns the document.

printAsHTML

public static void printAsHTML(org.w3c.dom.Document document,
                               java.io.PrintWriter printWriter)
Prints an XHTML DOM as browser-compliant HTML

printAsXML

public static void printAsXML(org.w3c.dom.Document document,
                              java.io.PrintWriter printWriter)
Prints an XML DOM.

replaceElement

public static void replaceElement(org.w3c.dom.Element newElement,
                                  org.w3c.dom.Element oldElement)
Replaces an element in document.

document2File

public static void document2File(org.w3c.dom.Document document,
                                 java.lang.String fileName)
Write Document structure to XML file.

warn

public static void warn(java.lang.String s)

p

public static void p(java.lang.String s)

testCreateDocument

private static void testCreateDocument()

testReplaceElement

private static void testReplaceElement()

testXMLFile

private static void testXMLFile(java.lang.String fileName)

main

public static void main(java.lang.String[] args)


Copyright © 2000-2001 - Just Objects B.V.