zongaro 2002/11/13 09:04:09
Modified: java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
DTMDefaultBase.java
Log:
1) Changed constructor so that it does not set m_blocksize to 16 when indexing
is off. That was code left over from the days when RTF's did not share a
single DTM, and so a DTM for an RTF had to be as light as possible.
2) Changed getNamespaceContext to optimize for the case where the only
namespace declarations are on the root element of the document.
Revision Changes Path
No revision
No revision
1.28.2.4 +33 -13
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java
Index: DTMDefaultBase.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java,v
retrieving revision 1.28.2.3
retrieving revision 1.28.2.4
diff -u -r1.28.2.3 -r1.28.2.4
--- DTMDefaultBase.java 29 Jul 2002 00:01:30 -0000 1.28.2.3
+++ DTMDefaultBase.java 13 Nov 2002 17:04:06 -0000 1.28.2.4
@@ -210,12 +210,6 @@
DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory, boolean doIndexing)
{
- if(false == doIndexing)
- {
- m_initialblocksize = 8;
- m_blocksize = 16;
- }
-
m_exptype = new SuballocatedIntVector(m_initialblocksize);
m_firstch = new SuballocatedIntVector(m_initialblocksize);
m_nextsib = new SuballocatedIntVector(m_initialblocksize);
@@ -1271,16 +1265,42 @@
// Decrement wouldBeAt to find last possible ancestor
int candidate=m_namespaceDeclSetElements.elementAt(-- wouldBeAt);
int ancestor=_parent(elementNodeIndex);
+
+ // Special case: if the candidate is before the given node, and
+ // is in the earliest possible position in the document, it
+ // must have the namespace declarations we're interested in.
+ if (wouldBeAt == 0 && candidate < ancestor) {
+ int rootHandle = getDocumentRoot(makeNodeHandle(elementNodeIndex));
+ int rootID = makeNodeIdentity(rootHandle);
+ int uppermostNSCandidateID;
+
+ if (getNodeType(rootHandle) == DTM.DOCUMENT_NODE) {
+ int ch = _firstch(rootID);
+ uppermostNSCandidateID = (ch != DTM.NULL) ? ch : rootID;
+ } else {
+ uppermostNSCandidateID = rootID;
+ }
+
+ if (candidate == uppermostNSCandidateID) {
+ return (SuballocatedIntVector)m_namespaceDeclSets
+ .elementAt(wouldBeAt);
+ }
+ }
+
while(wouldBeAt>=0 && ancestor>0)
{
- candidate=m_namespaceDeclSetElements.elementAt(wouldBeAt);
-
- if(candidate==ancestor) // Found ancestor in list
+ if (candidate==ancestor) {
+ // Found ancestor in list
return
(SuballocatedIntVector)m_namespaceDeclSets.elementAt(wouldBeAt);
- else if(candidate<ancestor) // Too deep in tree
- ancestor=_parent(ancestor);
- else // Too late in list
- --wouldBeAt;
+ } else if (candidate<ancestor) {
+ // Too deep in tree
+ do {
+ ancestor=_parent(ancestor);
+ } while (candidate < ancestor);
+ } else {
+ // Too late in list
+ candidate=m_namespaceDeclSetElements.elementAt(--wouldBeAt);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]