|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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
This class implements a DTM that tends to be optimized more for speed than for compactness, that is constructed via SAX2 ContentHandler events.
Fields inherited from class org.apache.xml.dtm.ref.DTMDefaultBase |
DEFAULT_BLOCKSIZE,
DEFAULT_NUMBLOCKS,
DEFAULT_NUMBLOCKS_SMALL,
m_mgr,
ROOTNODE |
Constructor Summary | |
SAX2DTM(DTMManager mgr,
Source source,
int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing)
Construct a SAX2DTM object using the default block size. |
|
SAX2DTM(DTMManager mgr,
Source source,
int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing,
int blocksize,
boolean usePrevsib)
Construct a SAX2DTM object ready to be constructed from SAX2 ContentHandler events. |
Method Summary | |
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,
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. |
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(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(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. |
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 |
getIdForNamespace(java.lang.String uri)
Get a prefix either from the uri mapping, or just make one up! |
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! |
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 whitespace |
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. |
InputSource |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
Resolve an external entity. |
void |
setDocumentLocator(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. |
static 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,
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(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 java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public SAX2DTM(DTMManager mgr, Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing)
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.public SAX2DTM(DTMManager mgr, Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing, int blocksize, boolean usePrevsib)
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.Method Detail |
public static void setUseSourceLocation(boolean useSourceLocation)
public void clearCoRoutine()
public void clearCoRoutine(boolean callDoTerminate)
callDoTerminate
- true of doTerminate should be called on the
coRoutine parser.public void setIncrementalSAXSource(IncrementalSAXSource incrementalSAXSource)
incrementalSAXSource
- The parser that we want to recieve events from
on demand.appCoRID
- The CoRoutine ID for the application.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
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.public java.lang.String getNodeName(int nodeHandle)
nodeHandle
- the id of the node.public java.lang.String getNodeNameX(int nodeHandle)
nodeHandle
- the id of the node.public boolean isAttributeSpecified(int attributeHandle)
the
- attribute handleattributeHandle
- Must be a valid handle to an attribute node.true
if the attribute was specified;
false
if it was defaulted.public java.lang.String getDocumentTypeDeclarationSystemIdentifier()
public void dispatchToEvents(int nodeHandle, ContentHandler ch) throws SAXException
nodeHandle
- The node ID.ch
- A non-null reference to a ContentHandler.public int getNumberOfNodes()
public java.lang.String getNodeValue(int nodeHandle)
nodeHandle
- The node id.public java.lang.String getLocalName(int nodeHandle)
nodeHandle
- the id of the node.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.)
name
- A string containing the Entity Name of the unparsed
entity.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
nodeHandle
- the id of the node.public int getAttributeNode(int nodeHandle, java.lang.String namespaceURI, java.lang.String name)
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.nodeName
) or DTM.NULL
if there is no such
attribute.public java.lang.String getDocumentTypeDeclarationPublicIdentifier()
the
- document type declaration handlepublic java.lang.String getNamespaceURI(int nodeHandle)
%REVIEW% Null or ""? -sb
nodeHandle
- the id of the node.public XMLString getStringValue(int nodeHandle)
nodeHandle
- The node ID.public boolean isWhitespace(int nodeHandle)
nodeHandle
- The node Handle.public 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.
elementId
- The unique id
value for an element.public java.lang.String getPrefix(java.lang.String qname, java.lang.String uri)
qname
- The qualified name, which may be null.uri
- The namespace URI, which may be null.public int getIdForNamespace(java.lang.String uri)
uri
- The namespace URI, which may be null.public java.lang.String getNamespaceURI(java.lang.String prefix)
qname
- The qualified name, which may be null.uri
- The namespace URI, which may be null.public void setIDAttribute(java.lang.String id, int elem)
id
- The ID string.elem
- The associated element handle.public InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws SAXException
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.
publicId
- The public identifer, or null if none is
available.systemId
- The system identifier provided in the XML
document.EntityResolver.resolveEntity(java.lang.String, java.lang.String)
public void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws SAXException
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.
name
- The notation name.publicId
- The notation public identifier, or null if not
available.systemId
- The notation system identifier.DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)
public void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName) throws SAXException
By default, do nothing. Application writers may override this method in a subclass to keep track of the unparsed entities declared in a document.
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.DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void setDocumentLocator(Locator locator)
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.
locator
- A locator for all SAX document events.ContentHandler.setDocumentLocator(org.xml.sax.Locator)
,
Locator
public void startDocument() throws SAXException
ContentHandler.startDocument()
public void endDocument() throws SAXException
ContentHandler.endDocument()
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws SAXException
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).
prefix
- The Namespace prefix being declared.uri
- The Namespace URI mapped to the prefix.ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)
public void endPrefixMapping(java.lang.String prefix) throws SAXException
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each prefix mapping.
prefix
- The Namespace prefix being declared.ContentHandler.endPrefixMapping(java.lang.String)
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, Attributes attributes) throws SAXException
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).
name
- The element type name.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.ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws SAXException
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).
name
- The element type name.attributes
- The specified or defaulted attributes.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.ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
public void characters(char[] ch, int start, int length) throws SAXException
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).
ch
- The characters.start
- The start position in the character array.length
- The number of characters to use from the
character array.ContentHandler.characters(char[], int, int)
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
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).
ch
- The whitespace characters.start
- The start position in the character array.length
- The number of characters to use from the
character array.ContentHandler.ignorableWhitespace(char[], int, int)
public void processingInstruction(java.lang.String target, java.lang.String data) throws SAXException
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.
target
- The processing instruction target.data
- The processing instruction data, or null if
none is supplied.ContentHandler.processingInstruction(java.lang.String, java.lang.String)
public void skippedEntity(java.lang.String name) throws SAXException
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.
name
- The name of the skipped entity.ContentHandler.processingInstruction(java.lang.String, java.lang.String)
public void warning(SAXParseException e) throws SAXException
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.
e
- The warning information encoded as an exception.ErrorHandler.warning(org.xml.sax.SAXParseException)
,
SAXParseException
public void error(SAXParseException e) throws SAXException
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.
e
- The warning information encoded as an exception.ErrorHandler.warning(org.xml.sax.SAXParseException)
,
SAXParseException
public void fatalError(SAXParseException e) throws SAXException
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.
e
- The error information encoded as an exception.ErrorHandler.fatalError(org.xml.sax.SAXParseException)
,
SAXParseException
public void elementDecl(java.lang.String name, java.lang.String model) throws SAXException
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.
name
- The element type name.model
- The content model as a normalized string.public void attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value) throws SAXException
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.
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.public void internalEntityDecl(java.lang.String name, java.lang.String value) throws SAXException
Only the effective (first) declaration for each entity will be reported.
name
- The name of the entity. If it is a parameter
entity, the name will begin with '%'.value
- The replacement text of the entity.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
,
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws SAXException
Only the effective (first) declaration for each entity will be reported.
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.internalEntityDecl(java.lang.String, java.lang.String)
,
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws SAXException
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.
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.endDTD()
,
startEntity(java.lang.String)
public void endDTD() throws SAXException
startDTD(java.lang.String, java.lang.String, java.lang.String)
public void startEntity(java.lang.String name) throws SAXException
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.
name
- The name of the entity. If it is a parameter
entity, the name will begin with '%'.endEntity(java.lang.String)
,
DeclHandler.internalEntityDecl(java.lang.String, java.lang.String)
,
DeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
public void endEntity(java.lang.String name) throws SAXException
name
- The name of the entity that is ending.startEntity(java.lang.String)
public void startCDATA() throws SAXException
The contents of the CDATA section will be reported through the regular characters event.
endCDATA()
public void endCDATA() throws SAXException
startCDATA()
public void comment(char[] ch, int start, int length) throws SAXException
This callback will be used for comments inside or outside the document element, including comments in the external DTD subset (if read).
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.public void setProperty(java.lang.String property, java.lang.Object value)
property
- a String
valuevalue
- an Object
valuepublic SourceLocator getSourceLocatorFor(int node)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |