Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

openfuture.editxml.model
Class XmlFormMapper  view XmlFormMapper download XmlFormMapper.java

java.lang.Object
  extended byopenfuture.editxml.model.XmlFormMapper

public class XmlFormMapper
extends java.lang.Object

Mapper between DOM trees and XML forms.

Created: Thu Apr 12 05:48:51 2001

Version:
$Revision: 1.1.1.1 $

Field Summary
static java.lang.String ATTRIBUTE_SEPARATOR
          String separating path and attribute value.
static java.lang.String PATH_SEPARATOR
          String separating a list of elements on a path.
private  openfuture.util.misc.HashTree xmlTree
          XML tree structuring the document.
 
Constructor Summary
XmlFormMapper(java.util.LinkedList xmlPaths)
          Creates a new XmlFormMapper instance.
 
Method Summary
protected  org.w3c.dom.Element createPath(java.util.LinkedList path, org.w3c.dom.Document doc, org.w3c.dom.Element root)
          Creates a path of text nodes starting at root.
 openfuture.editxml.form.XmlForm dom2form(java.lang.String domain, java.lang.String file, org.w3c.dom.Document doc)
          Convert a DOM tree into an XML form.
protected  java.lang.String element2String(org.w3c.dom.Element element)
          Convert an element into a String using XMLSerializer.
protected  void fillentries(org.w3c.dom.Document doc, java.lang.String prefix, openfuture.util.misc.HashTree current, java.util.Hashtable table, org.w3c.dom.Node node)
          Recursively descends from element and fills the hashtable.
 org.w3c.dom.Document form2dom(openfuture.editxml.form.XmlForm form)
          Convert an XML form into a DOM tree.
protected  org.w3c.dom.Node getFirstTextChild(org.w3c.dom.Node parent)
          Find the first child node that holds text.
 openfuture.util.misc.HashTree getXmlTree()
          Get the value of xmlTree.
 org.w3c.dom.NodeList parseHtml(java.lang.String text)
          Parse the given text as HTML fragment.
 void setXmlTree(openfuture.util.misc.HashTree v)
          Set the value of xmlTree.
protected  java.util.LinkedList splitPath(java.lang.String path)
          Split up the string in a list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_SEPARATOR

public static final java.lang.String PATH_SEPARATOR
String separating a list of elements on a path.

See Also:
Constant Field Values

ATTRIBUTE_SEPARATOR

public static final java.lang.String ATTRIBUTE_SEPARATOR
String separating path and attribute value.

See Also:
Constant Field Values

xmlTree

private openfuture.util.misc.HashTree xmlTree
XML tree structuring the document.

Constructor Detail

XmlFormMapper

public XmlFormMapper(java.util.LinkedList xmlPaths)
Creates a new XmlFormMapper instance.

Method Detail

dom2form

public openfuture.editxml.form.XmlForm dom2form(java.lang.String domain,
                                                java.lang.String file,
                                                org.w3c.dom.Document doc)
Convert a DOM tree into an XML form. Nodes inside the xmlTree 55 are added to the form entries 55 as XML entry, nodes outside the xmlTree 55 are added as HTML text to their parent.

The key of the XML entry holds the path from the root node separated by PATH_SEPARATOR 55 . Attributes are also added as XML entry, where the attribute name is appended by ATTRIBUTE_SEPARATOR 55 .


form2dom

public org.w3c.dom.Document form2dom(openfuture.editxml.form.XmlForm form)
                              throws org.xml.sax.SAXException
Convert an XML form into a DOM tree. The conversion of #dom2form(Document) is reverted into a DOM tree. All text nodes are viewed as XHTML fragments, are parsed and added as sub nodes to the DOM tree.


fillentries

protected void fillentries(org.w3c.dom.Document doc,
                           java.lang.String prefix,
                           openfuture.util.misc.HashTree current,
                           java.util.Hashtable table,
                           org.w3c.dom.Node node)
Recursively descends from element and fills the hashtable.


splitPath

protected java.util.LinkedList splitPath(java.lang.String path)
Split up the string in a list. The character PATH_SEPARATOR 55 is used as separating symbol.


createPath

protected org.w3c.dom.Element createPath(java.util.LinkedList path,
                                         org.w3c.dom.Document doc,
                                         org.w3c.dom.Element root)
Creates a path of text nodes starting at root. Existing nodes on the path are used, not duplicated.


parseHtml

public org.w3c.dom.NodeList parseHtml(java.lang.String text)
                               throws org.xml.sax.SAXException
Parse the given text as HTML fragment.


getFirstTextChild

protected org.w3c.dom.Node getFirstTextChild(org.w3c.dom.Node parent)
Find the first child node that holds text.


element2String

protected java.lang.String element2String(org.w3c.dom.Element element)
Convert an element into a String using XMLSerializer.


getXmlTree

public openfuture.util.misc.HashTree getXmlTree()
Get the value of xmlTree.


setXmlTree

public void setXmlTree(openfuture.util.misc.HashTree v)
Set the value of xmlTree.