Java Doc for DOM2DTM.java in  » XML » xalan » org » apache » xml » dtm » ref » dom2dtm » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » xalan » org.apache.xml.dtm.ref.dom2dtm 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.xml.dtm.ref.DTMDefaultBaseIterators
   org.apache.xml.dtm.ref.dom2dtm.DOM2DTM

DOM2DTM
public class DOM2DTM extends DTMDefaultBaseIterators (Code)
The 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.

Inner Class :public interface CharacterNodeHandler

Field Summary
final static  booleanJJK_DEBUG
    
final static  booleanJJK_NEWCODE
    
final static  StringNAMESPACE_DECL_NS
    
protected  Vectorm_nodes
     The node objects.
 booleanm_processedFirstElement
     True iff the first element has been processed.
 TreeWalkerm_walker
    

Constructor Summary
public  DOM2DTM(DTMManager mgr, DOMSource domSource, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing)
     Construct a DOM2DTM object from a DOM node.

Method Summary
protected  intaddNode(Node node, int parentIndex, int previousSibling, int forceNodeType)
     Construct the node map from the node.
Parameters:
  node - The node that is to be added to the DTM.
Parameters:
  parentIndex - The current parent index.
Parameters:
  previousSibling - The previous sibling index.
Parameters:
  forceNodeType - If not DTM.NULL, overrides the DOM node type.Used to force nodes to Text rather than CDATASection when theircoalesced value includes ordinary Text nodes (current DTM behavior).
public  voiddispatchCharactersEvents(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).
protected static  voiddispatchNodeData(Node node, org.xml.sax.ContentHandler ch, int depth)
     Retrieve the text content of a DOM subtree, appending it into a user-supplied FastStringBuffer object.
public  voiddispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
     Directly create SAX parser events from a subtree.
public  intgetAttributeNode(int nodeHandle, String namespaceURI, String name)
     Retrieves an attribute node by by qualified name and namespace URI.
Parameters:
  nodeHandle - int Handle of the node upon which to look up this attribute..
Parameters:
  namespaceURI - The namespace URI of the attribute toretrieve, or null.
Parameters:
  name - The local name of the attribute toretrieve.
public  org.xml.sax.ContentHandlergetContentHandler()
     getContentHandler returns "our SAX builder" -- the thing that someone else should send SAX events to in order to extend this DTM model.
public  org.xml.sax.DTDHandlergetDTDHandler()
     Return this DTM's DTDHandler.
public  org.xml.sax.ext.DeclHandlergetDeclHandler()
     Return this DTM's DeclHandler.
public  StringgetDocumentTypeDeclarationPublicIdentifier()
     Return the public identifier of the external subset, normalized as described in 4.2.2 External Entities [XML].
public  StringgetDocumentTypeDeclarationSystemIdentifier()
     A document type declaration information item has the following properties: 1.
public  intgetElementById(String elementId)
     Returns the Element whose ID is given by elementId.
public  org.xml.sax.EntityResolvergetEntityResolver()
     Return this DTM's EntityResolver.
public  org.xml.sax.ErrorHandlergetErrorHandler()
     Return this DTM's ErrorHandler.
public  intgetHandleOfNode(Node node)
     Get the handle from a Node.
public  org.xml.sax.ext.LexicalHandlergetLexicalHandler()
     Return this DTM's lexical handler.
public  StringgetLocalName(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).
Parameters:
  nodeHandle - the id of the node.
public  StringgetNamespaceURI(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


Parameters:
  nodeHandle - the id of the node.
protected  intgetNextNodeIdentity(int identity)
     Get the next node identity value in the list, and call the iterator if it hasn't been added yet.
Parameters:
  identity - The node identity (index).
public  NodegetNode(int nodeHandle)
     Return an DOM node for the given node.
Parameters:
  nodeHandle - The node ID.
protected static  voidgetNodeData(Node node, FastStringBuffer buf)
     Retrieve the text content of a DOM subtree, appending it into a user-supplied FastStringBuffer object.
public  StringgetNodeName(int nodeHandle)
     Given a node handle, return its DOM-style node name.
public  StringgetNodeNameX(int nodeHandle)
     Given a node handle, return the XPath node name.
public  StringgetNodeValue(int nodeHandle)
     Given a node handle, return its node value.
public  intgetNumberOfNodes()
     Get the number of nodes that have been added.
public  StringgetPrefix(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...

public  SourceLocatorgetSourceLocatorFor(int node)
     No source information is available for DOM2DTM, so return null here.
public  XMLStringgetStringValue(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).
Parameters:
  nodeHandle - The node ID.
public  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]).
public  booleanisAttributeSpecified(int attributeHandle)
     5.
