Class SAX2DTM
- java.lang.Object
-
- org.apache.xml.dtm.ref.DTMDefaultBase
-
- org.apache.xml.dtm.ref.DTMDefaultBaseTraversers
-
- org.apache.xml.dtm.ref.DTMDefaultBaseIterators
-
- org.apache.xml.dtm.ref.sax2dtm.SAX2DTM
-
- All Implemented Interfaces:
DTM
,org.xml.sax.ContentHandler
,org.xml.sax.DTDHandler
,org.xml.sax.EntityResolver
,org.xml.sax.ErrorHandler
,org.xml.sax.ext.DeclHandler
,org.xml.sax.ext.LexicalHandler
- Direct Known Subclasses:
SAX2DTM2
,SAX2RTFDTM
public class SAX2DTM extends DTMDefaultBaseIterators implements org.xml.sax.EntityResolver, org.xml.sax.DTDHandler, org.xml.sax.ContentHandler, org.xml.sax.ErrorHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.ext.LexicalHandler
This class implements a DTM that tends to be optimized more for speed than for compactness, that is constructed via SAX2 ContentHandler events.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.xml.dtm.ref.DTMDefaultBaseIterators
DTMDefaultBaseIterators.AncestorIterator, DTMDefaultBaseIterators.AttributeIterator, DTMDefaultBaseIterators.ChildrenIterator, DTMDefaultBaseIterators.DescendantIterator, DTMDefaultBaseIterators.FollowingIterator, DTMDefaultBaseIterators.FollowingSiblingIterator, DTMDefaultBaseIterators.InternalAxisIteratorBase, DTMDefaultBaseIterators.NamespaceAttributeIterator, DTMDefaultBaseIterators.NamespaceChildrenIterator, DTMDefaultBaseIterators.NamespaceIterator, DTMDefaultBaseIterators.NthDescendantIterator, DTMDefaultBaseIterators.ParentIterator, DTMDefaultBaseIterators.PrecedingIterator, DTMDefaultBaseIterators.PrecedingSiblingIterator, DTMDefaultBaseIterators.RootIterator, DTMDefaultBaseIterators.SingletonIterator, DTMDefaultBaseIterators.TypedAncestorIterator, DTMDefaultBaseIterators.TypedAttributeIterator, DTMDefaultBaseIterators.TypedChildrenIterator, DTMDefaultBaseIterators.TypedDescendantIterator, DTMDefaultBaseIterators.TypedFollowingIterator, DTMDefaultBaseIterators.TypedFollowingSiblingIterator, DTMDefaultBaseIterators.TypedNamespaceIterator, DTMDefaultBaseIterators.TypedPrecedingIterator, DTMDefaultBaseIterators.TypedPrecedingSiblingIterator, DTMDefaultBaseIterators.TypedRootIterator, DTMDefaultBaseIterators.TypedSingletonIterator
-
-
Field Summary
-
Fields inherited from class org.apache.xml.dtm.ref.DTMDefaultBase
DEFAULT_BLOCKSIZE, DEFAULT_NUMBLOCKS, DEFAULT_NUMBLOCKS_SMALL, m_mgr, ROOTNODE
-
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
-
-
Constructor Summary
Constructors Constructor Description SAX2DTM(DTMManager mgr, javax.xml.transform.Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing)
Construct a SAX2DTM object using the default block size.SAX2DTM(DTMManager mgr, javax.xml.transform.Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing, int blocksize, boolean usePrevsib, boolean newNameTable)
Construct a SAX2DTM object ready to be constructed from SAX2 ContentHandler events.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value)
Report an attribute type declaration.void
characters(char[] ch, int start, int length)
Receive notification of character data inside an element.void
clearCoRoutine()
Ask the CoRoutine parser to doTerminate and clear the reference.void
clearCoRoutine(boolean callDoTerminate)
Ask the CoRoutine parser to doTerminate and clear the reference.void
comment(char[] ch, int start, int length)
Report an XML comment anywhere in the document.void
dispatchCharactersEvents(int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize)
Directly call the characters method on the passed ContentHandler for the string-value of the given node (see http://www.w3.org/TR/xpath#data-model for the definition of a node's string-value).void
dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
Directly create SAX parser events from a subtree.void
elementDecl(java.lang.String name, java.lang.String model)
Report an element type declaration.void
endCDATA()
Report the end of a CDATA section.void
endDocument()
Receive notification of the end of the document.void
endDTD()
Report the end of DTD declarations.void
endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
Receive notification of the end of an element.void
endEntity(java.lang.String name)
Report the end of an entity.void
endPrefixMapping(java.lang.String prefix)
Receive notification of the end of a Namespace mapping.void
error(org.xml.sax.SAXParseException e)
Receive notification of a recoverable parser error.void
externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
Report a parsed external entity declaration.void
fatalError(org.xml.sax.SAXParseException e)
Report a fatal XML parsing error.int
getAttributeNode(int nodeHandle, java.lang.String namespaceURI, java.lang.String name)
Retrieves an attribute node by by qualified name and namespace URI.org.xml.sax.ContentHandler
getContentHandler()
getContentHandler returns "our SAX builder" -- the thing that someone else should send SAX events to in order to extend this DTM model.org.xml.sax.ext.DeclHandler
getDeclHandler()
Return this DTM's DeclHandler.java.lang.String
getDocumentTypeDeclarationPublicIdentifier()
Return the public identifier of the external subset, normalized as described in 4.2.2 External Entities [XML].java.lang.String
getDocumentTypeDeclarationSystemIdentifier()
A document type declaration information item has the following properties: 1.org.xml.sax.DTDHandler
getDTDHandler()
Return this DTM's DTDHandler.int
getElementById(java.lang.String elementId)
Returns theElement
whoseID
is given byelementId
.org.xml.sax.EntityResolver
getEntityResolver()
Return this DTM's EntityResolver.org.xml.sax.ErrorHandler
getErrorHandler()
Return this DTM's ErrorHandler.java.lang.String
getFixedNames(int type)
int
getIdForNamespace(java.lang.String uri)
Get a prefix either from the uri mapping, or just make one up!org.xml.sax.ext.LexicalHandler
getLexicalHandler()
Return this DTM's lexical handler.java.lang.String
getLocalName(int nodeHandle)
Given a node handle, return its XPath-style localname.java.lang.String
getNamespaceURI(int nodeHandle)
Given a node handle, return its DOM-style namespace URI (As defined in Namespaces, this is the declared URI which this node's prefix -- or default in lieu thereof -- was mapped to.)java.lang.String
getNamespaceURI(java.lang.String prefix)
Get a prefix either from the qname or from the uri mapping, or just make one up!java.lang.String
getNodeName(int nodeHandle)
Given a node handle, return its DOM-style node name.java.lang.String
getNodeNameX(int nodeHandle)
Given a node handle, return the XPath node name.java.lang.String
getNodeValue(int nodeHandle)
Given a node handle, return its node value.int
getNumberOfNodes()
Get the number of nodes that have been added.java.lang.String
getPrefix(int nodeHandle)
Given a namespace handle, return the prefix that the namespace decl is mapping.java.lang.String
getPrefix(java.lang.String qname, java.lang.String uri)
Get a prefix either from the qname or from the uri mapping, or just make one up!javax.xml.transform.SourceLocator
getSourceLocatorFor(int node)
Retrieve the SourceLocator associated with a specific node.XMLString
getStringValue(int nodeHandle)
Get the string-value of a node as a String object (see http://www.w3.org/TR/xpath#data-model for the definition of a node's string-value).java.lang.String
getUnparsedEntityURI(java.lang.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]).void
ignorableWhitespace(char[] ch, int start, int length)
Receive notification of ignorable whitespace in element content.void
internalEntityDecl(java.lang.String name, java.lang.String value)
Report an internal entity declaration.boolean
isAttributeSpecified(int attributeHandle)
5.boolean
isWhitespace(int nodeHandle)
Determine if the string-value of a node is whitespacevoid
migrateTo(DTMManager manager)
Migrate a DTM built with an old DTMManager to a new DTMManager.boolean
needsTwoThreads()
void
notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
Receive notification of a notation declaration.void
processingInstruction(java.lang.String target, java.lang.String data)
Receive notification of a processing instruction.org.xml.sax.InputSource
resolveEntity(java.lang.String publicId, java.lang.String systemId)
Resolve an external entity.void
setDocumentLocator(org.xml.sax.Locator locator)
Receive a Locator object for document events.void
setIDAttribute(java.lang.String id, int elem)
Set an ID string to node association in the ID table.void
setIncrementalSAXSource(IncrementalSAXSource incrementalSAXSource)
Bind a IncrementalSAXSource to this DTM.void
setProperty(java.lang.String property, java.lang.Object value)
Set a run time property for this DTM instance.void
setUseSourceLocation(boolean useSourceLocation)
Set whether information about document source location should be maintained or not.void
skippedEntity(java.lang.String name)
Receive notification of a skipped entity.void
startCDATA()
Report the start of a CDATA section.void
startDocument()
Receive notification of the beginning of the document.void
startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
Report the start of DTD declarations, if any.void
startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
Receive notification of the start of an element.void
startEntity(java.lang.String name)
Report the beginning of an entity in content.void
startPrefixMapping(java.lang.String prefix, java.lang.String uri)
Receive notification of the start of a Namespace mapping.void
unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)
Receive notification of an unparsed entity declaration.void
warning(org.xml.sax.SAXParseException e)
Receive notification of a parser warning.-
Methods inherited from class org.apache.xml.dtm.ref.DTMDefaultBaseIterators
getAxisIterator, getTypedAxisIterator
-
Methods inherited from class org.apache.xml.dtm.ref.DTMDefaultBaseTraversers
getAxisTraverser
-
Methods inherited from class org.apache.xml.dtm.ref.DTMDefaultBase
appendChild, appendTextChild, documentRegistration, documentRelease, dumpDTM, dumpNode, getDocument, getDocumentAllDeclarationsProcessed, getDocumentBaseURI, getDocumentEncoding, getDocumentRoot, getDocumentStandalone, getDocumentSystemIdentifier, getDocumentVersion, getDTMIDs, getExpandedTypeID, getExpandedTypeID, getFirstAttribute, getFirstChild, getFirstNamespaceNode, getLastChild, getLevel, getLocalNameFromExpandedNameID, getManager, getNamespaceFromExpandedNameID, getNamespaceType, getNextAttribute, getNextNamespaceNode, getNextSibling, getNode, getNodeHandle, getNodeIdent, getNodeType, getOwnerDocument, getParent, getPreviousSibling, getStringValueChunk, getStringValueChunkCount, getTypedFirstChild, getTypedNextSibling, hasChildNodes, isCharacterElementContentWhitespace, isDocumentAllDeclarationsProcessed, isNodeAfter, isSupported, makeNodeHandle, makeNodeIdentity, setDocumentBaseURI, setFeature, supportsPreStripping
-
-
-
-
Constructor Detail
-
SAX2DTM
public SAX2DTM(DTMManager mgr, javax.xml.transform.Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing)
Construct a SAX2DTM object using the default block size.- Parameters:
mgr
- The DTMManager who owns this DTM.source
- the JAXP 1.1 Source object for this DTM.dtmIdentity
- The DTM identity ID for this DTM.whiteSpaceFilter
- The white space filter for this DTM, which may be null.xstringfactory
- XMLString factory for creating character content.doIndexing
- true if the caller considers it worth it to use indexing schemes.
-
SAX2DTM
public SAX2DTM(DTMManager mgr, javax.xml.transform.Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing, int blocksize, boolean usePrevsib, boolean newNameTable)
Construct a SAX2DTM object ready to be constructed from SAX2 ContentHandler events.- Parameters:
mgr
- The DTMManager who owns this DTM.source
- the JAXP 1.1 Source object for this DTM.dtmIdentity
- The DTM identity ID for this DTM.whiteSpaceFilter
- The white space filter for this DTM, which may be null.xstringfactory
- XMLString factory for creating character content.doIndexing
- true if the caller considers it worth it to use indexing schemes.blocksize
- The block size of the DTM.usePrevsib
- true if we want to build the previous sibling node array.newNameTable
- true if we want to use a new ExpandedNameTable for this DTM.
-
-
Method Detail
-
setUseSourceLocation
public void setUseSourceLocation(boolean useSourceLocation)
Set whether information about document source location should be maintained or not.
-
clearCoRoutine
public void clearCoRoutine()
Ask the CoRoutine parser to doTerminate and clear the reference.
-
clearCoRoutine
public void clearCoRoutine(boolean callDoTerminate)
Ask the CoRoutine parser to doTerminate and clear the reference. If the CoRoutine parser has already been cleared, this will have no effect.- Parameters:
callDoTerminate
- true of doTerminate should be called on the coRoutine parser.
-
setIncrementalSAXSource
public void setIncrementalSAXSource(IncrementalSAXSource incrementalSAXSource)
Bind a IncrementalSAXSource to this DTM. If we discover we need nodes that have not yet been built, we will ask this object to send us more events, and it will manage interactions with its data sources. Note that we do not actually build the IncrementalSAXSource, since we don't know what source it's reading from, what thread that source will run in, or when it will run.- Parameters:
incrementalSAXSource
- The parser that we want to recieve events from on demand.
-
getContentHandler
public org.xml.sax.ContentHandler getContentHandler()
getContentHandler returns "our SAX builder" -- the thing that someone else should send SAX events to in order to extend this DTM model. %REVIEW% Should this return null if constrution already done/begun?- Specified by:
getContentHandler
in interfaceDTM
- Returns:
- null if this model doesn't respond to SAX events, "this" if the DTM object has a built-in SAX ContentHandler, the IncrementalSAXSource if we're bound to one and should receive the SAX stream via it for incremental build purposes...
-
getLexicalHandler
public org.xml.sax.ext.LexicalHandler getLexicalHandler()
Return this DTM's lexical handler. %REVIEW% Should this return null if constrution already done/begun?- Specified by:
getLexicalHandler
in interfaceDTM
- Returns:
- null if this model doesn't respond to lexical SAX events, "this" if the DTM object has a built-in SAX ContentHandler, the IncrementalSAXSource if we're bound to one and should receive the SAX stream via it for incremental build purposes...
-
getEntityResolver
public org.xml.sax.EntityResolver getEntityResolver()
Return this DTM's EntityResolver.- Specified by:
getEntityResolver
in interfaceDTM
- Returns:
- null if this model doesn't respond to SAX entity ref events.
-
getDTDHandler
public org.xml.sax.DTDHandler getDTDHandler()
Return this DTM's DTDHandler.- Specified by:
getDTDHandler
in interfaceDTM
- Returns:
- null if this model doesn't respond to SAX dtd events.
-
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
Return this DTM's ErrorHandler.- Specified by:
getErrorHandler
in interfaceDTM
- Returns:
- null if this model doesn't respond to SAX error events.
-
getDeclHandler
public org.xml.sax.ext.DeclHandler getDeclHandler()
Return this DTM's DeclHandler.- Specified by:
getDeclHandler
in interfaceDTM
- Returns:
- null if this model doesn't respond to SAX Decl events.
-
needsTwoThreads
public boolean needsTwoThreads()
- Specified by:
needsTwoThreads
in interfaceDTM
- Returns:
- true iff we're building this model incrementally (eg we're partnered with a IncrementalSAXSource) and thus require that the transformation and the parse run simultaneously. Guidance to the DTMManager.
-
dispatchCharactersEvents
public void dispatchCharactersEvents(int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize) throws org.xml.sax.SAXException
Directly call the characters method on the passed ContentHandler for the string-value of the given node (see http://www.w3.org/TR/xpath#data-model for the definition of a node's string-value). Multiple calls to the ContentHandler's characters methods may well occur for a single call to this method.- Specified by:
dispatchCharactersEvents
in interfaceDTM
- Specified by:
dispatchCharactersEvents
in classDTMDefaultBase
- Parameters:
nodeHandle
- The node ID.ch
- A non-null reference to a ContentHandler.normalize
- true if the content should be normalized according to the rules for the XPath normalize-space function.- Throws:
org.xml.sax.SAXException
-
getNodeName
public java.lang.String getNodeName(int nodeHandle)
Given a node handle, return its DOM-style node name. This will include names such as #text or #document.- Specified by:
getNodeName
in interfaceDTM
- Specified by:
getNodeName
in classDTMDefaultBase
- Parameters:
nodeHandle
- the id of the node.- Returns:
- String Name of this node, which may be an empty string. %REVIEW% Document when empty string is possible... %REVIEW-COMMENT% It should never be empty, should it?
-
getNodeNameX
public java.lang.String getNodeNameX(int nodeHandle)
Given a node handle, return the XPath node name. This should be the name as described by the XPath data model, NOT the DOM-style name.- Specified by:
getNodeNameX
in interfaceDTM
- Overrides:
getNodeNameX
in classDTMDefaultBase
- Parameters:
nodeHandle
- the id of the node.- Returns:
- String Name of this node, which may be an empty string.
-
isAttributeSpecified
public boolean isAttributeSpecified(int attributeHandle)
5. [specified] A flag indicating whether this attribute was actually specified in the start-tag of its element, or was defaulted from the DTD.- Specified by:
isAttributeSpecified
in interfaceDTM
- Specified by:
isAttributeSpecified
in classDTMDefaultBase
- Parameters:
attributeHandle
- Must be a valid handle to an attribute node.- Returns:
true
if the attribute was specified;false
if it was defaulted.
-
getDocumentTypeDeclarationSystemIdentifier
public java.lang.String getDocumentTypeDeclarationSystemIdentifier()
A document type declaration information item has the following properties: 1. [system identifier] The system identifier of the external subset, if it exists. Otherwise this property has no value.- Specified by:
getDocumentTypeDeclarationSystemIdentifier
in interfaceDTM
- Specified by:
getDocumentTypeDeclarationSystemIdentifier
in classDTMDefaultBase
- Returns:
- the system identifier String object, or null if there is none.
-
dispatchToEvents
public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch) throws org.xml.sax.SAXException
Directly create SAX parser events from a subtree.- Specified by:
dispatchToEvents
in interfaceDTM
- Specified by:
dispatchToEvents
in classDTMDefaultBase
- Parameters:
nodeHandle
- The node ID.ch
- A non-null reference to a ContentHandler.- Throws:
org.xml.sax.SAXException
-
getNumberOfNodes
public int getNumberOfNodes()
Get the number of nodes that have been added.- Returns:
- The number of that are currently in the tree.
-
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.- Specified by:
migrateTo
in interfaceDTM
- Overrides:
migrateTo
in classDTMDefaultBase
- Parameters:
manager
- the DTMManager
-
getNodeValue
public java.lang.String getNodeValue(int nodeHandle)
Given a node handle, return its node value. This is mostly as defined by the DOM, but may ignore some conveniences.- Specified by:
getNodeValue
in interfaceDTM
- Specified by:
getNodeValue
in classDTMDefaultBase
- Parameters:
nodeHandle
- The node id.- Returns:
- String Value of this node, or null if not meaningful for this node type.
-
getLocalName
public java.lang.String getLocalName(int nodeHandle)
Given a node handle, return its XPath-style localname. (As defined in Namespaces, this is the portion of the name after any colon character).- Specified by:
getLocalName
in interfaceDTM
- Specified by:
getLocalName
in classDTMDefaultBase
- Parameters:
nodeHandle
- the id of the node.- Returns:
- String Local name of this node.
-
getUnparsedEntityURI
public java.lang.String getUnparsedEntityURI(java.lang.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.XML processors may choose to use the System Identifier (if one is provided) to resolve the entity, rather than the URI in the Public Identifier. The details are dependent on the processor, and we would have to support some form of plug-in resolver to handle this properly. Currently, we simply return the System Identifier if present, and hope that it a usable URI or that our caller can map it to one. TODO: Resolve Public Identifiers... or consider changing function name.
If we find a relative URI reference, XML expects it to be resolved in terms of the base URI of the document. The DOM doesn't do that for us, and it isn't entirely clear whether that should be done here; currently that's pushed up to a higher level of our application. (Note that DOM Level 1 didn't store the document's base URI.) TODO: Consider resolving Relative URIs.
(The DOM's statement that "An XML processor may choose to completely expand entities before the structure model is passed to the DOM" refers only to parsed entities, not unparsed, and hence doesn't affect this function.)
- Specified by:
getUnparsedEntityURI
in interfaceDTM
- Specified by:
getUnparsedEntityURI
in classDTMDefaultBase
- Parameters:
name
- A string containing the Entity Name of the unparsed entity.- Returns:
- String containing the URI of the Unparsed Entity, or an empty string if no such entity exists.
-
getPrefix
public java.lang.String getPrefix(int nodeHandle)
Given a namespace handle, return the prefix that the namespace decl is mapping. Given a node handle, return the prefix used to map to the namespace.%REVIEW% Are you sure you want "" for no prefix?
%REVIEW-COMMENT% I think so... not totally sure. -sb
- Specified by:
getPrefix
in interfaceDTM
- Specified by:
getPrefix
in classDTMDefaultBase
- Parameters:
nodeHandle
- the id of the node.- Returns:
- String prefix of this node's name, or "" if no explicit namespace prefix was given.
-
getAttributeNode
public int getAttributeNode(int nodeHandle, java.lang.String namespaceURI, java.lang.String name)
Retrieves an attribute node by by qualified name and namespace URI.- Specified by:
getAttributeNode
in interfaceDTM
- Specified by:
getAttributeNode
in classDTMDefaultBase
- Parameters:
nodeHandle
- int Handle of the node upon which to look up this attribute..namespaceURI
- The namespace URI of the attribute to retrieve, or null.name
- The local name of the attribute to retrieve.- Returns:
- The attribute node handle with the specified name (
nodeName
) orDTM.NULL
if there is no such attribute.
-
getDocumentTypeDeclarationPublicIdentifier
public java.lang.String getDocumentTypeDeclarationPublicIdentifier()
Return the public identifier of the external subset, normalized as described in 4.2.2 External Entities [XML]. If there is no external subset or if it has no public identifier, this property has no value.- Specified by:
getDocumentTypeDeclarationPublicIdentifier
in interfaceDTM
- Specified by:
getDocumentTypeDeclarationPublicIdentifier
in classDTMDefaultBase
- Returns:
- the public identifier String object, or null if there is none.
-
getNamespaceURI
public java.lang.String getNamespaceURI(int nodeHandle)
Given a node handle, return its DOM-style namespace URI (As defined in Namespaces, this is the declared URI which this node's prefix -- or default in lieu thereof -- was mapped to.)%REVIEW% Null or ""? -sb
- Specified by:
getNamespaceURI
in interfaceDTM
- Specified by:
getNamespaceURI
in classDTMDefaultBase
- Parameters:
nodeHandle
- the id of the node.- Returns:
- String URI value of this node's namespace, or null if no namespace was resolved.
-
getStringValue
public XMLString getStringValue(int nodeHandle)
Get the string-value of a node as a String object (see http://www.w3.org/TR/xpath#data-model for the definition of a node's string-value).- Specified by:
getStringValue
in interfaceDTM
- Specified by:
getStringValue
in classDTMDefaultBase
- Parameters:
nodeHandle
- The node ID.- Returns:
- A string object that represents the string-value of the given node.
-
isWhitespace
public boolean isWhitespace(int nodeHandle)
Determine if the string-value of a node is whitespace- Parameters:
nodeHandle
- The node Handle.- Returns:
- Return true if the given node is whitespace.
-
getElementById
public int getElementById(java.lang.String elementId)
Returns theElement
whoseID
is given byelementId
. If no such element exists, returnsDTM.NULL
. Behavior is not defined if more than one element has thisID
. Attributes (including those with the name "ID") are not of type ID unless so defined by DTD/Schema information available to the DTM implementation. Implementations that do not know whether attributes are of type ID or not are expected to returnDTM.NULL
.%REVIEW% Presumably IDs are still scoped to a single document, and this operation searches only within a single document, right? Wouldn't want collisions between DTMs in the same process.
- Specified by:
getElementById
in interfaceDTM
- Specified by:
getElementById
in classDTMDefaultBase
- Parameters:
elementId
- The uniqueid
value for an element.- Returns:
- The handle of the matching element.
-
getPrefix
public java.lang.String getPrefix(java.lang.String qname, java.lang.String uri)
Get a prefix either from the qname or from the uri mapping, or just make one up!- Parameters:
qname
- The qualified name, which may be null.uri
- The namespace URI, which may be null.- Returns:
- The prefix if there is one, or null.
-
getIdForNamespace
public int getIdForNamespace(java.lang.String uri)
Get a prefix either from the uri mapping, or just make one up!- Parameters:
uri
- The namespace URI, which may be null.- Returns:
- The prefix if there is one, or null.
-
getNamespaceURI
public java.lang.String getNamespaceURI(java.lang.String prefix)
Get a prefix either from the qname or from the uri mapping, or just make one up!- Returns:
- The prefix if there is one, or null.
-
setIDAttribute
public void setIDAttribute(java.lang.String id, int elem)
Set an ID string to node association in the ID table.- Parameters:
id
- The ID string.elem
- The associated element handle.
-
resolveEntity
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
Resolve an external entity.Always return null, so that the parser will use the system identifier provided in the XML document. This method implements the SAX default behaviour: application writers can override it in a subclass to do special translations such as catalog lookups or URI redirection.
- Specified by:
resolveEntity
in interfaceorg.xml.sax.EntityResolver
- Parameters:
publicId
- The public identifer, or null if none is available.systemId
- The system identifier provided in the XML document.- Returns:
- The new input source, or null to require the default behaviour.
- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.org.xml.sax.SAXException
- See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)
-
notationDecl
public void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
Receive notification of a notation declaration.By default, do nothing. Application writers may override this method in a subclass if they wish to keep track of the notations declared in a document.
- Specified by:
notationDecl
in interfaceorg.xml.sax.DTDHandler
- Parameters:
name
- The notation name.publicId
- The notation public identifier, or null if not available.systemId
- The notation system identifier.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.org.xml.sax.SAXException
- See Also:
DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)
-
unparsedEntityDecl
public void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName) throws org.xml.sax.SAXException
Receive notification of an unparsed entity declaration.By default, do nothing. Application writers may override this method in a subclass to keep track of the unparsed entities declared in a document.
- Specified by:
unparsedEntityDecl
in interfaceorg.xml.sax.DTDHandler
- Parameters:
name
- The entity name.publicId
- The entity public identifier, or null if not available.systemId
- The entity system identifier.notationName
- The name of the associated notation.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.org.xml.sax.SAXException
- See Also:
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator locator)
Receive a Locator object for document events.By default, do nothing. Application writers may override this method in a subclass if they wish to store the locator for use with other document events.
- Specified by:
setDocumentLocator
in interfaceorg.xml.sax.ContentHandler
- Parameters:
locator
- A locator for all SAX document events.- See Also:
ContentHandler.setDocumentLocator(org.xml.sax.Locator)
,Locator
-
startDocument
public void startDocument() throws org.xml.sax.SAXException
Receive notification of the beginning of the document.- Specified by:
startDocument
in interfaceorg.xml.sax.ContentHandler
- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.startDocument()
-
endDocument
public void endDocument() throws org.xml.sax.SAXException
Receive notification of the end of the document.- Specified by:
endDocument
in interfaceorg.xml.sax.ContentHandler
- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.endDocument()
-
startPrefixMapping
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
Receive notification of the start of a Namespace mapping.By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each Namespace prefix scope (such as storing the prefix mapping).
- Specified by:
startPrefixMapping
in interfaceorg.xml.sax.ContentHandler
- Parameters:
prefix
- The Namespace prefix being declared.uri
- The Namespace URI mapped to the prefix.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)
-
endPrefixMapping
public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException
Receive notification of the end of a Namespace mapping.By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each prefix mapping.
- Specified by:
endPrefixMapping
in interfaceorg.xml.sax.ContentHandler
- Parameters:
prefix
- The Namespace prefix being declared.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.endPrefixMapping(java.lang.String)
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
Receive notification of the start of an element.By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Parameters:
uri
- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.localName
- The local name (without prefix), or the empty string if Namespace processing is not being performed.qName
- The qualified name (with prefix), or the empty string if qualified names are not available.attributes
- The specified or defaulted attributes.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
-
endElement
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
Receive notification of the end of an element.By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).
- Specified by:
endElement
in interfaceorg.xml.sax.ContentHandler
- Parameters:
uri
- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.localName
- The local name (without prefix), or the empty string if Namespace processing is not being performed.qName
- The qualified XML 1.0 name (with prefix), or the empty string if qualified names are not available.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
Receive notification of character data inside an element.By default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).
- Specified by:
characters
in interfaceorg.xml.sax.ContentHandler
- Parameters:
ch
- The characters.start
- The start position in the character array.length
- The number of characters to use from the character array.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.characters(char[], int, int)
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
Receive notification of ignorable whitespace in element content.By default, do nothing. Application writers may override this method to take specific actions for each chunk of ignorable whitespace (such as adding data to a node or buffer, or printing it to a file).
- Specified by:
ignorableWhitespace
in interfaceorg.xml.sax.ContentHandler
- Parameters:
ch
- The whitespace characters.start
- The start position in the character array.length
- The number of characters to use from the character array.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.ignorableWhitespace(char[], int, int)
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
Receive notification of a processing instruction.By default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.
- Specified by:
processingInstruction
in interfaceorg.xml.sax.ContentHandler
- Parameters:
target
- The processing instruction target.data
- The processing instruction data, or null if none is supplied.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.processingInstruction(java.lang.String, java.lang.String)
-
skippedEntity
public void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException
Receive notification of a skipped entity.By default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.
- Specified by:
skippedEntity
in interfaceorg.xml.sax.ContentHandler
- Parameters:
name
- The name of the skipped entity.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.processingInstruction(java.lang.String, java.lang.String)
-
warning
public void warning(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
Receive notification of a parser warning.The default implementation does nothing. Application writers may override this method in a subclass to take specific actions for each warning, such as inserting the message in a log file or printing it to the console.
- Specified by:
warning
in interfaceorg.xml.sax.ErrorHandler
- Parameters:
e
- The warning information encoded as an exception.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ErrorHandler.warning(org.xml.sax.SAXParseException)
,SAXParseException
-
error
public void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
Receive notification of a recoverable parser error.The default implementation does nothing. Application writers may override this method in a subclass to take specific actions for each error, such as inserting the message in a log file or printing it to the console.
- Specified by:
error
in interfaceorg.xml.sax.ErrorHandler
- Parameters:
e
- The warning information encoded as an exception.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ErrorHandler.warning(org.xml.sax.SAXParseException)
,SAXParseException
-
fatalError
public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
Report a fatal XML parsing error.The default implementation throws a SAXParseException. Application writers may override this method in a subclass if they need to take specific actions for each fatal error (such as collecting all of the errors into a single report): in any case, the application must stop all regular processing when this method is invoked, since the document is no longer reliable, and the parser may no longer report parsing events.
- Specified by:
fatalError
in interfaceorg.xml.sax.ErrorHandler
- Parameters:
e
- The error information encoded as an exception.- Throws:
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
ErrorHandler.fatalError(org.xml.sax.SAXParseException)
,SAXParseException
-
elementDecl
public void elementDecl(java.lang.String name, java.lang.String model) throws org.xml.sax.SAXException
Report an element type declaration.The content model will consist of the string "EMPTY", the string "ANY", or a parenthesised group, optionally followed by an occurrence indicator. The model will be normalized so that all whitespace is removed,and will include the enclosing parentheses.
- Specified by:
elementDecl
in interfaceorg.xml.sax.ext.DeclHandler
- Parameters:
name
- The element type name.model
- The content model as a normalized string.- Throws:
org.xml.sax.SAXException
- The application may raise an exception.
-
attributeDecl
public void attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value) throws org.xml.sax.SAXException
Report an attribute type declaration.Only the effective (first) declaration for an attribute will be reported. The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION", or a parenthesized token group with the separator "|" and all whitespace removed.
- Specified by:
attributeDecl
in interfaceorg.xml.sax.ext.DeclHandler
- Parameters:
eName
- The name of the associated element.aName
- The name of the attribute.type
- A string representing the attribute type.valueDefault
- A string representing the attribute default ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.value
- A string representing the attribute's default value, or null if there is none.- Throws:
org.xml.sax.SAXException
- The application may raise an exception.
-
internalEntityDecl
public void internalEntityDecl(java.lang.String name, java.lang.String value) throws org.xml.sax.SAXException
Report an internal entity declaration.Only the effective (first) declaration for each entity will be reported.
- Specified by:
internalEntityDecl
in interfaceorg.xml.sax.ext.DeclHandler
- Parameters:
name
- The name of the entity. If it is a parameter entity, the name will begin with '%'.value
- The replacement text of the entity.- Throws:
org.xml.sax.SAXException
- The application may raise an exception.- See Also:
externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
,DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-
externalEntityDecl
public void externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
Report a parsed external entity declaration.Only the effective (first) declaration for each entity will be reported.
- Specified by:
externalEntityDecl
in interfaceorg.xml.sax.ext.DeclHandler
- Parameters:
name
- The name of the entity. If it is a parameter entity, the name will begin with '%'.publicId
- The declared public identifier of the entity, or null if none was declared.systemId
- The declared system identifier of the entity.- Throws:
org.xml.sax.SAXException
- The application may raise an exception.- See Also:
internalEntityDecl(java.lang.String, java.lang.String)
,DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-
startDTD
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
Report the start of DTD declarations, if any.Any declarations are assumed to be in the internal subset unless otherwise indicated by a
startEntity
event.Note that the start/endDTD events will appear within the start/endDocument events from ContentHandler and before the first startElement event.
- Specified by:
startDTD
in interfaceorg.xml.sax.ext.LexicalHandler
- Parameters:
name
- The document type name.publicId
- The declared public identifier for the external DTD subset, or null if none was declared.systemId
- The declared system identifier for the external DTD subset, or null if none was declared.- Throws:
org.xml.sax.SAXException
- The application may raise an exception.- See Also:
endDTD()
,startEntity(java.lang.String)
-
endDTD
public void endDTD() throws org.xml.sax.SAXException
Report the end of DTD declarations.- Specified by:
endDTD
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
- The application may raise an exception.- See Also:
startDTD(java.lang.String, java.lang.String, java.lang.String)
-
startEntity
public void startEntity(java.lang.String name) throws org.xml.sax.SAXException
Report the beginning of an entity in content.NOTE: entity references in attribute values -- and the start and end of the document entity -- are never reported.
The start and end of the external DTD subset are reported using the pseudo-name "[dtd]". All other events must be properly nested within start/end entity events.
Note that skipped entities will be reported through the
skippedEntity
event, which is part of the ContentHandler interface.- Specified by:
startEntity
in interfaceorg.xml.sax.ext.LexicalHandler
- Parameters:
name
- The name of the entity. If it is a parameter entity, the name will begin with '%'.- Throws:
org.xml.sax.SAXException
- The application may raise an exception.- See Also:
endEntity(java.lang.String)
,DeclHandler.internalEntityDecl(java.lang.String, java.lang.String)
,DeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
-
endEntity
public void endEntity(java.lang.String name) throws org.xml.sax.SAXException
Report the end of an entity.- Specified by:
endEntity
in interfaceorg.xml.sax.ext.LexicalHandler
- Parameters:
name
- The name of the entity that is ending.- Throws:
org.xml.sax.SAXException
- The application may raise an exception.- See Also:
startEntity(java.lang.String)
-
startCDATA
public void startCDATA() throws org.xml.sax.SAXException
Report the start of a CDATA section.The contents of the CDATA section will be reported through the regular
characters
event.- Specified by:
startCDATA
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
- The application may raise an exception.- See Also:
endCDATA()
-
endCDATA
public void endCDATA() throws org.xml.sax.SAXException
Report the end of a CDATA section.- Specified by:
endCDATA
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
- The application may raise an exception.- See Also:
startCDATA()
-
comment
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXException
Report an XML comment anywhere in the document.This callback will be used for comments inside or outside the document element, including comments in the external DTD subset (if read).
- Specified by:
comment
in interfaceorg.xml.sax.ext.LexicalHandler
- Parameters:
ch
- An array holding the characters in the comment.start
- The starting position in the array.length
- The number of characters to use from the array.- Throws:
org.xml.sax.SAXException
- The application may raise an exception.
-
setProperty
public void setProperty(java.lang.String property, java.lang.Object value)
Set a run time property for this DTM instance. %REVIEW% Now that we no longer use this method to support getSourceLocatorFor, can we remove it?- Specified by:
setProperty
in interfaceDTM
- Parameters:
property
- aString
valuevalue
- anObject
value
-
getSourceLocatorFor
public javax.xml.transform.SourceLocator getSourceLocatorFor(int node)
Retrieve the SourceLocator associated with a specific node. This is only meaningful if the XalanProperties.SOURCE_LOCATION flag was set True using setProperty; if it was never set, or was set false, we will return null. (We _could_ return a locator with the document's base URI and bogus line/column information. Trying that; see the else clause.)- Specified by:
getSourceLocatorFor
in interfaceDTM
- Parameters:
node
- anint
value- Returns:
- a
SourceLocator
value or null if no location is available
-
getFixedNames
public java.lang.String getFixedNames(int type)
-
-