org.apache.xalan.xsltc.dom

Class SAXImpl

public final class SAXImpl extends SAX2DTM2 implements DOMEnhancedForDTM, DOMBuilder

SAXImpl is the core model for SAX input source. SAXImpl objects are usually created from an XSLTCDTMManager.

DOMSource inputs are handled using DOM2SAX + SAXImpl. SAXImpl has a few specific fields (e.g. _node2Ids, _document) to keep DOM-related information. They are used when the processing behavior between DOM and SAX has to be different. Examples of these include id function and unparsed entity.

SAXImpl extends SAX2DTM2 instead of SAX2DTM for better performance.

Author: Jacek Ambroziak Santiago Pericas-Geertsen Morten Jorgensen Douglas Sellers

Nested Class Summary
classSAXImpl.NamespaceAttributeIterator
Iterator that returns attributes within a given namespace for a node.
classSAXImpl.NamespaceChildrenIterator
Iterator that returns children within a given namespace for a given node.
classSAXImpl.NamespaceWildcardIterator
Iterator that handles node tests that test for a namespace, but have a wild card for the local name of the node, i.e., node tests of the form :::*
classSAXImpl.TypedNamespaceIterator
Iterator that returns the namespace nodes as defined by the XPath data model for a given node, filtered by extended type ID.
Constructor Summary
SAXImpl(XSLTCDTMManager mgr, Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing, boolean buildIdIndex)
Construct a SAXImpl object using the default block size.
SAXImpl(XSLTCDTMManager mgr, Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing, int blocksize, boolean buildIdIndex, boolean newNameTable)
Construct a SAXImpl object using the given block size.
Method Summary
voidcharacters(char[] ch, int start, int length)
SAX2: Receive notification of character data.
voidcharacters(int node, SerializationHandler handler)
Copy the string value of a node directly to an output handler
voidcomment(char[] ch, int start, int length)
SAX2: Report an XML comment anywhere in the document.
voidcopy(DTMAxisIterator nodes, SerializationHandler handler)
Copy a node-set to an output handler
voidcopy(SerializationHandler handler)
Copy the whole tree to an output handler
voidcopy(int node, SerializationHandler handler)
Performs a deep copy (ref.
voidendDocument()
SAX2: Receive notification of the end of a document.
voidendElement(String namespaceURI, String localName, String qname)
SAX2: Receive notification of the end of an element.
intgetAttributeNode(int type, int element)
Returns the attribute node of a given type (if any) for an element
StringgetAttributeValue(int type, int element)
Returns the value of a given attribute type of a given element
StringgetAttributeValue(String name, int element)
This method is for testing/debugging only
DTMAxisIteratorgetAxisIterator(int axis)
This is a shortcut to the iterators that implement the supported XPath axes (only namespace::) is not supported.
DOMBuildergetBuilder()
Returns an instance of the DOMBuilder inner class This class will consume the input document through a SAX2 interface and populate the tree.
DTMAxisIteratorgetChildren(int node)
Returns an iterator with all the children of a given node
StringgetDocumentURI()
Returns the origin of the document from which the tree was built
StringgetDocumentURI(int node)
intgetElementById(String idString)
Return the node identity for a given id String
HashtablegetElementsWithIDs()
%HZ% Need Javadoc
intgetGeneralizedType(String name)
Returns the internal type associated with an expanded QName
intgetGeneralizedType(String name, boolean searchOnly)
Returns the internal type associated with an expanded QName
DTMAxisIteratorgetIterator()
Returns singleton iterator containg the document root Works for them main document (mark == 0)
StringgetLanguage(int node)
Returns a node' defined language for a node (if any)
short[]getMapping(String[] names, String[] uris, int[] types)
Get mapping from DOM element/attribute types to external types
DTMAxisIteratorgetNamespaceAxisIterator(int axis, int ns)
Do not think that this returns an iterator for the namespace axis.
short[]getNamespaceMapping(String[] namespaces)
Get mapping from DOM namespace types to external namespace types
StringgetNamespaceName(int node)
Returns the namespace URI to which a node belongs
intgetNamespaceType(int node)
Returns the namespace type of a specific node
StringgetNodeName(int node)
Returns the name of a node (attribute or element).
DTMAxisIteratorgetNodeValueIterator(DTMAxisIterator iterator, int type, String value, boolean op)
intgetNSType(int node)
Get mapping from DOM namespace types to external namespace types
DTMAxisIteratorgetNthDescendant(int type, int n, boolean includeself)
Returns the nth descendant of a node
SerializationHandlergetOutputDomBuilder()
Return a SerializationHandler for output handling.
DOMgetResultTreeFrag(int initSize, int rtfType)
Return a instance of a DOM class to be used as an RTF
DOMgetResultTreeFrag(int initSize, int rtfType, boolean addToManager)
Return a instance of a DOM class to be used as an RTF
int[]getReverseMapping(String[] names, String[] uris, int[] types)
Get mapping from external element/attribute types to DOM types
short[]getReverseNamespaceMapping(String[] namespaces)
Get mapping from external namespace types to DOM namespace types
intgetSize()
Returns the number of nodes in the tree (used for indexing)
DTMAxisIteratorgetTypedAxisIterator(int axis, int type)
Similar to getAxisIterator, but this one returns an iterator containing nodes of a typed axis (ex.: child::foo)
DTMAxisIteratorgetTypedChildren(int type)
Returns an iterator with all children of a specific type for a given node (element)
DTMAxisIteratorgetTypedDescendantIterator(int type)
Returns an iterator with all descendants of a node that are of a given type.
StringgetUnparsedEntityURI(String name)
The getUnparsedEntityURI function returns the URI of the unparsed entity with the specified name in the same document as the context node (see [3.3 Unparsed Entities]).
booleanhasDOMSource()
Return true if the input source is DOMSource.
voidignorableWhitespace(char[] ch, int start, int length)
SAX2: Receive notification of ignorable whitespace in element content.
booleanisAttribute(int node)
Returns 'true' if a specific node is an attribute (of any type)
booleanisElement(int node)
Returns 'true' if a specific node is an element (of any type)
booleanlessThan(int node1, int node2)
Returns true if node1 comes before node2 in document order
StringlookupNamespace(int node, String prefix)
Lookup a namespace URI from a prefix starting at node.
NodemakeNode(int index)
Create an org.w3c.dom.Node from a node in the tree
NodemakeNode(DTMAxisIterator iter)
Create an org.w3c.dom.Node from a node in an iterator The iterator most be started before this method is called
NodeListmakeNodeList(int index)
Create an org.w3c.dom.NodeList from a node in the tree
NodeListmakeNodeList(DTMAxisIterator iter)
Create an org.w3c.dom.NodeList from a node iterator The iterator most be started before this method is called
voidmigrateTo(DTMManager manager)
Migrate a DTM built with an old DTMManager to a new DTMManager.
DTMAxisIteratororderNodes(DTMAxisIterator source, int node)
Encapsulates an iterator in an OrderedIterator to ensure node order
voidprint(int node, int level)
Prints the whole tree to standard output
voidprocessingInstruction(String target, String data)
SAX2: Receive notification of a processing instruction.
voidsetDocumentURI(String uri)
Define the origin of the document from which the tree was built
booleansetEscaping(boolean value)
voidsetFilter(StripFilter filter)
Part of the DOM interface - no function here.
voidsetupMapping(String[] names, String[] urisArray, int[] typesArray, String[] namespaces)
StringshallowCopy(int node, SerializationHandler handler)
Performs a shallow copy (ref.
voidstartDocument()
SAX2: Receive notification of the beginning of a document.
voidstartElement(String uri, String localName, String qname, Attributes attributes, Node node)
Specialized interface used by DOM2SAX.
voidstartElement(String uri, String localName, String qname, Attributes attributes)
SAX2: Receive notification of the beginning of an element.
voidstartPrefixMapping(String prefix, String uri)
SAX2: Begin the scope of a prefix-URI Namespace mapping.

Constructor Detail

SAXImpl

public SAXImpl(XSLTCDTMManager mgr, Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing, boolean buildIdIndex)
Construct a SAXImpl object using the default block size.

SAXImpl

public SAXImpl(XSLTCDTMManager mgr, Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing, int blocksize, boolean buildIdIndex, boolean newNameTable)
Construct a SAXImpl object using the given block size.

Method Detail

characters

public void characters(char[] ch, int start, int length)
SAX2: Receive notification of character data.

characters

public void characters(int node, SerializationHandler handler)
Copy the string value of a node directly to an output handler

comment

public void comment(char[] ch, int start, int length)
SAX2: Report an XML comment anywhere in the document.

copy

public void copy(DTMAxisIterator nodes, SerializationHandler handler)
Copy a node-set to an output handler

copy

public void copy(SerializationHandler handler)
Copy the whole tree to an output handler

copy

public void copy(int node, SerializationHandler handler)
Performs a deep copy (ref. XSLs copy-of()) TODO: Copy namespace declarations. Can't be done until we add namespace nodes and keep track of NS prefixes TODO: Copy comment nodes

endDocument

public void endDocument()
SAX2: Receive notification of the end of a document.

endElement

public void endElement(String namespaceURI, String localName, String qname)
SAX2: Receive notification of the end of an element.

getAttributeNode

public int getAttributeNode(int type, int element)
Returns the attribute node of a given type (if any) for an element

getAttributeValue

public String getAttributeValue(int type, int element)
Returns the value of a given attribute type of a given element

getAttributeValue

public String getAttributeValue(String name, int element)
This method is for testing/debugging only

getAxisIterator

public DTMAxisIterator getAxisIterator(int axis)
This is a shortcut to the iterators that implement the supported XPath axes (only namespace::) is not supported. Returns a bare-bones iterator that must be initialized with a start node (using iterator.setStartNode()).

getBuilder

public DOMBuilder getBuilder()
Returns an instance of the DOMBuilder inner class This class will consume the input document through a SAX2 interface and populate the tree.

getChildren

public DTMAxisIterator getChildren(int node)
Returns an iterator with all the children of a given node

getDocumentURI

public String getDocumentURI()
Returns the origin of the document from which the tree was built

getDocumentURI

public String getDocumentURI(int node)

getElementById

public int getElementById(String idString)
Return the node identity for a given id String

Parameters: idString The id String

Returns: The identity of the node whose id is the given String.

getElementsWithIDs

public Hashtable getElementsWithIDs()
%HZ% Need Javadoc

getGeneralizedType

public int getGeneralizedType(String name)
Returns the internal type associated with an expanded QName

getGeneralizedType

public int getGeneralizedType(String name, boolean searchOnly)
Returns the internal type associated with an expanded QName

getIterator

public DTMAxisIterator getIterator()
Returns singleton iterator containg the document root Works for them main document (mark == 0)

getLanguage

public String getLanguage(int node)
Returns a node' defined language for a node (if any)

getMapping

public short[] getMapping(String[] names, String[] uris, int[] types)
Get mapping from DOM element/attribute types to external types

getNamespaceAxisIterator

public DTMAxisIterator getNamespaceAxisIterator(int axis, int ns)
Do not think that this returns an iterator for the namespace axis. It returns an iterator with nodes that belong in a certain namespace, such as with The 'axis' specifies the axis for the base iterator from which the nodes are taken, while 'ns' specifies the namespace URI type.

getNamespaceMapping

public short[] getNamespaceMapping(String[] namespaces)
Get mapping from DOM namespace types to external namespace types

getNamespaceName

public String getNamespaceName(int node)
Returns the namespace URI to which a node belongs

getNamespaceType

public int getNamespaceType(int node)
Returns the namespace type of a specific node

getNodeName

public String getNodeName(int node)
Returns the name of a node (attribute or element).

getNodeValueIterator

public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iterator, int type, String value, boolean op)

getNSType

public int getNSType(int node)
Get mapping from DOM namespace types to external namespace types

getNthDescendant

public DTMAxisIterator getNthDescendant(int type, int n, boolean includeself)
Returns the nth descendant of a node

getOutputDomBuilder

public SerializationHandler getOutputDomBuilder()
Return a SerializationHandler for output handling. This method is used by Result Tree Fragments.

getResultTreeFrag

public DOM getResultTreeFrag(int initSize, int rtfType)
Return a instance of a DOM class to be used as an RTF

getResultTreeFrag

public DOM getResultTreeFrag(int initSize, int rtfType, boolean addToManager)
Return a instance of a DOM class to be used as an RTF

Parameters: initSize The initial size of the DOM. rtfType The type of the RTF addToManager true if the RTF should be registered with the DTMManager.

Returns: The DOM object which represents the RTF.

getReverseMapping

public int[] getReverseMapping(String[] names, String[] uris, int[] types)
Get mapping from external element/attribute types to DOM types

getReverseNamespaceMapping

public short[] getReverseNamespaceMapping(String[] namespaces)
Get mapping from external namespace types to DOM namespace types

getSize

public int getSize()
Returns the number of nodes in the tree (used for indexing)

getTypedAxisIterator

public DTMAxisIterator getTypedAxisIterator(int axis, int type)
Similar to getAxisIterator, but this one returns an iterator containing nodes of a typed axis (ex.: child::foo)

getTypedChildren

public DTMAxisIterator getTypedChildren(int type)
Returns an iterator with all children of a specific type for a given node (element)

getTypedDescendantIterator

public DTMAxisIterator getTypedDescendantIterator(int type)
Returns an iterator with all descendants of a node that are of a given type.

getUnparsedEntityURI

public String getUnparsedEntityURI(String name)
The getUnparsedEntityURI function returns the URI of the unparsed entity with the specified name in the same document as the context node (see [3.3 Unparsed Entities]). It returns the empty string if there is no such entity.

hasDOMSource

public boolean hasDOMSource()
Return true if the input source is DOMSource.

ignorableWhitespace

public void ignorableWhitespace(char[] ch, int start, int length)
SAX2: Receive notification of ignorable whitespace in element content. Similar to characters(char[], int, int).

isAttribute

public boolean isAttribute(int node)
Returns 'true' if a specific node is an attribute (of any type)

isElement

public boolean isElement(int node)
Returns 'true' if a specific node is an element (of any type)

lessThan

public boolean lessThan(int node1, int node2)
Returns true if node1 comes before node2 in document order

lookupNamespace

public String lookupNamespace(int node, String prefix)
Lookup a namespace URI from a prefix starting at node. This method is used in the execution of xsl:element when the prefix is not known at compile time.

makeNode

public Node makeNode(int index)
Create an org.w3c.dom.Node from a node in the tree

makeNode

public Node makeNode(DTMAxisIterator iter)
Create an org.w3c.dom.Node from a node in an iterator The iterator most be started before this method is called

makeNodeList

public NodeList makeNodeList(int index)
Create an org.w3c.dom.NodeList from a node in the tree

makeNodeList

public NodeList makeNodeList(DTMAxisIterator iter)
Create an org.w3c.dom.NodeList from a node iterator The iterator most be started before this method is called

migrateTo

public void migrateTo(DTMManager manager)
Migrate a DTM built with an old DTMManager to a new DTMManager. After the migration, the new DTMManager will treat the DTM as one that is built by itself. This is used to support DTM sharing between multiple transformations.

Parameters: manager the DTMManager

orderNodes

public DTMAxisIterator orderNodes(DTMAxisIterator source, int node)
Encapsulates an iterator in an OrderedIterator to ensure node order

print

public void print(int node, int level)
Prints the whole tree to standard output

processingInstruction

public void processingInstruction(String target, String data)
SAX2: Receive notification of a processing instruction.

setDocumentURI

public void setDocumentURI(String uri)
Define the origin of the document from which the tree was built

setEscaping

public boolean setEscaping(boolean value)

setFilter

public void setFilter(StripFilter filter)
Part of the DOM interface - no function here.

setupMapping

public void setupMapping(String[] names, String[] urisArray, int[] typesArray, String[] namespaces)

shallowCopy

public String shallowCopy(int node, SerializationHandler handler)
Performs a shallow copy (ref. XSLs copy())

startDocument

public void startDocument()
SAX2: Receive notification of the beginning of a document.

startElement

public void startElement(String uri, String localName, String qname, Attributes attributes, Node node)
Specialized interface used by DOM2SAX. This one has an extra Node parameter to build the Node -> id map.

startElement

public void startElement(String uri, String localName, String qname, Attributes attributes)
SAX2: Receive notification of the beginning of an element.

startPrefixMapping

public void startPrefixMapping(String prefix, String uri)
SAX2: Begin the scope of a prefix-URI Namespace mapping.
Copyright © 2005 Apache XML Project. All Rights Reserved.