org.apache.xalan.xsltc.dom
Class SimpleResultTreeImpl

java.lang.Object
  |
  +--org.apache.xml.serializer.EmptySerializer
        |
        +--org.apache.xalan.xsltc.dom.SimpleResultTreeImpl
Direct Known Subclasses:
AdaptiveResultTreeImpl

public class SimpleResultTreeImpl
extends EmptySerializer
implements DOM, DTM

This class represents a light-weight DOM model for simple result tree fragment(RTF). A simple RTF is an RTF that has only one Text node. The Text node can be produced by a combination of Text, xsl:value-of and xsl:number instructions. It can also be produced by a control structure (xsl:if or xsl:choose) whose body is pure Text.

A SimpleResultTreeImpl has only two nodes, i.e. the ROOT node and its Text child. All DOM interfaces are overridden with this in mind. For example, the getStringValue() interface returns the value of the Text node. This class receives the character data from the characters() interface.

This class implements DOM and SerializationHandler. It also implements the DTM interface for support in MultiDOM. The nested iterators (SimpleIterator and SingletonIterator) are used to support the nodeset() extension function.


Inner Class Summary
 class SimpleResultTreeImpl.SimpleIterator
          The SimpleIterator is designed to support the nodeset() extension function.
 class SimpleResultTreeImpl.SingletonIterator
          The SingletonIterator is used for the self axis.
 
Field Summary
static int NUMBER_OF_NODES
           
static int RTF_ROOT
           
