Qizx fe-4.4p2 API

com.qizx.api.util
Class PushStreamToDOM

java.lang.Object
  extended by com.qizx.xdm.AttributeList
      extended by com.qizx.xdm.XMLPushStreamBase
          extended by com.qizx.api.util.PushStreamToDOM
All Implemented Interfaces:
XMLPushStream, Attributes

public class PushStreamToDOM
extends com.qizx.xdm.XMLPushStreamBase

An implementation of XMLPushStream which creates W3C DOM documents or nodes.

This class can be used to export or convert a XML tree from Qizx to any system accepting DOM representation.

Caution: leading and trailing Comments or Processing-Instructions (i.e. preceding or following the topmost Element) are discarded. This feature is in fact not really supported by W3C DOM.


Field Summary
 
Fields inherited from interface com.qizx.api.XMLPushStream
NSCOPY_NOPRESERVE_INHERIT, NSCOPY_NOPRESERVE_NOINHERIT, NSCOPY_PRESERVE_INHERIT, NSCOPY_PRESERVE_NOINHERIT
 
Constructor Summary
PushStreamToDOM()
          Creates a DOM output using the default DOM implementation.
PushStreamToDOM(DOMImplementation implem)
          Creates a DOM output using a specified DOM implementation.
 
Method Summary
 Node exportNode(Node node)
          Converts a node of the XDM into a W3C DOM node.
 Document getResultDocument()
          Returns the DOM document built.
 void putComment(String contents)
          Puts a Comment event.
 boolean putDocumentStart()
          Puts a Document Start event.
 void putElementEnd(QName name)
          Puts an Element End event.
 void putElementStart(QName name)
          Puts an Element Start event.
 void putProcessingInstruction(String target, String contents)
          Puts a Processing-instruction event.
 void putText(String text)
          Puts a Text Fragment event.
 void reset()
          Resets the state before a new use.
 
Methods inherited from class com.qizx.xdm.XMLPushStreamBase
abort, defineContextMappings, flush, getNSPrefix, getNSURI, isAtRoot, maxVolumeReached, noSpace, putAtom, putAtomText, putAttribute, putChars, putDocumentEnd, putDTD, putLongAtom, putNamespace, putNamespaces, putNodeCopy, putNodeCopy, putNodeText, setCheckNS, setMaxVolume, setTrace
 
Methods inherited from class com.qizx.xdm.AttributeList
addAttribute, getAttributeCount, getIndex, getIndex, getIndex, getLength, getLocalName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getQName, getType, getType, getType, getURI, getValue, getValue, getValue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PushStreamToDOM

public PushStreamToDOM()
                throws DataModelException
Creates a DOM output using the default DOM implementation.

Throws:
DataModelException - wraps a ParserConfigurationException

PushStreamToDOM

public PushStreamToDOM(DOMImplementation implem)
Creates a DOM output using a specified DOM implementation.

Parameters:
implem - DOM implementation
Method Detail

exportNode

public Node exportNode(Node node)
                throws DataModelException
Converts a node of the XDM into a W3C DOM node.

Parameters:
node - a Node of the XQuery Data Model.
Returns:
a DOM Node, according to the type of the argument.
Throws:
DataModelException - not thrown

getResultDocument

public Document getResultDocument()
Returns the DOM document built. Attention: non null result only if the source Node is a document or an element.

Returns:
DOM document built

putDocumentStart

public boolean putDocumentStart()
                         throws DataModelException
Description copied from interface: XMLPushStream
Puts a Document Start event. This method should be called first if the result is meant to be a well-formed document. However it it possible to omit it (and putDocumentEnd) if the desired result is an element.

Specified by:
putDocumentStart in interface XMLPushStream
Overrides:
putDocumentStart in class com.qizx.xdm.XMLPushStreamBase
Returns:
false if the current stream position is already inside a node (this event is then ignored)
Throws:
DataModelException - reasons

putElementStart

public void putElementStart(QName name)
                     throws DataModelException
Description copied from interface: XMLPushStream
Puts an Element Start event.

Should precede namespace and attributes event for the element.

Specified by:
putElementStart in interface XMLPushStream
Overrides:
putElementStart in class com.qizx.xdm.XMLPushStreamBase
Parameters:
name - qualified name of the element. The local-part and namespace-URI properties of the name are used, but the prefix is ignored: to define a namespace (i.e a prefix/namespace-URI association), use the XMLPushStream.putNamespace(java.lang.String, java.lang.String) method.
Throws:
DataModelException - reasons

putElementEnd

public void putElementEnd(QName name)
                   throws DataModelException
Description copied from interface: XMLPushStream
Puts an Element End event. Should balance putElementStart exactly, else the result could be incorrect.

Specified by:
putElementEnd in interface XMLPushStream
Overrides:
putElementEnd in class com.qizx.xdm.XMLPushStreamBase
Parameters:
name - qualified name of the element
Throws:
DataModelException - reasons

putText

public void putText(String text)
             throws DataModelException
Description copied from interface: XMLPushStream
Puts a Text Fragment event.

A text fragment should appear inside an element. Consecutive text events are coalesced into one. An empty text fragment is discarded.

Parameters:
text - a fragment of text
Throws:
DataModelException - reasons

putComment

public void putComment(String contents)
                throws DataModelException
Description copied from interface: XMLPushStream
Puts a Comment event.

Specified by:
putComment in interface XMLPushStream
Overrides:
putComment in class com.qizx.xdm.XMLPushStreamBase
Parameters:
contents - contents of a comment.
Throws:
DataModelException - reasons

putProcessingInstruction

public void putProcessingInstruction(String target,
                                     String contents)
                              throws DataModelException
Description copied from interface: XMLPushStream
Puts a Processing-instruction event.

Specified by:
putProcessingInstruction in interface XMLPushStream
Overrides:
putProcessingInstruction in class com.qizx.xdm.XMLPushStreamBase
Parameters:
target - target (name) of the PI
contents - contents of the PI
Throws:
DataModelException - reasons

reset

public void reset()
Description copied from class: com.qizx.xdm.XMLPushStreamBase
Resets the state before a new use.

Should always be called before using the object again.

Specified by:
reset in interface XMLPushStream
Overrides:
reset in class com.qizx.xdm.XMLPushStreamBase

© 2010 Axyana Software