public  booleanisWhitespace(int nodeHandle)
     Determine if the string-value of a node is whitespace
Parameters:
  nodeHandle - The node Handle.
protected  NodelookupNode(int nodeIdentity)
     Get a Node from an identity index.
public  booleanneedsTwoThreads()
     true iff we're building this model incrementally (egwe're partnered with a IncrementalSAXSource) and thus require that thetransformation and the parse run simultaneously.
protected  booleannextNode()
     This method iterates to the next node that will be added to the table.
public  voidsetIncrementalSAXSource(IncrementalSAXSource source)
     Bind an IncrementalSAXSource to this DTM.
public  voidsetProperty(String property, Object value)
     For the moment all the run time properties are ignored by this class.

Field Detail
JJK_DEBUG
final static boolean JJK_DEBUG(Code)



JJK_NEWCODE
final static boolean JJK_NEWCODE(Code)



NAMESPACE_DECL_NS
final static String NAMESPACE_DECL_NS(Code)
Manefest constant



m_nodes
protected Vector m_nodes(Code)
The node objects. The instance part of the handle indexes directly into this vector. Each DTM node may actually be composed of several DOM nodes (for example, if logically-adjacent Text/CDATASection nodes in the DOM have been coalesced into a single DTM Text node); this table points only to the first in that sequence.



m_processedFirstElement
boolean m_processedFirstElement(Code)
True iff the first element has been processed. This is used to control synthesis of the implied xml: namespace declaration node.



m_walker
TreeWalker m_walker(Code)




Constructor Detail
DOM2DTM
public DOM2DTM(DTMManager mgr, DOMSource domSource, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing)(Code)
Construct a DOM2DTM object from a DOM node.
Parameters:
  mgr - The DTMManager who owns this DTM.
Parameters:
  domSource - the DOM source that this DTM will wrap.
Parameters:
  dtmIdentity - The DTM identity ID for this DTM.
Parameters:
  whiteSpaceFilter - The white space filter for this DTM, which may be null.
Parameters:
  xstringfactory - XMLString factory for creating character content.
Parameters:
  doIndexing - true if the caller considers it worth it to use indexing schemes.




Method Detail
addNode
protected int addNode(Node node, int parentIndex, int previousSibling, int forceNodeType)(Code)
Construct the node map from the node.
Parameters:
  node - The node that is to be added to the DTM.
Parameters:
  parentIndex - The current parent index.
Parameters:
  previousSibling - The previous sibling index.
Parameters:
  forceNodeType - If not DTM.NULL, overrides the DOM node type.Used to force nodes to Text rather than CDATASection when theircoalesced value includes ordinary Text nodes (current DTM behavior). The index identity of the node that was added.



dispatchCharactersEvents
public void dispatchCharactersEvents(int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize) throws org.xml.sax.SAXException(Code)
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.
Parameters:
  nodeHandle - The node ID.
Parameters:
  ch - A non-null reference to a ContentHandler.
throws:
  org.xml.sax.SAXException -



dispatchNodeData
protected static void dispatchNodeData(Node node, org.xml.sax.ContentHandler ch, int depth) throws org.xml.sax.SAXException(Code)
Retrieve the text content of a DOM subtree, appending it into a user-supplied FastStringBuffer object. Note that attributes are not considered part of the content of an element.

There are open questions regarding whitespace stripping. Currently we make no special effort in that regard, since the standard DOM doesn't yet provide DTD-based information to distinguish whitespace-in-element-context from genuine #PCDATA. Note that we should probably also consider xml:space if/when we address this. DOM Level 3 may solve the problem for us.