static int RTF_TEXT
           
 
Constructor Summary
SimpleResultTreeImpl(XSLTCDTMManager dtmManager, int documentID)
           
 
Method Summary
 void appendChild(int newChild, boolean clone, boolean cloneDepth)
           
 void appendTextChild(java.lang.String str)
           
 void characters(char[] ch, int offset, int length)
           
 void characters(int node, SerializationHandler handler)
          Dispatch the character content of a node to an output handler.
 void characters(java.lang.String str)
           
 void copy(DTMAxisIterator nodes, SerializationHandler handler)
           
 void copy(int node, SerializationHandler handler)
           
 void dispatchCharactersEvents(int nodeHandle, ContentHandler ch, boolean normalize)
           
 void dispatchToEvents(int nodeHandle, ContentHandler ch)
           
 void documentRegistration()
           
 void documentRelease()
           
 void endDocument()
           
 int getAttributeNode(int gType, int element)
           
 int getAttributeNode(int elementHandle, java.lang.String namespaceURI, java.lang.String name)
           
 DTMAxisIterator getAxisIterator(int axis)
           
 DTMAxisTraverser getAxisTraverser(int axis)
           
 DTMAxisIterator getChildren(int node)
           
 ContentHandler getContentHandler()
           
 DeclHandler getDeclHandler()
           
 int getDocument()
           
 boolean getDocumentAllDeclarationsProcessed()
           
 java.lang.String getDocumentBaseURI()
           
 java.lang.String getDocumentEncoding(int nodeHandle)
           
 int getDocumentRoot(int nodeHandle)
           
 java.lang.String getDocumentStandalone(int nodeHandle)
           
 java.lang.String getDocumentSystemIdentifier(int nodeHandle)
           
 java.lang.String getDocumentTypeDeclarationPublicIdentifier()
           
 java.lang.String getDocumentTypeDeclarationSystemIdentifier()
           
 java.lang.String getDocumentURI(int node)
           
 java.lang.String getDocumentVersion(int documentHandle)
           
 DTDHandler getDTDHandler()
           
 DTMManagerDefault getDTMManager()
           
 int getElementById(java.lang.String elementId)
           
 Hashtable getElementsWithIDs()
           
 EntityResolver getEntityResolver()
           
 ErrorHandler getErrorHandler()
           
 int getExpandedTypeID(int nodeHandle)
           
 int getExpandedTypeID(java.lang.String namespace, java.lang.String localName, int type)
           
 int getFirstAttribute(int nodeHandle)
           
 int getFirstChild(int nodeHandle)
           
 int getFirstNamespaceNode(int nodeHandle, boolean inScope)
           
 DTMAxisIterator getIterator()
           
 java.lang.String getLanguage(int node)
           
 int getLastChild(int nodeHandle)
           
 short getLevel(int nodeHandle)
           
 LexicalHandler getLexicalHandler()
           
 java.lang.String getLocalName(int nodeHandle)
           
 java.lang.String getLocalNameFromExpandedNameID(int ExpandedNameID)
           
 DTMAxisIterator getNamespaceAxisIterator(int axis, int ns)
           
 java.lang.String getNamespaceFromExpandedNameID(int ExpandedNameID)
           
 java.lang.String getNamespaceName(int node)
           
 int getNamespaceType(int node)
           
 java.lang.String getNamespaceURI(int nodeHandle)
           
 int getNextAttribute(int nodeHandle)
           
 int getNextNamespaceNode(int baseHandle, int namespaceHandle, boolean inScope)
           
 int getNextSibling(int nodeHandle)
           
 Node getNode(int nodeHandle)
           
 int getNodeHandle(int nodeId)
          Return the node handle from a node identity.
 int getNodeIdent(int nodehandle)
          Return the node identity from a node handle.
 java.lang.String getNodeName(int node)
           
 java.lang.String getNodeNameX(int node)
           
 short getNodeType(int nodeHandle)
           
 java.lang.String getNodeValue(int nodeHandle)
           
 DTMAxisIterator getNodeValueIterator(DTMAxisIterator iter, int returnType, java.lang.String value, boolean op)
           
 int getNSType(int node)
           
 DTMAxisIterator getNthDescendant(int node, int n, boolean includeself)
           
 SerializationHandler getOutputDomBuilder()
           
 int getOwnerDocument(int nodeHandle)
           
 int getParent(int nodeHandle)
           
 java.lang.String getPrefix(int nodeHandle)
           
 int getPreviousSibling(int nodeHandle)
           
 DOM getResultTreeFrag(int initialSize, int rtfType)
           
 int getSize()
           
 SourceLocator getSourceLocatorFor(int node)
           
 java.lang.String getStringValue()
           
 XMLString getStringValue(int nodeHandle)
           
 char[] getStringValueChunk(int nodeHandle, int chunkIndex, int[] startAndLen)
           
 int getStringValueChunkCount(int nodeHandle)
           
 java.lang.String getStringValueX(int nodeHandle)
           
 DTMAxisIterator getTypedAxisIterator(int axis, int type)
           
 DTMAxisIterator getTypedChildren(int type)
           
 java.lang.String getUnparsedEntityURI(java.lang.String name)
           
 boolean hasChildNodes(int nodeHandle)
           
 boolean isAttribute(int node)
           
 boolean isAttributeSpecified(int attributeHandle)
           
 boolean isCharacterElementContentWhitespace(int nodeHandle)
           
 boolean isDocumentAllDeclarationsProcessed(int documentHandle)
           
 boolean isElement(int node)
           
 boolean isNodeAfter(int firstNodeHandle, int secondNodeHandle)
           
 boolean isSupported(java.lang.String feature, java.lang.String version)
           
 boolean lessThan(int node1, int node2)
           
 java.lang.String lookupNamespace(int node, java.lang.String prefix)
           
 Node makeNode(DTMAxisIterator iter)
           
 Node makeNode(int index)
           
 NodeList makeNodeList(DTMAxisIterator iter)
           
 NodeList makeNodeList(int index)
           
 boolean needsTwoThreads()
           
 DTMAxisIterator orderNodes(DTMAxisIterator source, int node)
           
 void setDocumentBaseURI(java.lang.String baseURI)
           
 boolean setEscaping(boolean escape)
           
 void setFeature(java.lang.String featureId, boolean state)
          The DTM interfaces are not used in this class.
 void setFilter(StripFilter filter)
           
 void setProperty(java.lang.String property, java.lang.Object value)
           
 void setupMapping(java.lang.String[] names, java.lang.String[] namespaces)
           
 java.lang.String shallowCopy(int node, SerializationHandler handler)
           
 void startDocument()
          We only need to override the endDocument, characters, and setEscaping interfaces.
 boolean supportsPreStripping()
           
 
