org.apache.xalan.xsltc.dom

Class SimpleResultTreeImpl

Implemented Interfaces:
ContentHandler, DeclHandler, DOM, DOMSerializer, DTM, ErrorHandler, ExtendedContentHandler, ExtendedLexicalHandler, LexicalHandler, SerializationHandler, Serializer, XSLOutputAttributes
Known Direct 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.

Nested 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

Fields inherited from interface org.apache.xalan.xsltc.DOM

ADAPTIVE_RTF, FIRST_TYPE, NO_TYPE, NULL, RETURN_CURRENT, RETURN_PARENT, SIMPLE_RTF, TREE_RTF

Fields inherited from interface org.apache.xml.dtm.DTM

ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NAMESPACE_NODE, NOTATION_NODE, NTYPES, NULL, PROCESSING_INSTRUCTION_NODE, ROOT_NODE, TEXT_NODE

Fields inherited from interface org.apache.xml.serializer.ExtendedContentHandler

HTML_ATTREMPTY, HTML_ATTRURL, NO_BAD_CHARS

Constructor Summary

SimpleResultTreeImpl(XSLTCDTMManager dtmManager, int documentID)

Method Summary

void
appendChild(int newChild, boolean clone, boolean cloneDepth)
void
appendTextChild(String str)
void
characters(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
copy(int node, SerializationHandler handler)
void
copy(DTMAxisIterator nodes, 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 elementHandle, String namespaceURI, String name)
int
getAttributeNode(int gType, int element)
DTMAxisIterator
getAxisIterator(int axis)
DTMAxisTraverser
getAxisTraverser(int axis)
DTMAxisIterator
getChildren(int node)
ContentHandler
getContentHandler()
DTDHandler
getDTDHandler()
DTMManagerDefault
getDTMManager()
DeclHandler
getDeclHandler()
int
getDocument()
boolean
getDocumentAllDeclarationsProcessed()
String
getDocumentBaseURI()
String
getDocumentEncoding(int nodeHandle)
int
getDocumentRoot(int nodeHandle)
String
getDocumentStandalone(int nodeHandle)
String
getDocumentSystemIdentifier(int nodeHandle)
String
getDocumentTypeDeclarationPublicIdentifier()
String
getDocumentTypeDeclarationSystemIdentifier()
String
getDocumentURI(int node)
String
getDocumentVersion(int documentHandle)
int
getElementById(String elementId)
Hashtable
getElementsWithIDs()
EntityResolver
getEntityResolver()
ErrorHandler
getErrorHandler()
int
getExpandedTypeID(String namespace, String localName, int type)
int
getExpandedTypeID(int nodeHandle)
int
getFirstAttribute(int nodeHandle)
int
getFirstChild(int nodeHandle)
int
getFirstNamespaceNode(int nodeHandle, boolean inScope)
DTMAxisIterator
getIterator()
String
getLanguage(int node)
int
getLastChild(int nodeHandle)
short
getLevel(int nodeHandle)
LexicalHandler
getLexicalHandler()
String
getLocalName(int nodeHandle)
String
getLocalNameFromExpandedNameID(int ExpandedNameID)
int
getNSType(int node)
DTMAxisIterator
getNamespaceAxisIterator(int axis, int ns)
String
getNamespaceFromExpandedNameID(int ExpandedNameID)
String
getNamespaceName(int node)
int
getNamespaceType(int node)
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.
String
getNodeName(int node)
String
getNodeNameX(int node)
short
getNodeType(int nodeHandle)
String
getNodeValue(int nodeHandle)
DTMAxisIterator
getNodeValueIterator(DTMAxisIterator iter, int returnType, String value, boolean op)
DTMAxisIterator
getNthDescendant(int node, int n, boolean includeself)
SerializationHandler
getOutputDomBuilder()
int
getOwnerDocument(int nodeHandle)
int
getParent(int nodeHandle)
String
getPrefix(int nodeHandle)
int
getPreviousSibling(int nodeHandle)
DOM
getResultTreeFrag(int initialSize, int rtfType)
DOM
getResultTreeFrag(int initialSize, int rtfType, boolean addToManager)
int
getSize()
SourceLocator
getSourceLocatorFor(int node)
String
getStringValue()
XMLString
getStringValue(int nodeHandle)
char[]
getStringValueChunk(int nodeHandle, int chunkIndex, int[] startAndLen)
int
getStringValueChunkCount(int nodeHandle)
String
getStringValueX(int nodeHandle)
DTMAxisIterator
getTypedAxisIterator(int axis, int type)
DTMAxisIterator
getTypedChildren(int type)
String
getUnparsedEntityURI(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(String feature, String version)
boolean
lessThan(int node1, int node2)
String
lookupNamespace(int node, String prefix)
Node
makeNode(int index)
Node
makeNode(DTMAxisIterator iter)
NodeList
makeNodeList(int index)
NodeList
makeNodeList(DTMAxisIterator iter)
void
migrateTo(DTMManager manager)
boolean
needsTwoThreads()
DTMAxisIterator
orderNodes(DTMAxisIterator source, int node)
void
setDocumentBaseURI(String baseURI)
boolean
setEscaping(boolean escape)
void
setFeature(String featureId, boolean state)
The DTM interfaces are not used in this class.
void
setFilter(StripFilter filter)
void
setProperty(String property, Object value)
void
setupMapping(String[] names, String[] uris, int[] types, String[] namespaces)
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, addUniqueAttribute, asContentHandler, asDOMSerializer, attributeDecl, characters, characters, close, comment, comment, elementDecl, endCDATA, endDTD, endDocument, 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, setEscaping, setIndent, setIndentAmount, setMediaType, setNamespaceMappings, setOmitXMLDeclaration, setOutputFormat, setOutputStream, setSourceLocator, setStandalone, setTransformer, setVersion, setWriter, skippedEntity, startCDATA, startDTD, startDocument, startElement, startElement, startElement, startEntity, startPrefixMapping, startPrefixMapping, warning

Field Details

NUMBER_OF_NODES

public static final int NUMBER_OF_NODES
Field Value:
2

RTF_ROOT

public static final int RTF_ROOT
Field Value:
0

RTF_TEXT

public static final int RTF_TEXT
Field Value:
1

Constructor Details

SimpleResultTreeImpl

public SimpleResultTreeImpl(XSLTCDTMManager dtmManager,
                            int documentID)

Method Details

appendChild

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

appendTextChild

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

characters

public void characters(String str)
            throws SAXException
Specified by:
characters in interface ExtendedContentHandler
Overrides:
characters in interface EmptySerializer

characters

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

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

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

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

documentRegistration

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

documentRelease

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

endDocument

public void endDocument()
            throws SAXException
Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in interface EmptySerializer

getAttributeNode

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

getAttributeNode

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

getAxisIterator

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

getAxisTraverser

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

getChildren

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

getContentHandler

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

getDTDHandler

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

getDTMManager

public DTMManagerDefault getDTMManager()

getDeclHandler

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

getDocument

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

getDocumentAllDeclarationsProcessed

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

getDocumentBaseURI

public String getDocumentBaseURI()
Specified by:
getDocumentBaseURI in interface DTM

getDocumentEncoding

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

getDocumentRoot

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

getDocumentStandalone

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

getDocumentSystemIdentifier

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

getDocumentTypeDeclarationPublicIdentifier

public String getDocumentTypeDeclarationPublicIdentifier()
Specified by:
getDocumentTypeDeclarationPublicIdentifier in interface DTM

getDocumentTypeDeclarationSystemIdentifier

public String getDocumentTypeDeclarationSystemIdentifier()
Specified by:
getDocumentTypeDeclarationSystemIdentifier in interface DTM

getDocumentURI

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

getDocumentVersion

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

getElementById

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

getElementsWithIDs

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

getEntityResolver

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

getErrorHandler

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

getExpandedTypeID

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

getExpandedTypeID

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

getFirstAttribute

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

getFirstChild

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

getFirstNamespaceNode

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

getIterator

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

getLanguage

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

getLastChild

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

getLevel

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

getLexicalHandler

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

getLocalName

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

getLocalNameFromExpandedNameID

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

getNSType

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

getNamespaceAxisIterator

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

getNamespaceFromExpandedNameID

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

getNamespaceName

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

getNamespaceType

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

getNamespaceURI

public String getNamespaceURI(int nodeHandle)
Specified by:
getNamespaceURI 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

getNextSibling

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

getNode

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

getNodeHandle

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

getNodeIdent

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

getNodeName

public String getNodeName(int node)
Specified by:
getNodeName in interface DOM
getNodeName in interface DTM

getNodeNameX

public String getNodeNameX(int node)
Specified by:
getNodeNameX in interface DOM
getNodeNameX in interface DTM

getNodeType

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

getNodeValue

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

getNodeValueIterator

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

getNthDescendant

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

getOutputDomBuilder

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

getOwnerDocument

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

getParent

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

getPrefix

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

getPreviousSibling

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

getResultTreeFrag

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

getResultTreeFrag

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

getSize

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

getSourceLocatorFor

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

getStringValue

public String getStringValue()
Specified by:
getStringValue in interface DOM

getStringValue

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

getStringValueChunk

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

getStringValueChunkCount

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

getStringValueX

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

getTypedAxisIterator

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

getTypedChildren

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

getUnparsedEntityURI

public String getUnparsedEntityURI(String name)
Specified by:
getUnparsedEntityURI in interface DOM
getUnparsedEntityURI in interface DTM

hasChildNodes

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

isAttribute

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

isAttributeSpecified

public boolean isAttributeSpecified(int attributeHandle)
Specified by:
isAttributeSpecified 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

isElement

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

isNodeAfter

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

isSupported

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

lessThan

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

lookupNamespace

public String lookupNamespace(int node,
                              String prefix)
            throws TransletException
Specified by:
lookupNamespace 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

migrateTo

public void migrateTo(DTMManager manager)
Specified by:
migrateTo in interface DTM

needsTwoThreads

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

orderNodes

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

setDocumentBaseURI

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

setEscaping

public boolean setEscaping(boolean escape)
            throws SAXException
Specified by:
setEscaping in interface SerializationHandler
Overrides:
setEscaping in interface EmptySerializer

setFeature

public void setFeature(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

setFilter

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

setProperty

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

setupMapping

public void setupMapping(String[] names,
                         String[] uris,
                         int[] types,
                         String[] namespaces)
Specified by:
setupMapping in interface DOM

shallowCopy

public String shallowCopy(int node,
                          SerializationHandler handler)
            throws TransletException
Specified by:
shallowCopy 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.
Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in interface EmptySerializer

supportsPreStripping

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

Copyright B) 2004 Apache XML Project. All Rights Reserved.