%REVIEW% Note that as a DOM-level operation, it can be argued that this routine _shouldn't_ perform any processing beyond what the DOM already does, and that whitespace stripping and so on belong at the DTM level. If you want a stripped DOM view, wrap DTM2DOM around DOM2DTM.
Parameters:
  node - Node whose subtree is to be walked, gathering thecontents of all Text or CDATASection nodes.




dispatchToEvents
public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch) throws org.xml.sax.SAXException(Code)
Directly create SAX parser events from a subtree.
Parameters:
  nodeHandle - The node ID.
Parameters:
  ch - A non-null reference to a ContentHandler.
throws:
  org.xml.sax.SAXException -



getAttributeNode
public int getAttributeNode(int nodeHandle, String namespaceURI, String name)(Code)
Retrieves an attribute node by by qualified name and namespace URI.
Parameters:
  nodeHandle - int Handle of the node upon which to look up this attribute..
Parameters:
  namespaceURI - The namespace URI of the attribute toretrieve, or null.
Parameters:
  name - The local name of the attribute toretrieve. The attribute node handle with the specified name (nodeName) or DTM.NULL if there is no suchattribute.



getContentHandler
public org.xml.sax.ContentHandler getContentHandler()(Code)
getContentHandler returns "our SAX builder" -- the thing that someone else should send SAX events to in order to extend this DTM model. null if this model doesn't respond to SAX events,"this" if the DTM object has a built-in SAX ContentHandler,the IncrmentalSAXSource if we're bound to one and should receivethe SAX stream via it for incremental build purposes...



getDTDHandler
public org.xml.sax.DTDHandler getDTDHandler()(Code)
Return this DTM's DTDHandler. null if this model doesn't respond to SAX dtd events.



getDeclHandler
public org.xml.sax.ext.DeclHandler getDeclHandler()(Code)
Return this DTM's DeclHandler. null if this model doesn't respond to SAX Decl events.



getDocumentTypeDeclarationPublicIdentifier
public String getDocumentTypeDeclarationPublicIdentifier()(Code)
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. the public identifier String object, or null if there is none.



getDocumentTypeDeclarationSystemIdentifier
public String getDocumentTypeDeclarationSystemIdentifier()(Code)
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. the system identifier String object, or null if there is none.



getElementById
public int getElementById(String elementId)(Code)
Returns the 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.


Parameters:
  elementId - The unique id value for an element. The handle of the matching element.



getEntityResolver
public org.xml.sax.EntityResolver getEntityResolver()(Code)
Return this DTM's EntityResolver. null if this model doesn't respond to SAX entity ref events.



getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()(Code)
Return this DTM's ErrorHandler. null if this model doesn't respond to SAX error events.



getHandleOfNode
public int getHandleOfNode(Node node)(Code)
Get the handle from a Node. This is a more robust version of getHandleFromNode, intended to be usable by the public.

%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.
Parameters:
  node - A node, which may be null. The node handle or DTM.NULL.



getLexicalHandler
public org.xml.sax.ext.LexicalHandler getLexicalHandler()(Code)
Return this DTM's lexical handler. %REVIEW% Should this return null if constrution already done/begun? 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 receivethe SAX stream via it for incremental build purposes...



getLocalName
public String getLocalName(int nodeHandle)(Code)
Given a node handle, return its XPath-style localname. (As defined in Namespaces, this is the portion of the name after any colon character).
Parameters:
  nodeHandle - the id of the node. String Local name of this node.



getNamespaceURI
public String getNamespaceURI(int nodeHandle)(Code)
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


Parameters:
  nodeHandle - the id of the node. String URI value of this node's namespace, or null if nonamespace was resolved.



getNextNodeIdentity
protected int getNextNodeIdentity(int identity)(Code)
Get the next node identity value in the list, and call the iterator if it hasn't been added yet.
Parameters:
  identity - The node identity (index). identity+1, or DTM.NULL.



getNode
public Node getNode(int nodeHandle)(Code)
Return an DOM node for the given node.
Parameters:
  nodeHandle - The node ID. A node representation of the DTM node.



getNodeData
protected static void getNodeData(Node node, FastStringBuffer buf)(Code)
Retrieve the text content of a DOM subtree, appending it into a user-supplied FastStringBuffer object. Note that attributes are not considered part of the content of an element.