Methods inherited from class org.apache.xml.serializer.EmptySerializer
addAttribute, addAttribute, addAttributes, asContentHandler, asDOMSerializer, attributeDecl, close, comment, comment, elementDecl, endCDATA, endDTD, endElement, endElement, endEntity, endPrefixMapping, entityReference, error, externalEntityDecl, fatalError, flushPending, getDoctypePublic, getDoctypeSystem, getEncoding, getIndent, getIndentAmount, getMediaType, getNamespaceMappings, getNamespaceURI, getNamespaceURIFromPrefix, getOmitXMLDeclaration, getOutputFormat, getOutputStream, getPrefix, getStandalone, getTransformer, getVersion, getWriter, ignorableWhitespace, internalEntityDecl, namespaceAfterStartElement, processingInstruction, reset, serialize, setCdataSectionElements, setCdataSectionElements, setContentHandler, setDoctype, setDoctypePublic, setDoctypeSystem, setDocumentLocator, setEncoding, setIndent, setIndentAmount, setMediaType, setNamespaceMappings, setOmitXMLDeclaration, setOutputFormat, setOutputStream, setSourceLocator, setStandalone, setTransformer, setVersion, setWriter, skippedEntity, startCDATA, startDTD, startElement, startElement, startElement, startEntity, startPrefixMapping, startPrefixMapping, warning
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RTF_ROOT

public static final int RTF_ROOT

RTF_TEXT

public static final int RTF_TEXT

NUMBER_OF_NODES

public static final int NUMBER_OF_NODES
Constructor Detail

SimpleResultTreeImpl

public SimpleResultTreeImpl(XSLTCDTMManager dtmManager,
                            int documentID)
Method Detail

getDTMManager

public DTMManagerDefault getDTMManager()

getDocument

public int getDocument()
Specified by:
getDocument in interface DOM

getStringValue

public java.lang.String getStringValue()
Specified by:
getStringValue in interface DOM

getIterator

public DTMAxisIterator getIterator()
Specified by:
getIterator in interface DOM

getChildren

public DTMAxisIterator getChildren(int node)
Specified by:
getChildren in interface DOM

getTypedChildren

public DTMAxisIterator getTypedChildren(int type)
Specified by:
getTypedChildren in interface DOM

getAxisIterator

public DTMAxisIterator getAxisIterator(int axis)
Specified by:
getAxisIterator in interface DOM

getTypedAxisIterator

public DTMAxisIterator getTypedAxisIterator(int axis,
                                            int type)
Specified by:
getTypedAxisIterator in interface DOM

getNthDescendant

public DTMAxisIterator getNthDescendant(int node,
                                        int n,
                                        boolean includeself)
Specified by:
getNthDescendant in interface DOM

getNamespaceAxisIterator

public DTMAxisIterator getNamespaceAxisIterator(int axis,
                                                int ns)
Specified by:
getNamespaceAxisIterator in interface DOM

getNodeValueIterator

public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iter,
                                            int returnType,
                                            java.lang.String value,
                                            boolean op)
Specified by:
getNodeValueIterator in interface DOM

orderNodes

public DTMAxisIterator orderNodes(DTMAxisIterator source,
                                  int node)
Specified by:
orderNodes in interface DOM

getNodeName

public java.lang.String getNodeName(int node)
Specified by:
getNodeName in interface DOM

getNodeNameX

public java.lang.String getNodeNameX(int node)
Specified by:
getNodeNameX in interface DOM

getNamespaceName

public java.lang.String getNamespaceName(int node)
Specified by:
getNamespaceName in interface DOM

getExpandedTypeID

public int getExpandedTypeID(int nodeHandle)
Specified by:
getExpandedTypeID in interface DOM

getNamespaceType

public int getNamespaceType(int node)
Specified by:
getNamespaceType in interface DOM

getParent

public int getParent(int nodeHandle)
Specified by:
getParent in interface DOM

getAttributeNode

public int getAttributeNode(int gType,
                            int element)
Specified by:
getAttributeNode in interface DOM

getStringValueX

