mkwan 2003/02/19 10:15:51
Modified: java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
SAXImpl.java
java/src/org/apache/xml/dtm/ref/sax2dtm Tag: XSLTC_DTM
SAX2DTM2.java
Log:
XSLTC_DTM performance work
Override _exptype() and dispatchCharactersEvents() in SAX2DTM2.
The new dispatchCharactersEvents(int, ContentHandler) interface is slightly
different from the one in SAX2DTM in that it does not have the boolean
parameter.
Revision Changes Path
No revision
No revision
1.1.2.31 +2 -2 xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java
Index: SAXImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java,v
retrieving revision 1.1.2.30
retrieving revision 1.1.2.31
diff -u -r1.1.2.30 -r1.1.2.31
--- SAXImpl.java 18 Feb 2003 20:30:39 -0000 1.1.2.30
+++ SAXImpl.java 19 Feb 2003 18:15:46 -0000 1.1.2.31
@@ -1721,7 +1721,7 @@
if (node != DTM.NULL) {
_ch2toh.setTOH(handler);
try {
- dispatchCharactersEvents(node, _ch2toh, false);
+ dispatchCharactersEvents(node, _ch2toh);
} catch (SAXException e) {
throw new TransletException(e);
}
No revision
No revision
1.1.2.15 +100 -0
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM2.java
Index: SAX2DTM2.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM2.java,v
retrieving revision 1.1.2.14
retrieving revision 1.1.2.15
diff -u -r1.1.2.14 -r1.1.2.15
--- SAX2DTM2.java 18 Feb 2003 19:08:48 -0000 1.1.2.14
+++ SAX2DTM2.java 19 Feb 2003 18:15:50 -0000 1.1.2.15
@@ -1779,6 +1779,17 @@
}
/**
+ * Override DTMDefaultBase._exptype().
+ * This one is less efficient than _exptype2. It is only used during
+ * DOM building. _exptype2 is used in the case when the document
+ * is fully built.
+ */
+ public final int _exptype(int identity)
+ {
+ return m_exptype.elementAt(identity);
+ }
+
+ /**
* The optimized version of DTMDefaultBase._exptype().
*/
public final int _exptype2(int identity)
@@ -2682,6 +2693,95 @@
dataIndex = m_data.elementAt(dataIndex + 1);
}
return m_valuesOrPrefixes.indexToString(dataIndex);
+ }
+ }
+
+ /**
+ * The optimized version of SAX2DTM.dispatchCharactersEvents(int, ContentHandler,
boolean).
+ * This one does not have the third boolean parameter.
+ *
+ * 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.
+ *
+ * @param nodeHandle The node ID.
+ * @param ch A non-null reference to a ContentHandler.
+ * @param normalize true if the content should be normalized according to
+ * the rules for the XPath
+ * <a
href="http://www.w3.org/TR/xpath#function-normalize-space">normalize-space</a>
+ * function.
+ *
+ * @throws SAXException
+ */
+ public final void dispatchCharactersEvents(int nodeHandle, ContentHandler ch)
+ throws SAXException
+ {
+
+ int identity = makeNodeIdentity(nodeHandle);
+
+ if (identity == DTM.NULL)
+ return;
+
+ int type = _type2(identity);
+
+ if (type == DTM.ELEMENT_NODE || type == DTM.DOCUMENT_NODE)
+ {
+ int firstChild = _firstch2(identity);
+ if (DTM.NULL != firstChild)
+ {
+ int offset = -1;
+ int length = 0;
+ int startNode = identity;
+
+ identity = firstChild;
+
+ do
+ {
+ type = _exptype2(identity);
+
+ if (type == DTM.TEXT_NODE || type == DTM.CDATA_SECTION_NODE)
+ {
+ int dataIndex = _dataOrQName(identity);
+
+ if (-1 == offset)
+ {
+ offset = m_data.elementAt(dataIndex);
+ }
+
+ length += m_data.elementAt(dataIndex + 1);
+ }
+
+ identity++;
+ } while (_parent2(identity) >= startNode);
+
+ if (length > 0)
+ {
+ m_chars.sendSAXcharacters(ch, offset, length);
+ }
+ }
+ }
+ else if (DTM.TEXT_NODE == type || DTM.CDATA_SECTION_NODE == type)
+ {
+ int dataIndex = _dataOrQName(identity);
+
+ m_chars.sendSAXcharacters(ch, m_data.elementAt(dataIndex),
+ m_data.elementAt(dataIndex + 1));
+ }
+ else
+ {
+ int dataIndex = _dataOrQName(identity);
+
+ if (dataIndex < 0)
+ {
+ dataIndex = -dataIndex;
+ dataIndex = m_data.elementAt(dataIndex + 1);
+ }
+
+ String str = m_valuesOrPrefixes.indexToString(dataIndex);
+ ch.characters(str.toCharArray(), 0, str.length());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]