There are open questions regarding whitespace stripping. Currently we make no special effort in that regard, since the standard DOM doesn't yet provide DTD-based information to distinguish whitespace-in-element-context from genuine #PCDATA. Note that we should probably also consider xml:space if/when we address this. DOM Level 3 may solve the problem for us.

%REVIEW% Actually, since this method operates on the DOM side of the fence rather than the DTM side, it SHOULDN'T do any special handling. The DOM does what the DOM does; if you want DTM-level abstractions, use DTM-level methods.
Parameters:
  node - Node whose subtree is to be walked, gathering thecontents of all Text or CDATASection nodes.
Parameters:
  buf - FastStringBuffer into which the contents of the textnodes are to be concatenated.




getNodeName
public String getNodeName(int nodeHandle)(Code)
Given a node handle, return its DOM-style node name. This will include names such as #text or #document.
Parameters:
  nodeHandle - the id of the node. 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 String getNodeNameX(int nodeHandle)(Code)
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.
Parameters:
  nodeHandle - the id of the node. String Name of this node, which may be an empty string.



getNodeValue
public String getNodeValue(int nodeHandle)(Code)
Given a node handle, return its node value. This is mostly as defined by the DOM, but may ignore some conveniences.


Parameters:
  nodeHandle - The node id. String Value of this node, or null if notmeaningful for this node type.




getNumberOfNodes
public int getNumberOfNodes()(Code)
Get the number of nodes that have been added.



getPrefix
public String getPrefix(int nodeHandle)(Code)
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


Parameters:
  nodeHandle - the id of the node. String prefix of this node's name, or "" if no explicitnamespace prefix was given.



getSourceLocatorFor
public SourceLocator getSourceLocatorFor(int node)(Code)
No source information is available for DOM2DTM, so return null here.
Parameters:
  node - an int value null



getStringValue
public XMLString getStringValue(int nodeHandle)(Code)
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).
Parameters:
  nodeHandle - The node ID. A string object that represents the string-value of the given node.



getUnparsedEntityURI
public String getUnparsedEntityURI(String name)(Code)
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.)
Parameters:
  name - A string containing the Entity Name of the unparsedentity. String containing the URI of the Unparsed Entity, or anempty string if no such entity exists.




isAttributeSpecified
public boolean isAttributeSpecified(int attributeHandle)(Code)
5. [specified] A flag indicating whether this attribute was actually specified in the start-tag of its element, or was defaulted from the DTD.
Parameters:
  attributeHandle - the attribute handle true if the attribute was specified;false if it was defaulted.



isWhitespace
public boolean isWhitespace(int nodeHandle)(Code)
Determine if the string-value of a node is whitespace
Parameters:
  nodeHandle - The node Handle. Return true if the given node is whitespace.



lookupNode
protected Node lookupNode(int nodeIdentity)(Code)
Get a Node from an identity index. NEEDSDOC @param nodeIdentity NEEDSDOC ($objectName$) @return



needsTwoThreads
public boolean needsTwoThreads()(Code)
true iff we're building this model incrementally (egwe're partnered with a IncrementalSAXSource) and thus require that thetransformation and the parse run simultaneously. Guidance to theDTMManager.



nextNode
protected boolean nextNode()(Code)
This method iterates to the next node that will be added to the table. Each call to this method adds a new node to the table, unless the end is reached, in which case it returns null. The true if a next node is found or false if there are no more nodes.



setIncrementalSAXSource
public void setIncrementalSAXSource(IncrementalSAXSource source)(Code)
Bind an IncrementalSAXSource to this DTM. NOT RELEVANT for DOM2DTM, since we're wrapped around an existing DOM.
Parameters:
  source - The IncrementalSAXSource that we want to recieve events fromon demand.



setProperty
public void setProperty(String property, Object value)(Code)
For the moment all the run time properties are ignored by this class.
Parameters:
  property - a String value
Parameters:
  value - an Object value



Methods inherited from org.apache.xml.dtm.ref.DTMDefaultBaseIterators
public DTMAxisIterator getAxisIterator(int axis)(Code)(Java Doc)
public DTMAxisIterator getTypedAxisIterator(int axis, int type)(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.