public class DOM2DTM extends DTMDefaultBaseIterators
DOM2DTM class serves up a DOM's contents via the
DTM API.
Note that it doesn't necessarily represent a full Document
tree. You can wrap a DOM2DTM around a specific node and its subtree
and the right things should happen. (I don't _think_ we currently
support DocumentFrgment nodes as roots, though that might be worth
considering.)
Note too that we do not currently attempt to track document
mutation. If you alter the DOM after wrapping DOM2DTM around it,
all bets are off.| Modifier and Type | Class and Description |
|---|---|
static interface |
DOM2DTM.CharacterNodeHandler |
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.TypedSingletonIteratorDEFAULT_BLOCKSIZE, DEFAULT_NUMBLOCKS, DEFAULT_NUMBLOCKS_SMALL, m_mgr, ROOTNODEATTRIBUTE_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 and Description |
|---|
DOM2DTM(DTMManager mgr,
DOMSource domSource,
int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing)
Construct a DOM2DTM object from a DOM node.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispatchCharactersEvents(int nodeHandle,
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,
ContentHandler ch)
Directly create SAX parser events from a subtree.
|
int |
getAttributeNode(int nodeHandle,
java.lang.String namespaceURI,
java.lang.String name)
Retrieves an attribute node by by qualified name and namespace URI.
|
ContentHandler |
getContentHandler()
getContentHandler returns "our SAX builder" -- the thing that
someone else should send SAX events to in order to extend this
DTM model.
|
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.
|
DTDHandler |
getDTDHandler()
Return this DTM's DTDHandler.
|
int |
getElementById(java.lang.String elementId)
Returns the
Element whose ID is given by
elementId. |
EntityResolver |
getEntityResolver()
Return this DTM's EntityResolver.
|
ErrorHandler |
getErrorHandler()
Return this DTM's ErrorHandler.
|
int |
getHandleOfNode(Node node)
Get the handle from a Node.
|
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.)
|
Node |
getNode(int nodeHandle)
Return an DOM node for the given node.
|
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.
|
SourceLocator |
getSourceLocatorFor(int node)
No source information is available for DOM2DTM, so return
null here. |
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]).
|
boolean |
isAttributeSpecified(int attributeHandle)
5.
|
boolean |
isWhitespace(int nodeHandle)
Determine if the string-value of a node is whitespace
|
boolean |
needsTwoThreads() |
void |
setIncrementalSAXSource(IncrementalSAXSource source)
Bind an IncrementalSAXSource to this DTM.
|
void |
setProperty(java.lang.String property,
java.lang.Object value)
For the moment all the run time properties are ignored by this
class.
|
getAxisIterator, getTypedAxisIteratorgetAxisTraverserappendChild, 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, getNodeHandle, getNodeIdent, getNodeType, getOwnerDocument, getParent, getPreviousSibling, getStringValueChunk, getStringValueChunkCount, getTypedFirstChild, getTypedNextSibling, hasChildNodes, isCharacterElementContentWhitespace, isDocumentAllDeclarationsProcessed, isNodeAfter, isSupported, makeNodeHandle, makeNodeIdentity, migrateTo, setDocumentBaseURI, setFeature, supportsPreStrippingpublic DOM2DTM(DTMManager mgr, DOMSource domSource, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing)
mgr - The DTMManager who owns this DTM.domSource - the DOM source that this DTM will wrap.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.public int getNumberOfNodes()
public Node getNode(int nodeHandle)
getNode in interface DTMgetNode in class DTMDefaultBasenodeHandle - The node ID.public int getHandleOfNode(Node node)
%OPT% This will be pretty slow.
%REVIEW% This relies on being able to test node-identity via object-identity. DTM2DOM proxying is a great example of a case where that doesn't work. DOM Level 3 will provide the isSameNode() method to fix that, but until then this is going to be flaky.node - A node, which may be null.DTM.NULL.public int getAttributeNode(int nodeHandle,
java.lang.String namespaceURI,
java.lang.String name)
getAttributeNode in interface DTMgetAttributeNode in class DTMDefaultBasenodeHandle - 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.nodeName) or DTM.NULL if there is no such
attribute.public XMLString getStringValue(int nodeHandle)
getStringValue in interface DTMgetStringValue in class DTMDefaultBasenodeHandle - The node ID.public boolean isWhitespace(int nodeHandle)
nodeHandle - The node Handle.public java.lang.String getNodeName(int nodeHandle)
getNodeName in interface DTMgetNodeName in class DTMDefaultBasenodeHandle - the id of the node.public java.lang.String getNodeNameX(int nodeHandle)
getNodeNameX in interface DTMgetNodeNameX in class DTMDefaultBasenodeHandle - the id of the node.public java.lang.String getLocalName(int nodeHandle)
getLocalName in interface DTMgetLocalName in class DTMDefaultBasenodeHandle - the id of the node.public java.lang.String getPrefix(int nodeHandle)
%REVIEW% Are you sure you want "" for no prefix?
%REVIEW-COMMENT% I think so... not totally sure. -sb
getPrefix in interface DTMgetPrefix in class DTMDefaultBasenodeHandle - the id of the node.public java.lang.String getNamespaceURI(int nodeHandle)
%REVIEW% Null or ""? -sb
getNamespaceURI in interface DTMgetNamespaceURI in class DTMDefaultBasenodeHandle - the id of the node.public java.lang.String getNodeValue(int nodeHandle)
getNodeValue in interface DTMgetNodeValue in class DTMDefaultBasenodeHandle - The node id.public java.lang.String getDocumentTypeDeclarationSystemIdentifier()
getDocumentTypeDeclarationSystemIdentifier in interface DTMgetDocumentTypeDeclarationSystemIdentifier in class DTMDefaultBasepublic java.lang.String getDocumentTypeDeclarationPublicIdentifier()
getDocumentTypeDeclarationPublicIdentifier in interface DTMgetDocumentTypeDeclarationPublicIdentifier in class DTMDefaultBasepublic int getElementById(java.lang.String elementId)
Element whose ID is given by
elementId. If no such element exists, returns
DTM.NULL. Behavior is not defined if more than one element
has this ID. 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 return DTM.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.
getElementById in interface DTMgetElementById in class DTMDefaultBaseelementId - The unique id value for an element.public java.lang.String getUnparsedEntityURI(java.lang.String name)
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.)
getUnparsedEntityURI in interface DTMgetUnparsedEntityURI in class DTMDefaultBasename - A string containing the Entity Name of the unparsed
entity.public boolean isAttributeSpecified(int attributeHandle)
isAttributeSpecified in interface DTMisAttributeSpecified in class DTMDefaultBaseattributeHandle - the attribute handletrue if the attribute was specified;
false if it was defaulted.public void setIncrementalSAXSource(IncrementalSAXSource source)
source - The IncrementalSAXSource that we want to recieve events from
on demand.public ContentHandler getContentHandler()
public LexicalHandler getLexicalHandler()
public EntityResolver getEntityResolver()
public DTDHandler getDTDHandler()
public ErrorHandler getErrorHandler()
public DeclHandler getDeclHandler()
public boolean needsTwoThreads()
public void dispatchCharactersEvents(int nodeHandle,
ContentHandler ch,
boolean normalize)
throws SAXException
dispatchCharactersEvents in interface DTMdispatchCharactersEvents in class DTMDefaultBasenodeHandle - 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.SAXExceptionpublic void dispatchToEvents(int nodeHandle,
ContentHandler ch)
throws SAXException
dispatchToEvents in interface DTMdispatchToEvents in class DTMDefaultBasenodeHandle - The node ID.ch - A non-null reference to a ContentHandler.SAXExceptionpublic void setProperty(java.lang.String property,
java.lang.Object value)
property - a String valuevalue - an Object valuepublic SourceLocator getSourceLocatorFor(int node)
null here.node - an int valueCopyright © 2014 Apache XML Project. All Rights Reserved.