public java.lang.String getStringValueX(int nodeHandle)
Specified by:
getStringValueX in interface DOM

copy

public void copy(int node,
                 SerializationHandler handler)
          throws TransletException
Specified by:
copy in interface DOM

copy

public void copy(DTMAxisIterator nodes,
                 SerializationHandler handler)
          throws TransletException
Specified by:
copy in interface DOM

shallowCopy

public java.lang.String shallowCopy(int node,
                                    SerializationHandler handler)
                             throws TransletException
Specified by:
shallowCopy in interface DOM

lessThan

public boolean lessThan(int node1,
                        int node2)
Specified by:
lessThan in interface DOM

characters

public void characters(int node,
                       SerializationHandler handler)
                throws TransletException
Dispatch the character content of a node to an output handler. The escape setting should be taken care of when outputting to a handler.
Specified by:
characters in interface DOM

makeNode

public Node makeNode(int index)
Specified by:
makeNode in interface DOM

makeNode

public Node makeNode(DTMAxisIterator iter)
Specified by:
makeNode in interface DOM

makeNodeList

public NodeList makeNodeList(int index)
Specified by:
makeNodeList in interface DOM

makeNodeList

public NodeList makeNodeList(DTMAxisIterator iter)
Specified by:
makeNodeList in interface DOM

getLanguage

public java.lang.String getLanguage(int node)
Specified by:
getLanguage in interface DOM

getSize

public int getSize()
Specified by:
getSize in interface DOM

getDocumentURI

public java.lang.String getDocumentURI(int node)
Specified by:
getDocumentURI in interface DOM

setFilter

public void setFilter(StripFilter filter)
Specified by:
setFilter in interface DOM

setupMapping

public void setupMapping(java.lang.String[] names,
                         java.lang.String[] namespaces)
Specified by:
setupMapping in interface DOM

isElement

public boolean isElement(int node)
Specified by:
isElement in interface DOM

isAttribute

public boolean isAttribute(int node)
Specified by:
isAttribute in interface DOM

lookupNamespace

public java.lang.String lookupNamespace(int node,
                                        java.lang.String prefix)
                                 throws TransletException
Specified by:
lookupNamespace in interface DOM

getNodeIdent

public int getNodeIdent(int nodehandle)
Return the node identity from a node handle.
Specified by:
getNodeIdent in interface DOM

getNodeHandle

public int getNodeHandle(int nodeId)
Return the node handle from a node identity.
Specified by:
getNodeHandle in interface DOM

getResultTreeFrag

public DOM getResultTreeFrag(int initialSize,
                             int rtfType)
Specified by:
getResultTreeFrag in interface DOM

getOutputDomBuilder

public SerializationHandler getOutputDomBuilder()
Specified by:
getOutputDomBuilder in interface DOM

getNSType

public int getNSType(int node)
Specified by:
getNSType in interface DOM

getUnparsedEntityURI

public java.lang.String getUnparsedEntityURI(java.lang.String name)
Specified by:
getUnparsedEntityURI in interface DOM

getElementsWithIDs

public Hashtable getElementsWithIDs()
Specified by:
getElementsWithIDs in interface DOM

startDocument

public void startDocument()
                   throws SAXException
We only need to override the endDocument, characters, and setEscaping interfaces. A simple RTF does not have element nodes. We do not need to touch startElement and endElement.
Overrides:
startDocument in class EmptySerializer

endDocument

public void endDocument()
                 throws SAXException
Overrides:
endDocument in class EmptySerializer

characters

public void characters(java.lang.String str)
                throws SAXException
Overrides:
characters in class EmptySerializer

characters

public void characters(char[] ch,
                       int offset,
                       int length)
                throws SAXException
Overrides:
characters in class EmptySerializer

setEscaping

public boolean setEscaping(boolean escape)
                    throws SAXException
Overrides:
setEscaping in class EmptySerializer

setFeature

public void setFeature(java.lang.String featureId,
                       boolean state)
