You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by jk...@apache.org on 2002/08/26 19:58:06 UTC
cvs commit: xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm FuncValidate.java XNI2DTM.java
jkesselm 2002/08/26 10:58:06
Modified: java/src/org/apache/xml/dtm/ref Tag: xslt20
DTMManagerDefault.java
java/src/org/apache/xml/dtm/ref/sax2dtm Tag: xslt20
SAX2DTM.java
java/src/org/apache/xml/dtm/ref/xni2dtm Tag: xslt20
FuncValidate.java XNI2DTM.java
Log:
Reorg to support typed Temporary Trees (RTFs).
Note that I have given up the safety net which kept getDocument()
from working for shared DTMs. A better fix might be to leave that
protection in place and have validate invoke a separate call to
get the last document built (which would also clean up the
transform-to-rtf mechanism somewhat). RECONSIDER.
Revision Changes Path
No revision
No revision
1.41.6.1.2.1 +7 -3 xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java
Index: DTMManagerDefault.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java,v
retrieving revision 1.41.6.1
retrieving revision 1.41.6.1.2.1
diff -u -r1.41.6.1 -r1.41.6.1.2.1
--- DTMManagerDefault.java 14 Aug 2002 19:45:34 -0000 1.41.6.1
+++ DTMManagerDefault.java 26 Aug 2002 17:58:05 -0000 1.41.6.1.2.1
@@ -313,7 +313,11 @@
//
// %REVIEW% This is a sloppy way to request this mode;
// we need to consider architectural improvements.
- dtm = new SAX2DTM(this, source, documentID, whiteSpaceFilter,
+ //
+ // XSLT20 Temporary Trees may want to contain
+ // schema-typed nodes, so we actually need
+ // XNI2DTM rather than SAX2DTM.
+ dtm = new /*SAX2DTM*/XNI2DTM(this, source, documentID, whiteSpaceFilter,
xstringFactory, doIndexing, true);
if(DEBUG)
System.out.println("CREATING RTF DTM: "+dtm);
@@ -343,7 +347,7 @@
XNISource xsrc=(XNISource)source;
XNI2DTM dtm = new XNI2DTM(this, source, documentID, whiteSpaceFilter,
- xstringFactory, doIndexing);
+ xstringFactory, doIndexing, false);
addDTM(dtm, dtmPos, 0);
xsrc.setDocumentHandler(dtm);
@@ -404,7 +408,7 @@
if(reader.getClass().getName().equals("org.apache.xerces.parsers.SAXParser"))
{
DTM dtm = new XNI2DTM(this, source, documentID, whiteSpaceFilter,
- xstringFactory, doIndexing);
+ xstringFactory, doIndexing,false);
addDTM(dtm, dtmPos, 0);
{
No revision
No revision
1.29.2.1.2.2 +6 -2 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.29.2.1.2.1
retrieving revision 1.29.2.1.2.2
diff -u -r1.29.2.1.2.1 -r1.29.2.1.2.2
--- SAX2DTM.java 22 Aug 2002 20:03:01 -0000 1.29.2.1.2.1
+++ SAX2DTM.java 26 Aug 2002 17:58:05 -0000 1.29.2.1.2.2
@@ -1797,8 +1797,12 @@
// We _shouldn't_ clear it in non-shared DTMs, since -- at this time,
// anyway -- some of the start-up code assumes that getDocument() on the
// source document will work after the doc is closed.
- if(!JJK_LEAVE_DOCUMENT_CURRENT && m_isSharedDTM)
- m_currentDocumentNode= NULL; // no longer open
+ //
+ // ISSUE: The validate operation needs to retrieve last doc written to
+ // an RTF. We either need a separate call to obtain that, or we need to
+ // remove this safety net. Gonk
+ //if(!JJK_LEAVE_DOCUMENT_CURRENT && m_isSharedDTM)
+ // m_currentDocumentNode= NULL; // no longer open
m_endDocumentOccured = true;
}
No revision
No revision
1.1.4.1.2.1 +46 -12 xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/FuncValidate.java
Index: FuncValidate.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/FuncValidate.java,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.1.2.1
diff -u -r1.1.4.1 -r1.1.4.1.2.1
--- FuncValidate.java 14 Aug 2002 19:45:35 -0000 1.1.4.1
+++ FuncValidate.java 26 Aug 2002 17:58:06 -0000 1.1.4.1.2.1
@@ -17,9 +17,13 @@
*
* %REVIEW% Current code validates only a single root element. If we want more,
* we can do it but it'll take a bit more coding.
+ *
+ * %BUG% Need to change this to write into the RTFDTM -- which should
+ * be an instance of XNI2DTM for this purpose -- rather than always
+ * instantiating a new DTM.
* */
public class FuncValidate {
- private static final boolean JJK_DISABLE_VALIDATOR=false; // debugging hook
+ private static final boolean JJK_USE_RTFDTM=true; // validate into shared DTM
private static final boolean JJK_DUMMY_CODE=true; // debugging hook
@@ -85,9 +89,6 @@
// those through a secondary channel, eg by turning them into custom
// annotations until they get back to XNI.
XNISource xsrc;
- if(JJK_DISABLE_VALIDATOR)
- xsrc=new XNISource(d2x,null); // Test: Just flow thru
- else
{
// ISSUE: Do we need to explicitly normalize namespaces?
@@ -172,14 +173,47 @@
// as that thought might be -- the source DTM might be an RTF and
// might Go Away. We probably _should_ make it an RTF DTM, but those
// currently aren't supported for XNI.
- DTM newDTM=xctxt.getDTM(xsrc,
- true, // unique
- null, // whitespace filter
- false, // incremental -- not supported at this writing
- false // doIndexing -- open to debate
- );
-
- return newDTM.getNode(newDTM.getDocument());
+ if(!JJK_USE_RTFDTM)
+ {
+ DTM newDTM=xctxt.getDTM(xsrc,
+ true, // unique
+ null, // whitespace filter
+ false, // incremental -- not supported at this writing
+ false // doIndexing -- open to debate
+ );
+ return newDTM.getNode(newDTM.getDocument());
+ }
+ else
+ {
+ XNI2DTM dtm=(XNI2DTM)xctxt.getRTFDTM();
+ xsrc.setDocumentHandler(dtm);
+ xsrc.setErrorHandler(dtm);
+ // XNI's document scanner does support incremental.
+ // Would require yet another flavor of incremental-source to
+ // glue it to our APIs. For now, just run it to completion.
+ // MOVE THIS DOWN !!!!!
+ // %REVIEW%
+
+ try
+ {
+ xsrc.reset();
+ xsrc.scanDocument(true);
+ }
+ catch (RuntimeException re)
+ {
+ throw re;
+ }
+ catch (Exception e)
+ {
+ throw new org.apache.xml.utils.WrappedRuntimeException(e);
+ }
+
+ // We need to retrieve this. Requires either removing our
+ // block-getDocument-in-shared-DTMs hook (giving up a safety net)
+ // or creating a separate retrieve-last-document-built call.
+ // See SAX2DTM.getDocument for discussion.
+ return dtm.getNode(dtm.getDocument());
+ }
}
}
1.2.4.1.2.5 +31 -26 xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/XNI2DTM.java
Index: XNI2DTM.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/XNI2DTM.java,v
retrieving revision 1.2.4.1.2.4
retrieving revision 1.2.4.1.2.5
diff -u -r1.2.4.1.2.4 -r1.2.4.1.2.5
--- XNI2DTM.java 23 Aug 2002 14:36:35 -0000 1.2.4.1.2.4
+++ XNI2DTM.java 26 Aug 2002 17:58:06 -0000 1.2.4.1.2.5
@@ -155,16 +155,18 @@
* @param xstringfactory XMLString factory for creating character content.
* @param doIndexing true if the caller considers it worth it to use
* indexing schemes.
+ * @param shared true if the caller may want to write multiple documents
+ * into this DTM and prune them away again. This should be set true
+ * only for Result-Tree-Fragment/Temporary-Tree DTMs.
*/
public XNI2DTM(DTMManager mgr, Source source, int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
org.apache.xml.utils.XMLStringFactory xstringfactory,
- boolean doIndexing)
+ boolean doIndexing, boolean shared)
{
super(mgr, source, dtmIdentity, whiteSpaceFilter,
- xstringfactory, doIndexing);
+ xstringfactory, doIndexing, shared);
}
-
/** ADDED for XNI, SUPPLEMENTS non-schema-typed addNode:
*
@@ -401,7 +403,6 @@
*/
public void clearCoRoutine(boolean callDoTerminate)
{
-
if (null != m_incrementalXNISource)
{
if (callDoTerminate)
@@ -409,6 +410,8 @@
m_incrementalXNISource = null;
}
+ else
+ super.clearCoRoutine(callDoTerminate);
}
/** ADDED FOR XNI, REPLACES setIncrementalSAXSource:
@@ -448,7 +451,7 @@
*/
public boolean needsTwoThreads()
{
- return null != m_incrementalXNISource;
+ return null != m_incrementalXNISource || super.needsTwoThreads();
}
/** OVERRIDDEN FOR XNI:
@@ -465,29 +468,31 @@
protected boolean nextNode()
{
if (null == m_incrementalXNISource)
- return false;
-
- if (m_endDocumentOccured)
- {
- clearCoRoutine();
- return false;
- }
-
- try
+ return super.nextNode();
+ else
{
- boolean gotMore = m_incrementalXNISource.parse(false);
- if (!gotMore)
- {
- // EOF reached without satisfying the request
- clearCoRoutine(); // Drop connection, stop trying
- // %TBD% deregister as its listener?
- }
- return gotMore;
+ if (m_endDocumentOccured)
+ {
+ clearCoRoutine();
+ return false;
+ }
+
+ try
+ {
+ boolean gotMore = m_incrementalXNISource.parse(false);
+ if (!gotMore)
+ {
+ // EOF reached without satisfying the request
+ clearCoRoutine(); // Drop connection, stop trying
+ // %TBD% deregister as its listener?
+ }
+ return gotMore;
+ }
+ catch(RuntimeException e)
+ { throw e; }
+ catch(Exception e)
+ { throw new WrappedRuntimeException(e); }
}
- catch(RuntimeException e)
- { throw e; }
- catch(Exception e)
- { throw new WrappedRuntimeException(e); }
}
////////////////////////////////////////////////////////////////////
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org