mkwan 2003/06/23 08:23:41
Modified: java/src/org/apache/xalan/xsltc/dom SAXImpl.java
SimpleResultTreeImpl.java XSLTCDTMManager.java
java/src/org/apache/xalan/xsltc/trax XSLTCSource.java
java/src/org/apache/xml/dtm DTM.java
java/src/org/apache/xml/dtm/ref DTMDefaultBase.java
DTMDefaultBaseIterators.java
DTMDefaultBaseTraversers.java DTMDocumentImpl.java
java/src/org/apache/xml/dtm/ref/sax2dtm SAX2DTM.java
SAX2DTM2.java
Log:
Implement a "DTM migration" feature, which allows a DTM that is built with
an old DTMManager to be migrated to a new DTMManager. This is to support
DTM sharing between multiple transformations.
Revision Changes Path
1.7 +19 -4
xml-xalan/java/src/org/apache/xalan/xsltc/dom/SAXImpl.java
Index: SAXImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SAXImpl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SAXImpl.java 16 Apr 2003 20:58:49 -0000 1.6
+++ SAXImpl.java 23 Jun 2003 15:23:39 -0000 1.7
@@ -677,7 +677,7 @@
boolean doIndexing, boolean buildIdIndex)
{
this(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
- doIndexing, DEFAULT_BLOCKSIZE, buildIdIndex);
+ doIndexing, DEFAULT_BLOCKSIZE, buildIdIndex, false);
}
/**
@@ -687,10 +687,11 @@
int dtmIdentity, DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing, int blocksize,
- boolean buildIdIndex)
+ boolean buildIdIndex,
+ boolean newNameTable)
{
super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
- doIndexing, blocksize, false, buildIdIndex);
+ doIndexing, blocksize, false, buildIdIndex, newNameTable);
_dtmManager = mgr;
_size = blocksize;
@@ -715,6 +716,20 @@
}
_node2Ids = new Hashtable();
}
+ }
+
+ /**
+ * Migrate a DTM built with an old DTMManager to a new DTMManager.
+ * After the migration, the new DTMManager will treat the DTM as
+ * one that is built by itself.
+ * This is used to support DTM sharing between multiple transformations.
+ * @param manager the DTMManager
+ */
+ public void migrateTo(DTMManager manager) {
+ super.migrateTo(manager);
+ if (manager instanceof XSLTCDTMManager) {
+ _dtmManager = (XSLTCDTMManager)manager;
+ }
}
/**
1.4 +4 -0
xml-xalan/java/src/org/apache/xalan/xsltc/dom/SimpleResultTreeImpl.java
Index: SimpleResultTreeImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SimpleResultTreeImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SimpleResultTreeImpl.java 3 Apr 2003 16:48:11 -0000 1.3
+++ SimpleResultTreeImpl.java 23 Jun 2003 15:23:39 -0000 1.4
@@ -64,6 +64,7 @@
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMAxisIterator;
import org.apache.xml.dtm.DTMAxisTraverser;
+import org.apache.xml.dtm.DTMManager;
import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
import org.apache.xml.dtm.ref.DTMManagerDefault;
import org.apache.xml.serializer.EmptySerializer;
@@ -1041,4 +1042,7 @@
{
}
+ public void migrateTo(DTMManager manager)
+ {
+ }
}
1.3 +84 -6
xml-xalan/java/src/org/apache/xalan/xsltc/dom/XSLTCDTMManager.java
Index: XSLTCDTMManager.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/XSLTCDTMManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSLTCDTMManager.java 1 Apr 2003 21:39:17 -0000 1.2
+++ XSLTCDTMManager.java 23 Jun 2003 15:23:39 -0000 1.3
@@ -62,6 +62,7 @@
import javax.xml.transform.stream.StreamSource;
import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.ref.DTMDefaultBase;
import org.apache.xml.dtm.DTMException;
import org.apache.xml.dtm.DTMWSFilter;
import org.apache.xml.dtm.ref.DTMManagerDefault;
@@ -142,7 +143,7 @@
boolean doIndexing)
{
return getDTM(source, unique, whiteSpaceFilter, incremental,
- doIndexing, false, 0, true);
+ doIndexing, false, 0, true, false);
}
/**
@@ -172,7 +173,7 @@
boolean doIndexing, boolean buildIdIndex)
{
return getDTM(source, unique, whiteSpaceFilter, incremental,
- doIndexing, false, 0, buildIdIndex);
+ doIndexing, false, 0, buildIdIndex, false);
}
/**
@@ -193,6 +194,39 @@
* possible.
* @param doIndexing true if the caller considers it worth it to use
* indexing schemes.
+ * @param buildIdIndex true if the id index table should be built.
+ * @param newNameTable true if we want to use a separate
ExpandedNameTable
+ * for this DTM.
+ *
+ * @return a non-null DTM reference.
+ */
+ public DTM getDTM(Source source, boolean unique,
+ DTMWSFilter whiteSpaceFilter, boolean incremental,
+ boolean doIndexing, boolean buildIdIndex,
+ boolean newNameTable)
+ {
+ return getDTM(source, unique, whiteSpaceFilter, incremental,
+ doIndexing, false, 0, buildIdIndex, newNameTable);
+ }
+
+ /**
+ * Get an instance of a DTM, loaded with the content from the
+ * specified source. If the unique flag is true, a new instance will
+ * always be returned. Otherwise it is up to the DTMManager to return a
+ * new instance or an instance that it already created and may be being
used
+ * by someone else.
+ * (I think more parameters will need to be added for error handling, and
+ * entity resolution).
+ *
+ * @param source the specification of the source object.
+ * @param unique true if the returned DTM must be unique, probably
because it
+ * is going to be mutated.
+ * @param whiteSpaceFilter Enables filtering of whitespace nodes, and may
+ * be null.
+ * @param incremental true if the DTM should be built incrementally, if
+ * possible.
+ * @param doIndexing true if the caller considers it worth it to use
+ * indexing schemes.
* @param hasUserReader true if <code>source</code> is a
* <code>SAXSource</code> object that has an
* <code>XMLReader</code>, that was specified by the
@@ -207,6 +241,45 @@
boolean doIndexing, boolean hasUserReader, int size,
boolean buildIdIndex)
{
+ return getDTM(source, unique, whiteSpaceFilter, incremental,
+ doIndexing, hasUserReader, size,
+ buildIdIndex, false);
+ }
+
+ /**
+ * Get an instance of a DTM, loaded with the content from the
+ * specified source. If the unique flag is true, a new instance will
+ * always be returned. Otherwise it is up to the DTMManager to return a
+ * new instance or an instance that it already created and may be being
used
+ * by someone else.
+ * (I think more parameters will need to be added for error handling, and
+ * entity resolution).
+ *
+ * @param source the specification of the source object.
+ * @param unique true if the returned DTM must be unique, probably
because it
+ * is going to be mutated.
+ * @param whiteSpaceFilter Enables filtering of whitespace nodes, and may
+ * be null.
+ * @param incremental true if the DTM should be built incrementally, if
+ * possible.
+ * @param doIndexing true if the caller considers it worth it to use
+ * indexing schemes.
+ * @param hasUserReader true if <code>source</code> is a
+ * <code>SAXSource</code> object that has an
+ * <code>XMLReader</code>, that was specified by the
+ * user.
+ * @param size Specifies initial size of tables that represent the DTM
+ * @param buildIdIndex true if the id index table should be built.
+ * @param newNameTable true if we want to use a separate
ExpandedNameTable
+ * for this DTM.
+ *
+ * @return a non-null DTM reference.
+ */
+ public DTM getDTM(Source source, boolean unique,
+ DTMWSFilter whiteSpaceFilter, boolean incremental,
+ boolean doIndexing, boolean hasUserReader, int size,
+ boolean buildIdIndex, boolean newNameTable)
+ {
if(DEBUG && null != source) {
System.out.println("Starting "+
(unique ? "UNIQUE" : "shared")+
@@ -226,10 +299,13 @@
if (size <= 0) {
dtm = new SAXImpl(this, source, documentID,
- whiteSpaceFilter, null, doIndexing, buildIdIndex);
+ whiteSpaceFilter, null, doIndexing,
+ DTMDefaultBase.DEFAULT_BLOCKSIZE,
+ buildIdIndex, newNameTable);
} else {
dtm = new SAXImpl(this, source, documentID,
- whiteSpaceFilter, null, doIndexing, size,
buildIdIndex);
+ whiteSpaceFilter, null, doIndexing,
+ size, buildIdIndex, newNameTable);
}
dtm.setDocumentURI(source.getSystemId());
@@ -289,10 +365,12 @@
SAXImpl dtm;
if (size <= 0) {
dtm = new SAXImpl(this, source, documentID,
whiteSpaceFilter,
- null, doIndexing, buildIdIndex);
+ null, doIndexing,
+ DTMDefaultBase.DEFAULT_BLOCKSIZE,
+ buildIdIndex, newNameTable);
} else {
dtm = new SAXImpl(this, source, documentID,
whiteSpaceFilter,
- null, doIndexing, size, buildIdIndex);
+ null, doIndexing, size, buildIdIndex, newNameTable);
}
// Go ahead and add the DTM to the lookup table. This needs
to be
1.7 +3 -3
xml-xalan/java/src/org/apache/xalan/xsltc/trax/XSLTCSource.java
Index: XSLTCSource.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/XSLTCSource.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XSLTCSource.java 1 Apr 2003 21:19:06 -0000 1.6
+++ XSLTCSource.java 23 Jun 2003 15:23:40 -0000 1.7
@@ -102,8 +102,8 @@
XSLTCDTMManager.newInstance();
int dtmPos = dtmManager.getFirstFreeDTMID();
int documentID = dtmPos << DTMManager.IDENT_DTM_NODE_BITS;
- _dom = (DOM)new SAXImpl(dtmManager, this, documentID, null,
- null, false, size, true);
+ _dom = new SAXImpl(dtmManager, this, documentID, null,
+ null, false, size, true, false);
dtmManager.addDTM((DTM)_dom, dtmPos);
}
1.11 +9 -0 xml-xalan/java/src/org/apache/xml/dtm/DTM.java
Index: DTM.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTM.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DTM.java 1 Apr 2003 19:00:51 -0000 1.10
+++ DTM.java 23 Jun 2003 15:23:40 -0000 1.11
@@ -1006,4 +1006,13 @@
*/
public void documentRelease();
+
+ /**
+ * Migrate a DTM built with an old DTMManager to a new DTMManager.
+ * After the migration, the new DTMManager will treat the DTM as
+ * one that is built by itself.
+ * This is used to support DTM sharing between multiple transformations.
+ * @param manager the DTMManager
+ */
+ public void migrateTo(DTMManager manager);
}
1.37 +19 -5
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.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- DTMDefaultBase.java 23 Apr 2003 22:35:48 -0000 1.36
+++ DTMDefaultBase.java 23 Jun 2003 15:23:40 -0000 1.37
@@ -206,7 +206,7 @@
XMLStringFactory xstringfactory, boolean doIndexing)
{
this(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
- doIndexing, DEFAULT_BLOCKSIZE, true);
+ doIndexing, DEFAULT_BLOCKSIZE, true, false);
}
/**
@@ -223,14 +223,14 @@
* indexing schemes.
* @param blocksize The block size of the DTM.
* @param usePrevsib true if we want to build the previous sibling node
array.
+ * @param newNameTable true if we want to use a new ExpandedNameTable for
this DTM.
*/
public DTMDefaultBase(DTMManager mgr, Source source, int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory, boolean doIndexing,
- int blocksize, boolean usePrevsib)
- {
- //m_blocksize = blocksize;
-
+ int blocksize, boolean usePrevsib,
+ boolean newNameTable)
+ {
// Use smaller sizes for the internal node arrays if the block size
// is small.
int numblocks;
@@ -2380,6 +2380,20 @@
public void documentRelease()
{
}
+
+ /**
+ * Migrate a DTM built with an old DTMManager to a new DTMManager.
+ * After the migration, the new DTMManager will treat the DTM as
+ * one that is built by itself.
+ * This is used to support DTM sharing between multiple transformations.
+ * @param manager the DTMManager
+ */
+ public void migrateTo(DTMManager mgr)
+ {
+ m_mgr = mgr;
+ if(mgr instanceof DTMManagerDefault)
+ m_mgrDefault=(DTMManagerDefault)mgr;
+ }
/** Query which DTMManager this DTM is currently being handled by.
*
1.20 +4 -2
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseIterators.java
Index: DTMDefaultBaseIterators.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseIterators.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- DTMDefaultBaseIterators.java 1 Apr 2003 19:14:04 -0000 1.19
+++ DTMDefaultBaseIterators.java 23 Jun 2003 15:23:40 -0000 1.20
@@ -109,6 +109,7 @@
* indexing schemes.
* @param blocksize The block size of the DTM.
* @param usePrevsib true if we want to build the previous sibling node
array.
+ * @param newNameTable true if we want to use a new ExpandedNameTable for
this DTM.
*/
public DTMDefaultBaseIterators(DTMManager mgr, Source source,
int dtmIdentity,
@@ -116,10 +117,11 @@
XMLStringFactory xstringfactory,
boolean doIndexing,
int blocksize,
- boolean usePrevsib)
+ boolean usePrevsib,
+ boolean newNameTable)
{
super(mgr, source, dtmIdentity, whiteSpaceFilter,
- xstringfactory, doIndexing, blocksize, usePrevsib);
+ xstringfactory, doIndexing, blocksize, usePrevsib, newNameTable);
}
/**
1.18 +4 -2
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseTraversers.java
Index: DTMDefaultBaseTraversers.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseTraversers.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- DTMDefaultBaseTraversers.java 1 Apr 2003 19:14:04 -0000 1.17
+++ DTMDefaultBaseTraversers.java 23 Jun 2003 15:23:40 -0000 1.18
@@ -114,6 +114,7 @@
* indexing schemes.
* @param blocksize The block size of the DTM.
* @param usePrevsib true if we want to build the previous sibling node
array.
+ * @param newNameTable true if we want to use a new ExpandedNameTable for
this DTM.
*/
public DTMDefaultBaseTraversers(DTMManager mgr, Source source,
int dtmIdentity,
@@ -121,10 +122,11 @@
XMLStringFactory xstringfactory,
boolean doIndexing,
int blocksize,
- boolean usePrevsib)
+ boolean usePrevsib,
+ boolean newNameTable)
{
super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
- doIndexing, blocksize, usePrevsib);
+ doIndexing, blocksize, usePrevsib, newNameTable);
}
/**
1.11 +10 -0
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDocumentImpl.java
Index: DTMDocumentImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDocumentImpl.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DTMDocumentImpl.java 1 Apr 2003 19:14:04 -0000 1.10
+++ DTMDocumentImpl.java 23 Jun 2003 15:23:40 -0000 1.11
@@ -2443,5 +2443,15 @@
{
}
+ /**
+ * Migrate a DTM built with an old DTMManager to a new DTMManager.
+ * After the migration, the new DTMManager will treat the DTM as
+ * one that is built by itself.
+ * This is used to support DTM sharing between multiple transformations.
+ * @param manager the DTMManager
+ */
+ public void migrateTo(DTMManager manager)
+ {
+ }
}
1.35 +29 -3
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java
Index: SAX2DTM.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- SAX2DTM.java 1 Apr 2003 18:56:03 -0000 1.34
+++ SAX2DTM.java 23 Jun 2003 15:23:41 -0000 1.35
@@ -263,7 +263,7 @@
{
this(mgr, source, dtmIdentity, whiteSpaceFilter,
- xstringfactory, doIndexing, DEFAULT_BLOCKSIZE, true);
+ xstringfactory, doIndexing, DEFAULT_BLOCKSIZE, true, false);
}
/**
@@ -280,17 +280,19 @@
* indexing schemes.
* @param blocksize The block size of the DTM.
* @param usePrevsib true if we want to build the previous sibling node
array.
+ * @param newNameTable true if we want to use a new ExpandedNameTable for
this DTM.
*/
public SAX2DTM(DTMManager mgr, Source source, int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing,
int blocksize,
- boolean usePrevsib)
+ boolean usePrevsib,
+ boolean newNameTable)
{
super(mgr, source, dtmIdentity, whiteSpaceFilter,
- xstringfactory, doIndexing, blocksize, usePrevsib);
+ xstringfactory, doIndexing, blocksize, usePrevsib, newNameTable);
// %OPT% Use smaller sizes for all internal storage units when
// the blocksize is small. This reduces the cost of creating an RTF.
@@ -981,6 +983,30 @@
// not to add messages right not for I18N reasons.
// %REVIEW% Should this be a Fatal Error?
error(XMLMessages.createXMLMessage(XMLErrorResources.ER_NO_DTMIDS_AVAIL,
null));//"No more DTM IDs are available";
+ }
+ }
+
+ /**
+ * Migrate a DTM built with an old DTMManager to a new DTMManager.
+ * After the migration, the new DTMManager will treat the DTM as
+ * one that is built by itself.
+ * This is used to support DTM sharing between multiple transformations.
+ * @param manager the DTMManager
+ */
+ public void migrateTo(DTMManager manager) {
+ super.migrateTo(manager);
+
+ // We have to reset the information in m_dtmIdent and
+ // register the DTM with the new manager.
+ int numDTMs = m_dtmIdent.size();
+ int dtmId = m_mgrDefault.getFirstFreeDTMID();
+ int nodeIndex = 0;
+ for (int i = 0; i < numDTMs; i++)
+ {
+ m_dtmIdent.setElementAt(dtmId << DTMManager.IDENT_DTM_NODE_BITS, i);
+ m_mgrDefault.addDTM(this, dtmId, nodeIndex);
+ dtmId++;
+ nodeIndex += (1 << DTMManager.IDENT_DTM_NODE_BITS);
}
}
1.5 +4 -3
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM2.java
Index: SAX2DTM2.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM2.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SAX2DTM2.java 16 Jun 2003 14:40:48 -0000 1.4
+++ SAX2DTM2.java 23 Jun 2003 15:23:41 -0000 1.5
@@ -1882,7 +1882,7 @@
{
this(mgr, source, dtmIdentity, whiteSpaceFilter,
- xstringfactory, doIndexing, DEFAULT_BLOCKSIZE, true, true);
+ xstringfactory, doIndexing, DEFAULT_BLOCKSIZE, true, true, false);
}
/**
@@ -1894,11 +1894,12 @@
boolean doIndexing,
int blocksize,
boolean usePrevsib,
- boolean buildIdIndex)
+ boolean buildIdIndex,
+ boolean newNameTable)
{
super(mgr, source, dtmIdentity, whiteSpaceFilter,
- xstringfactory, doIndexing, blocksize, usePrevsib);
+ xstringfactory, doIndexing, blocksize, usePrevsib, newNameTable);
// Initialize the values of m_SHIFT and m_MASK.
int shift;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]