The DTM interfaces are not used in this class. Implementing the DTM interface is a requirement from MultiDOM. If we have a better way of handling multiple documents, we can get rid of the DTM dependency. The following interfaces are just placeholders. The implementation does not have an impact because they will not be used.
Specified by:
setFeature in interface DTM

setProperty

public void setProperty(java.lang.String property,
                        java.lang.Object value)
Specified by:
setProperty in interface DTM

getAxisTraverser

public DTMAxisTraverser getAxisTraverser(int axis)
Specified by:
getAxisTraverser in interface DTM

hasChildNodes

public boolean hasChildNodes(int nodeHandle)
Specified by:
hasChildNodes in interface DTM

getFirstChild

public int getFirstChild(int nodeHandle)
Specified by:
getFirstChild in interface DTM

getLastChild

public int getLastChild(int nodeHandle)
Specified by:
getLastChild in interface DTM

getAttributeNode

public int getAttributeNode(int elementHandle,
                            java.lang.String namespaceURI,
                            java.lang.String name)
Specified by:
getAttributeNode in interface DTM

getFirstAttribute

public int getFirstAttribute(int nodeHandle)
Specified by:
getFirstAttribute in interface DTM

getFirstNamespaceNode

public int getFirstNamespaceNode(int nodeHandle,
                                 boolean inScope)
Specified by:
getFirstNamespaceNode in interface DTM

getNextSibling

public int getNextSibling(int nodeHandle)
Specified by:
getNextSibling in interface DTM

getPreviousSibling

public int getPreviousSibling(int nodeHandle)
Specified by:
getPreviousSibling in interface DTM

getNextAttribute

public int getNextAttribute(int nodeHandle)
Specified by:
getNextAttribute in interface DTM

getNextNamespaceNode

public int getNextNamespaceNode(int baseHandle,
                                int namespaceHandle,
                                boolean inScope)
Specified by:
getNextNamespaceNode in interface DTM

getOwnerDocument

public int getOwnerDocument(int nodeHandle)
Specified by:
getOwnerDocument in interface DTM

getDocumentRoot

public int getDocumentRoot(int nodeHandle)
Specified by:
getDocumentRoot in interface DTM

getStringValue

public XMLString getStringValue(int nodeHandle)
Specified by:
getStringValue in interface DTM

getStringValueChunkCount

public int getStringValueChunkCount(int nodeHandle)
Specified by:
getStringValueChunkCount in interface DTM

getStringValueChunk

public char[] getStringValueChunk(int nodeHandle,
                                  int chunkIndex,
                                  int[] startAndLen)
Specified by:
getStringValueChunk in interface DTM

getExpandedTypeID

public int getExpandedTypeID(java.lang.String namespace,
                             java.lang.String localName,
                             int type)
Specified by:
getExpandedTypeID in interface DTM

getLocalNameFromExpandedNameID

public java.lang.String getLocalNameFromExpandedNameID(int ExpandedNameID)
Specified by:
getLocalNameFromExpandedNameID in interface DTM

getNamespaceFromExpandedNameID

public java.lang.String getNamespaceFromExpandedNameID(int ExpandedNameID)
Specified by:
getNamespaceFromExpandedNameID in interface DTM

getLocalName

public java.lang.String getLocalName(int nodeHandle)
Specified by:
getLocalName in interface DTM

getPrefix

public java.lang.String getPrefix(int nodeHandle)
Specified by:
getPrefix in interface DTM

getNamespaceURI

public java.lang.String getNamespaceURI(int nodeHandle)
Specified by:
getNamespaceURI in interface DTM

getNodeValue

public java.lang.String getNodeValue(int nodeHandle)
Specified by:
getNodeValue in interface DTM

getNodeType

public short getNodeType(int nodeHandle)
Specified by:
getNodeType in interface DTM

getLevel

public short getLevel(int nodeHandle)
Specified by:
getLevel in interface DTM

isSupported

public boolean isSupported(java.lang.String feature,
                           java.lang.String version)
Specified by:
isSupported in interface DTM

getDocumentBaseURI

public java.lang.String getDocumentBaseURI()
Specified by:
getDocumentBaseURI in interface DTM

setDocumentBaseURI

