org.jaxup.xupdate
Class XUpdate

java.lang.Object
  |
  +--org.jaxup.xupdate.XUpdate

public class XUpdate
extends Object

XUpdate engine. This class can, using the instructions in an XUpdate instruction document, change another XML document in-place. For small changes to large XML files, this may be preferable over a full XSLT translation. It is especially efficient if the XML document is either kept in memory for a long time, or is stored in a persistent database.

Author:
Erwin Bolwidt ( ejb @ klomp.org )

Field Summary
static String NS_XUPDATE
           
 
Constructor Summary
XUpdate(Updater docUpdater)
          Creates an xupdate engine.
XUpdate(Updater docUpdater, org.jaxen.Navigator xuNavigator)
          Creates an xupdate engine.
 
Method Summary
protected  void conditional(Object doc, Object instrNode)
          Handles an xupdate 'if' instruction.
protected  Object copyLiteral(Object doc, Object literal)
           
protected  void creation(Object doc, Object instrNode, int type)
          Handles an xupdate 'append', 'update', 'insert-before' and 'insert-after' instruction.
protected  Object evaluateAttribute(Object doc, Object instrNode)
           
protected  Object evaluateComment(Object doc, Object instrNode)
           
protected  Object evaluateElement(Object doc, Object instrNode)
           
protected  Object evaluateProcessingInstruction(Object doc, Object instrNode)
           
protected  Object evaluateText(Object doc, Object instrNode)
           
protected  List evaluateValueOf(Object doc, Object instrNode)
           
protected  void executeUpdateInstructions(Object doc, Object instructionsContainer)
          Handles an xupdate 'modifications' or 'if' instruction container.
protected static Object getAttributeNode(org.jaxen.Navigator nav, Object element, String name)
          Returns attribute without namespace with the specified NCName in specified element, or null if there is no such attribute.
protected  List instantiateTemplate(Object doc, Object templateHolder)
           
protected  org.jaxen.BaseXPath parseXPath(String xpath, Object xuElement)
           
protected  void remove(Object doc, Object removeNode)
          Handles an xupdate 'remove' instruction.
protected  void removeChildren(Object element)
           
 void runUpdate(Object sourceDoc, Object xupdateContainer)
          Runs a series of xupdate instructions to manipulate a given source document.
protected static String[] splitQName(String qname)
           
protected  void variable(Object doc, Object instrNode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NS_XUPDATE

public static final String NS_XUPDATE
Constructor Detail

XUpdate

public XUpdate(Updater docUpdater)
Creates an xupdate engine. The source documents that are updated, and the xml documents containing the xupdate instructions, are both stored in the same data model (e.g. DOM, JDOM, DOM4J, EXML)
Parameters:
updater - an implementation of the Updater interface to update source and rad xupdate instruction documents.

XUpdate

public XUpdate(Updater docUpdater,
               org.jaxen.Navigator xuNavigator)
Creates an xupdate engine. The source documents that are updated and the xml documents containing the xupdate instructions may be stored in different data models, i.e. the source document in W3C DOM and the xupdate instructions in JDOM.
Parameters:
docUpdater - an implementation of the Updater interface to update source documents.
xuNavigator - an implementation of the Navigator interface to read xupdate instruction documents.
Method Detail

runUpdate

public void runUpdate(Object sourceDoc,
                      Object xupdateContainer)
               throws org.jaxen.JaxenException,
                      org.saxpath.SAXPathException
Runs a series of xupdate instructions to manipulate a given source document.
Parameters:
sourceDoc - the source document that is going to be changed.
xupdateContainer - an element node that contains xupdate instructions as its children. Ordinarily, this would be the document element of an xupdate XML document.

executeUpdateInstructions

protected void executeUpdateInstructions(Object doc,
                                         Object instructionsContainer)
                                  throws org.jaxen.JaxenException,
                                         org.saxpath.SAXPathException
Handles an xupdate 'modifications' or 'if' instruction container.

getAttributeNode

protected static Object getAttributeNode(org.jaxen.Navigator nav,
                                         Object element,
                                         String name)
                                  throws org.jaxen.JaxenException
Returns attribute without namespace with the specified NCName in specified element, or null if there is no such attribute.

parseXPath

protected org.jaxen.BaseXPath parseXPath(String xpath,
                                         Object xuElement)
                                  throws org.jaxen.JaxenException,
                                         org.saxpath.SAXPathException

splitQName

protected static String[] splitQName(String qname)
                              throws org.jaxen.JaxenException

variable

protected void variable(Object doc,
                        Object instrNode)
                 throws org.jaxen.JaxenException,
                        org.saxpath.SAXPathException

conditional

protected void conditional(Object doc,
                           Object instrNode)
                    throws org.jaxen.JaxenException,
                           org.saxpath.SAXPathException
Handles an xupdate 'if' instruction.

remove

protected void remove(Object doc,
                      Object removeNode)
               throws org.jaxen.JaxenException,
                      org.saxpath.SAXPathException
Handles an xupdate 'remove' instruction.

evaluateElement

protected Object evaluateElement(Object doc,
                                 Object instrNode)
                          throws org.jaxen.JaxenException,
                                 org.saxpath.SAXPathException

evaluateAttribute

protected Object evaluateAttribute(Object doc,
                                   Object instrNode)
                            throws org.jaxen.JaxenException,
                                   org.saxpath.SAXPathException

evaluateProcessingInstruction

protected Object evaluateProcessingInstruction(Object doc,
                                               Object instrNode)
                                        throws org.jaxen.JaxenException,
                                               org.saxpath.SAXPathException

evaluateComment

protected Object evaluateComment(Object doc,
                                 Object instrNode)
                          throws org.jaxen.JaxenException,
                                 org.saxpath.SAXPathException

evaluateText

protected Object evaluateText(Object doc,
                              Object instrNode)
                       throws org.jaxen.JaxenException,
                              org.saxpath.SAXPathException

evaluateValueOf

protected List evaluateValueOf(Object doc,
                               Object instrNode)
                        throws org.jaxen.JaxenException,
                               org.saxpath.SAXPathException

creation

protected void creation(Object doc,
                        Object instrNode,
                        int type)
                 throws org.jaxen.JaxenException,
                        org.saxpath.SAXPathException
Handles an xupdate 'append', 'update', 'insert-before' and 'insert-after' instruction.
Parameters:
type - 0 = append, 1 = update, 2 = insert-before, 3 = insert-after

removeChildren

protected void removeChildren(Object element)
                       throws org.jaxen.JaxenException

instantiateTemplate

protected List instantiateTemplate(Object doc,
                                   Object templateHolder)
                            throws org.jaxen.JaxenException,
                                   org.saxpath.SAXPathException

copyLiteral

protected Object copyLiteral(Object doc,
                             Object literal)
                      throws org.jaxen.JaxenException


Copyright © 2001 Erwin Bolwidt. All Rights Reserved. Hosted by

SourceForge Logo