public void setDocumentBaseURI(java.lang.String baseURI)
Specified by:
setDocumentBaseURI in interface DTM

getDocumentSystemIdentifier

public java.lang.String getDocumentSystemIdentifier(int nodeHandle)
Specified by:
getDocumentSystemIdentifier in interface DTM

getDocumentEncoding

public java.lang.String getDocumentEncoding(int nodeHandle)
Specified by:
getDocumentEncoding in interface DTM

getDocumentStandalone

public java.lang.String getDocumentStandalone(int nodeHandle)
Specified by:
getDocumentStandalone in interface DTM

getDocumentVersion

public java.lang.String getDocumentVersion(int documentHandle)
Specified by:
getDocumentVersion in interface DTM

getDocumentAllDeclarationsProcessed

public boolean getDocumentAllDeclarationsProcessed()
Specified by:
getDocumentAllDeclarationsProcessed in interface DTM

getDocumentTypeDeclarationSystemIdentifier

public java.lang.String getDocumentTypeDeclarationSystemIdentifier()
Specified by:
getDocumentTypeDeclarationSystemIdentifier in interface DTM

getDocumentTypeDeclarationPublicIdentifier

public java.lang.String getDocumentTypeDeclarationPublicIdentifier()
Specified by:
getDocumentTypeDeclarationPublicIdentifier in interface DTM

getElementById

public int getElementById(java.lang.String elementId)
Specified by:
getElementById in interface DTM

supportsPreStripping

public boolean supportsPreStripping()
Specified by:
supportsPreStripping in interface DTM

isNodeAfter

public boolean isNodeAfter(int firstNodeHandle,
                           int secondNodeHandle)
Specified by:
isNodeAfter in interface DTM

isCharacterElementContentWhitespace

public boolean isCharacterElementContentWhitespace(int nodeHandle)
Specified by:
isCharacterElementContentWhitespace in interface DTM

isDocumentAllDeclarationsProcessed

public boolean isDocumentAllDeclarationsProcessed(int documentHandle)
Specified by:
isDocumentAllDeclarationsProcessed in interface DTM

isAttributeSpecified

public boolean isAttributeSpecified(int attributeHandle)
Specified by:
isAttributeSpecified in interface DTM

dispatchCharactersEvents

public void dispatchCharactersEvents(int nodeHandle,
                                     ContentHandler ch,
                                     boolean normalize)
                              throws SAXException
Specified by:
dispatchCharactersEvents in interface DTM

dispatchToEvents

public void dispatchToEvents(int nodeHandle,
                             ContentHandler ch)
                      throws SAXException
Specified by:
dispatchToEvents in interface DTM

getNode

public Node getNode(int nodeHandle)
Specified by:
getNode in interface DTM

needsTwoThreads

public boolean needsTwoThreads()
Specified by:
needsTwoThreads in interface DTM

getContentHandler

public ContentHandler getContentHandler()
Specified by:
getContentHandler in interface DTM

getLexicalHandler

public LexicalHandler getLexicalHandler()
Specified by:
getLexicalHandler in interface DTM

getEntityResolver

public EntityResolver getEntityResolver()
Specified by:
getEntityResolver in interface DTM

getDTDHandler

public DTDHandler getDTDHandler()
Specified by:
getDTDHandler in interface DTM

getErrorHandler

public ErrorHandler getErrorHandler()
Specified by:
getErrorHandler in interface DTM

getDeclHandler

public DeclHandler getDeclHandler()
Specified by:
getDeclHandler in interface DTM

appendChild

public void appendChild(int newChild,
                        boolean clone,
                        boolean cloneDepth)
Specified by:
appendChild in interface DTM

appendTextChild

public void appendTextChild(java.lang.String str)
Specified by:
appendTextChild in interface DTM

getSourceLocatorFor

public SourceLocator getSourceLocatorFor(int node)
Specified by:
getSourceLocatorFor in interface DTM

documentRegistration

public void documentRegistration()
Specified by:
documentRegistration in interface DTM

documentRelease

public void documentRelease()
Specified by:
documentRelease in interface DTM


Copyright © 2003 Apache XML Project. All Rights Reserved.