mmidy 02/04/17 11:13:49
Modified: java/src/org/apache/xalan/templates Tag: XSLTC_DTM
ElemApplyTemplates.java
java/src/org/apache/xalan/xsltc Tag: XSLTC_DTM DOM.java
DOMCache.java NodeIterator.java Translet.java
java/src/org/apache/xalan/xsltc/cmdline Tag: XSLTC_DTM
Transform.java
java/src/org/apache/xalan/xsltc/compiler Tag: XSLTC_DTM
AbsolutePathPattern.java AncestorPattern.java
Constants.java CopyOf.java DocumentCall.java
ForEach.java IdKeyPattern.java Import.java Key.java
KeyCall.java LastCall.java Mode.java NameBase.java
NodeTest.java ParentLocationPath.java Parser.java
ProcessingInstructionPattern.java Step.java
StepPattern.java Stylesheet.java
SyntaxTreeNode.java UnionPathExpr.java XSLTC.java
java/src/org/apache/xalan/xsltc/compiler/util Tag: XSLTC_DTM
MethodGenerator.java NodeSetType.java
ResultTreeType.java
java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
AbsoluteIterator.java AnyNodeCounter.java Axis.java
BitArray.java CurrentNodeListFilter.java
CurrentNodeListIterator.java DOMAdapter.java
DOMImpl.java DTDMonitor.java DocumentCache.java
DupFilterIterator.java FilterIterator.java
FilteredStepIterator.java KeyIndex.java
LoadDocument.java MatchingIterator.java
MultiDOM.java MultipleNodeCounter.java
NodeCounter.java NthIterator.java
ReverseIterator.java SingleNodeCounter.java
SingletonIterator.java SortingIterator.java
StepIterator.java UnionIterator.java
java/src/org/apache/xalan/xsltc/runtime Tag: XSLTC_DTM
AbstractTranslet.java BasisLibrary.java
Constants.java DefaultRun.java SAXAdapter.java
java/src/org/apache/xalan/xsltc/trax Tag: XSLTC_DTM
TransformerHandlerImpl.java TransformerImpl.java
XSLTCSource.java
java/src/org/apache/xml/dtm Tag: XSLTC_DTM DTM.java
DTMAxisIterator.java DTMManager.java
java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
DTMAxisIteratorBase.java DTMDefaultBase.java
DTMDefaultBaseIterators.java DTMNamedNodeMap.java
DTMNodeList.java DTMNodeProxy.java
ExpandedNameTable.java
java/src/org/apache/xml/dtm/ref/dom2dtm Tag: XSLTC_DTM
DOM2DTM.java
java/src/org/apache/xml/dtm/ref/sax2dtm Tag: XSLTC_DTM
SAX2DTM.java
Added: java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
SAXImpl.java XSLTCDTMManager.java
Log:
Checking in a branch of xalan where XSLTC is using the DTM interface. This
branch is very unstable, please do not use yet!!!
Revision Changes Path
No revision
No revision
1.23.2.1 +1 -0
xml-xalan/java/src/org/apache/xalan/templates/ElemApplyTemplates.java
Index: ElemApplyTemplates.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemApplyTemplates.java,v
retrieving revision 1.23
retrieving revision 1.23.2.1
diff -u -r1.23 -r1.23.2.1
--- ElemApplyTemplates.java 10 Apr 2002 20:33:58 -0000 1.23
+++ ElemApplyTemplates.java 17 Apr 2002 18:13:40 -0000 1.23.2.1
@@ -329,6 +329,7 @@
}
final int exNodeType = dtm.getExpandedTypeID(child);
+
final int nodeType = dtm.getNodeType(child);
final QName mode = transformer.getMode();
No revision
No revision
1.9.10.1 +31 -22 xml-xalan/java/src/org/apache/xalan/xsltc/DOM.java
Index: DOM.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/DOM.java,v
retrieving revision 1.9
retrieving revision 1.9.10.1
diff -u -r1.9 -r1.9.10.1
--- DOM.java 26 Nov 2001 14:03:09 -0000 1.9
+++ DOM.java 17 Apr 2002 18:13:41 -0000 1.9.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOM.java,v 1.9 2001/11/26 14:03:09 morten Exp $
+ * @(#)$Id: DOM.java,v 1.9.10.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -66,43 +66,46 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.apache.xml.dtm.*;
+import org.apache.xml.dtm.ref.*;
+
public interface DOM {
public final static int FIRST_TYPE = 0;
public final static int NO_TYPE = -1;
- public final static int ROOT = 0;
- public final static int TEXT = 1;
- public final static int NAMESPACE = 2;
- public final static int ELEMENT = 3;
- public final static int ATTRIBUTE = 4;
- public final static int PROCESSING_INSTRUCTION = 5;
- public final static int COMMENT = 6;
+ //public final static int ROOT = 0;
+ //public final static int TEXT = 1;
+ //public final static int NAMESPACE = 2;
+ // public final static int ELEMENT = 3;
+ // public final static int ATTRIBUTE = 4;
+ // public final static int PROCESSING_INSTRUCTION = 5;
+ // public final static int COMMENT = 6;
- public final static int NTYPES = 7;
+ //public final static int NTYPES = 7;
// 0 is reserved for NodeIterator.END
public final static int NULL = 0;
// index of root node
- public final static int ROOTNODE = 1;
+ //public final static int ROOTNODE = 1;
// used by some node iterators to know which node to return
public final static int RETURN_CURRENT = 0;
public final static int RETURN_PARENT = 1;
/** returns singleton iterator containg the document root */
- public NodeIterator getIterator();
+ public DTMAxisIterator getIterator();
public String getStringValue();
public String getTreeString(); // this one includes PIs and comments...
- public NodeIterator getChildren(final int node);
- public NodeIterator getTypedChildren(final int type);
- public NodeIterator getAxisIterator(final int axis);
- public NodeIterator getTypedAxisIterator(final int axis, final int type);
- public NodeIterator getNthDescendant(int node, int n, boolean
includeself);
- public NodeIterator getNamespaceAxisIterator(final int axis, final int
ns);
- public NodeIterator getNodeValueIterator(NodeIterator iter, int
returnType,
+ public DTMAxisIterator getChildren(final int node);
+ public DTMAxisIterator getTypedChildren(final int type);
+ public DTMAxisIterator getAxisIterator(final int axis);
+ public DTMAxisIterator getTypedAxisIterator(final int axis, final int
type);
+ public DTMAxisIterator getNthDescendant(int node, int n, boolean
includeself);
+ public DTMAxisIterator getNamespaceAxisIterator(final int axis, final
int ns);
+ public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iter, int
returnType,
String value, boolean op);
- public NodeIterator orderNodes(NodeIterator source, int node);
+ public DTMAxisIterator orderNodes(DTMAxisIterator source, int node);
public String getNodeName(final int node);
public String getNamespaceName(final int node);
public int getType(final int node);
@@ -112,7 +115,7 @@
public String getNodeValue(final int node);
public void copy(final int node, TransletOutputHandler handler)
throws TransletException;
- public void copy(NodeIterator nodes, TransletOutputHandler handler)
+ public void copy(DTMAxisIterator nodes, TransletOutputHandler handler)
throws TransletException;
public String shallowCopy(final int node, TransletOutputHandler handler)
throws TransletException;
@@ -120,9 +123,9 @@
public void characters(final int textNode, TransletOutputHandler handler)
throws TransletException;
public Node makeNode(int index);
- public Node makeNode(NodeIterator iter);
+ public Node makeNode(DTMAxisIterator iter);
public NodeList makeNodeList(int index);
- public NodeList makeNodeList(NodeIterator iter);
+ public NodeList makeNodeList(DTMIterator iter);
public String getLanguage(int node);
public int getSize();
public String getDocumentURI(int node);
@@ -132,4 +135,10 @@
public void setupMapping(String[] names, String[] namespaces);
public boolean isElement(final int node);
public boolean isAttribute(final int node);
+ public int getNodeIdent(final int nodehandle);
+ public int getNodeHandle(final int nodeId);
+ public DOM getResultTreeFrag();
+ public TransletOutputHandler getOutputDomBuilder();
+ public int getNSType(int node);
+ public int getDocument();
}
1.2.10.1 +2 -2 xml-xalan/java/src/org/apache/xalan/xsltc/DOMCache.java
Index: DOMCache.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/DOMCache.java,v
retrieving revision 1.2
retrieving revision 1.2.10.1
diff -u -r1.2 -r1.2.10.1
--- DOMCache.java 8 Nov 2001 14:11:14 -0000 1.2
+++ DOMCache.java 17 Apr 2002 18:13:41 -0000 1.2.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOMCache.java,v 1.2 2001/11/08 14:11:14 morten Exp $
+ * @(#)$Id: DOMCache.java,v 1.2.10.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -92,6 +92,6 @@
*
* _dom.setDocumentURI(uri);
*/
- public DOMImpl retrieveDocument(String uri, int mask, Translet translet);
+ public DOM retrieveDocument(String uri, int mask, Translet translet);
}
1.2.10.1 +4 -2
xml-xalan/java/src/org/apache/xalan/xsltc/NodeIterator.java
Index: NodeIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/NodeIterator.java,v
retrieving revision 1.2
retrieving revision 1.2.10.1
diff -u -r1.2 -r1.2.10.1
--- NodeIterator.java 4 Dec 2001 10:30:07 -0000 1.2
+++ NodeIterator.java 17 Apr 2002 18:13:41 -0000 1.2.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NodeIterator.java,v 1.2 2001/12/04 10:30:07 morten Exp $
+ * @(#)$Id: NodeIterator.java,v 1.2.10.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -63,8 +63,10 @@
package org.apache.xalan.xsltc;
+import org.apache.xml.dtm.DTM;
+
public interface NodeIterator extends Cloneable {
- public static final int END = DOM.NULL;
+ public static final int END = DTM.NULL;
/**
* Callers should not call next() after it returns END.
1.3.10.1 +6 -3 xml-xalan/java/src/org/apache/xalan/xsltc/Translet.java
Index: Translet.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/Translet.java,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -r1.3 -r1.3.10.1
--- Translet.java 28 Sep 2001 14:39:14 -0000 1.3
+++ Translet.java 17 Apr 2002 18:13:41 -0000 1.3.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Translet.java,v 1.3 2001/09/28 14:39:14 morten Exp $
+ * @(#)$Id: Translet.java,v 1.3.10.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -63,19 +63,22 @@
package org.apache.xalan.xsltc;
+import org.apache.xml.dtm.*;
+import org.apache.xml.dtm.ref.*;
+
public interface Translet {
public void transform(DOM document, TransletOutputHandler handler)
throws TransletException;
public void transform(DOM document, TransletOutputHandler[] handlers)
throws TransletException;
- public void transform(DOM document, NodeIterator iterator,
+ public void transform(DOM document, DTMAxisIterator iterator,
TransletOutputHandler handler)
throws TransletException;
public Object addParameter(String name, Object value);
- public void buildKeys(DOM document, NodeIterator iterator,
+ public void buildKeys(DOM document, DTMAxisIterator iterator,
TransletOutputHandler handler, int root)
throws TransletException;
public void addAuxiliaryClass(Class auxClass);
No revision
No revision
1.15.10.1 +23 -11
xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Transform.java
Index: Transform.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Transform.java,v
retrieving revision 1.15
retrieving revision 1.15.10.1
diff -u -r1.15 -r1.15.10.1
--- Transform.java 17 Dec 2001 15:11:21 -0000 1.15
+++ Transform.java 17 Apr 2002 18:13:41 -0000 1.15.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Transform.java,v 1.15 2001/12/17 15:11:21 morten Exp $
+ * @(#)$Id: Transform.java,v 1.15.10.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -74,10 +74,13 @@
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.sax.SAXSource;
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
import org.xml.sax.ext.LexicalHandler;
import org.apache.xalan.xsltc.DOM;
@@ -86,12 +89,11 @@
import org.apache.xalan.xsltc.TransletOutputHandler;
import org.apache.xalan.xsltc.runtime.*;
-import org.apache.xalan.xsltc.dom.DOMImpl;
-import org.apache.xalan.xsltc.dom.DOMBuilder;
-import org.apache.xalan.xsltc.dom.Axis;
-import org.apache.xalan.xsltc.dom.DTDMonitor;
+import org.apache.xalan.xsltc.dom.*;
import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
+import org.apache.xml.dtm.DTMManager;
+
final public class Transform {
private TransletOutputHandler _handler;
@@ -159,9 +161,16 @@
final SAXParser parser = factory.newSAXParser();
final XMLReader reader = parser.getXMLReader();
+ // Create a DTD monitor and pass it to the XMLReader object
+ final DTDMonitor dtdMonitor = new DTDMonitor(reader);
+
// Set the DOM's DOM builder as the XMLReader's SAX2 content handler
- final DOMImpl dom = new DOMImpl();
- DOMBuilder builder = dom.getBuilder();
+ DTMManager dtmManager = XSLTCDTMManager.newInstance(
+ org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+
+ final SAXImpl dom = (SAXImpl)dtmManager.getDTM(new SAXSource(reader,
new InputSource(_fileName)), false, null, true, true);
+ //final DOMImpl dom = new DOMImpl();
+/* DOMBuilder builder = dom.getBuilder();
reader.setContentHandler(builder);
try {
@@ -170,18 +179,21 @@
}
catch (SAXException e) {
// quitely ignored
- }
+ } */
+
+
// Create a DTD monitor and pass it to the XMLReader object
- final DTDMonitor dtdMonitor = new DTDMonitor(reader);
+ // final DTDMonitor dtdMonitor = new DTDMonitor(reader);
+
AbstractTranslet _translet = (AbstractTranslet)translet;
dom.setDocumentURI(_fileName);
- if (_uri)
+/* if (_uri)
reader.parse(_fileName);
else
reader.parse(new File(_fileName).toURL().toExternalForm());
- builder = null;
+ builder = null; */
// If there are any elements with ID attributes, build an index
dtdMonitor.buildIdIndex(dom, 0, _translet);
No revision
No revision
1.5.6.1 +4 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsolutePathPattern.java
Index: AbsolutePathPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsolutePathPattern.java,v
retrieving revision 1.5
retrieving revision 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- AbsolutePathPattern.java 1 Feb 2002 20:07:08 -0000 1.5
+++ AbsolutePathPattern.java 17 Apr 2002 18:13:41 -0000 1.5.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AbsolutePathPattern.java,v 1.5 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: AbsolutePathPattern.java,v 1.5.6.1 2002/04/17 18:13:41 mmidy Exp
$
*
* The Apache Software License, Version 1.1
*
@@ -70,6 +70,8 @@
import org.apache.bcel.generic.*;
import org.apache.xalan.xsltc.compiler.util.*;
+import org.apache.xml.dtm.DTM;
+
final class AbsolutePathPattern extends LocationPathPattern {
private final RelativePathPattern _left; // may be null
@@ -139,7 +141,7 @@
il.append(SWAP);
}
il.append(new INVOKEINTERFACE(getType, 2));
- il.append(new PUSH(cpg, DOM.ROOT));
+ il.append(new PUSH(cpg, DTM.DOCUMENT_NODE));
// long jump: _falseList.add(il.append(new IF_ICMPNE(null)));
final BranchHandle skip = il.append(new IF_ICMPEQ(null));
1.4.6.1 +2 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AncestorPattern.java
Index: AncestorPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AncestorPattern.java,v
retrieving revision 1.4
retrieving revision 1.4.6.1
diff -u -r1.4 -r1.4.6.1
--- AncestorPattern.java 1 Feb 2002 20:07:08 -0000 1.4
+++ AncestorPattern.java 17 Apr 2002 18:13:41 -0000 1.4.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AncestorPattern.java,v 1.4 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: AncestorPattern.java,v 1.4.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -143,7 +143,7 @@
il.append(DUP);
il.append(storeLocal);
- _falseList.add(il.append(new IFEQ(null)));
+ _falseList.add(il.append(new IFLT(null)));
il.append(loadLocal);
_left.translate(classGen, methodGen);
1.19.2.1 +14 -6
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java
Index: Constants.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -u -r1.19 -r1.19.2.1
--- Constants.java 2 Apr 2002 19:01:37 -0000 1.19
+++ Constants.java 17 Apr 2002 18:13:41 -0000 1.19.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Constants.java,v 1.19 2002/04/02 19:01:37 santiagopg Exp $
+ * @(#)$Id: Constants.java,v 1.19.2.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -98,13 +98,17 @@
public static final String ATTRIBUTES_SIG
= "Lorg/apache/xalan/xsltc/runtime/Attributes;";
public static final String NODE_ITERATOR_SIG
- = "Lorg/apache/xalan/xsltc/NodeIterator;";
+ = "Lorg/apache/xml/dtm/DTMAxisIterator;";
public static final String DOM_INTF_SIG
= "Lorg/apache/xalan/xsltc/DOM;";
public static final String DOM_IMPL_CLASS
- = "org/apache/xalan/xsltc/dom/DOMImpl";
+ = "org/apache/xalan/xsltc/DOM"; //
xml/dtm/ref/DTMDefaultBaseIterators"; //xalan/xsltc/dom/DOMImpl";
+ public static final String SAX_IMPL_CLASS
+ = "org/apache/xalan/xsltc/DOM/SAXImpl";
public static final String DOM_IMPL_SIG
- = "Lorg/apache/xalan/xsltc/dom/DOMImpl;";
+ = "Lorg/apache/xalan/xsltc/dom/SAXImpl;";
//xml/dtm/ref/DTMDefaultBaseIterators"; //xalan/xsltc/dom/DOMImpl;";
+ public static final String SAX_IMPL_SIG
+ = "Lorg/apache/xalan/xsltc/dom/SAXImpl;";
public static final String DOM_ADAPTER_CLASS
= "org/apache/xalan/xsltc/dom/DOMAdapter";
public static final String DOM_ADAPTER_SIG
@@ -146,7 +150,7 @@
public static final String NODE
= "int";
public static final String NODE_ITERATOR
- = "org.apache.xalan.xsltc.NodeIterator";
+ = "org.apache.xml.dtm.DTMAxisIterator"; //xalan.xsltc.NodeIterator";
public static final String SORT_ITERATOR
= "org.apache.xalan.xsltc.dom.SortingIterator";
public static final String SORT_ITERATOR_SIG
@@ -213,6 +217,8 @@
= "()" + NODE_SIG;
public static final String NEXT
= "next";
+ public static final String NEXTID
+ = "nextNodeID";
public static final String MAKE_NODE
= "makeNode";
public static final String MAKE_NODE_LIST
@@ -263,7 +269,9 @@
public static final String DOM_INTF
= "org.apache.xalan.xsltc.DOM";
public static final String DOM_IMPL
- = "org.apache.xalan.xsltc.dom.DOMImpl";
+ = "org.apache.xalan.xsltc.dom.SAXImpl";
+ public static final String SAX_IMPL
+ = "org.apache.xalan.xsltc.dom.SAXImpl";
public static final String STRING_CLASS
= "java.lang.String";
public static final String OBJECT_CLASS
1.10.6.1 +7 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CopyOf.java
Index: CopyOf.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CopyOf.java,v
retrieving revision 1.10
retrieving revision 1.10.6.1
diff -u -r1.10 -r1.10.6.1
--- CopyOf.java 1 Feb 2002 20:07:08 -0000 1.10
+++ CopyOf.java 17 Apr 2002 18:13:41 -0000 1.10.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: CopyOf.java,v 1.10 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: CopyOf.java,v 1.10.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -115,6 +115,10 @@
final String CPY2_SIG = "("+NODE_SIG+TRANSLET_OUTPUT_SIG+")V";
final int cpy2 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY2_SIG);
+
+ final String getDoc_SIG = "()"+NODE_SIG;
+ final int getDoc = cpg.addInterfaceMethodref(DOM_INTF, "getDocument",
getDoc_SIG);
+
if (tselect instanceof NodeSetType) {
il.append(methodGen.loadDOM());
@@ -136,7 +140,8 @@
else if (tselect instanceof ResultTreeType) {
_select.translate(classGen, methodGen);
// We want the whole tree, so we start with the root node
- il.append(ICONST_1);
+ il.append(DUP); //need a pointer to the DOM ;
+ il.append(new INVOKEINTERFACE(getDoc,1)); //ICONST_0);
il.append(methodGen.loadHandler());
il.append(new INVOKEINTERFACE(cpy2, 3));
}
1.12.6.1 +21 -4
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/DocumentCall.java
Index: DocumentCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/DocumentCall.java,v
retrieving revision 1.12
retrieving revision 1.12.6.1
diff -u -r1.12 -r1.12.6.1
--- DocumentCall.java 1 Feb 2002 20:07:08 -0000 1.12
+++ DocumentCall.java 17 Apr 2002 18:13:41 -0000 1.12.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DocumentCall.java,v 1.12 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: DocumentCall.java,v 1.12.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -159,15 +159,32 @@
_uri.startResetIterator(classGen, methodGen);
// The base of the URI may be given as a second argument (a node-set)
- il.append(methodGen.loadDOM());
+ //il.append(methodGen.loadDOM());
if (_base != null) {
+ il.append(methodGen.loadDOM());
_base.translate(classGen, methodGen);
il.append(new INVOKEINTERFACE(nextIdx, 1));
+ il.append(new INVOKEINTERFACE(uriIdx, 2));
}
else {
- il.append(methodGen.loadContextNode());
+ //TODO: (MM) Need someone to double check me on this
+ // but I think this code was wrong because it would
+ // resolve document() relative to the input xml
+ // rather than relative to the input xsl when there
+ // is no second argument!!!
+ // The context node here would be at runtime in the xml
+ // I think the reason this worked was because if the
+ // xml fails, then the xsl is tried in the current code.
+ //il.append(methodGen.loadContextNode());
+ // Instead just pass in the current stylesheet
+ // I think this get the stylesheet associated with the
+ // context node, but...
+ if (_uriType == Type.NodeSet)
+ il.append(new PUSH(cpg,""));
+ else
+ il.append(new PUSH(cpg, getStylesheet().getSystemId()));
}
- il.append(new INVOKEINTERFACE(uriIdx, 2));
+ //il.append(new INVOKEINTERFACE(uriIdx, 2));
il.append(new PUSH(cpg, getStylesheet().getSystemId()));
// Feck the rest of the parameters on the stack
1.12.6.1 +2 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForEach.java
Index: ForEach.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForEach.java,v
retrieving revision 1.12
retrieving revision 1.12.6.1
diff -u -r1.12 -r1.12.6.1
--- ForEach.java 1 Feb 2002 20:07:08 -0000 1.12
+++ ForEach.java 17 Apr 2002 18:13:41 -0000 1.12.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ForEach.java,v 1.12 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: ForEach.java,v 1.12.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -182,7 +182,7 @@
il.append(methodGen.nextNode());
il.append(DUP);
il.append(methodGen.storeCurrentNode());
- il.append(new IFNE(loop));
+ il.append(new IFGT(loop));
// Restore current DOM (if result tree was used instead for this loop)
if ((_type != null) && (_type instanceof ResultTreeType)) {
1.6.6.1 +18 -1
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/IdKeyPattern.java
Index: IdKeyPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/IdKeyPattern.java,v
retrieving revision 1.6
retrieving revision 1.6.6.1
diff -u -r1.6 -r1.6.6.1
--- IdKeyPattern.java 1 Feb 2002 20:07:08 -0000 1.6
+++ IdKeyPattern.java 17 Apr 2002 18:13:41 -0000 1.6.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: IdKeyPattern.java,v 1.6 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: IdKeyPattern.java,v 1.6.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -127,6 +127,9 @@
final int lookupKey = cpg.addMethodref(KEY_INDEX_CLASS,
"containsKey",
"(ILjava/lang/Object;)I");
+ final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF,
+ "getNodeIdent",
+ "(I)"+NODE_SIG);
// Call getKeyIndex in AbstractTranslet with the name of the key
// to get the index for this key (which is also a node iterator).
@@ -139,9 +142,23 @@
il.append(SWAP);
il.append(new PUSH(cpg,_value));
if (this instanceof IdPattern)
+ {
+ il.append(SWAP);
+ il.append(methodGen.loadDOM());
+ il.append(SWAP);
+ il.append(new INVOKEINTERFACE(getNodeIdent, 2));
+ il.append(SWAP);
il.append(new INVOKEVIRTUAL(lookupId));
+ }
else
+ {
+ il.append(SWAP);
+ il.append(methodGen.loadDOM());
+ il.append(SWAP);
+ il.append(new INVOKEINTERFACE(getNodeIdent, 2));
+ il.append(SWAP);
il.append(new INVOKEVIRTUAL(lookupKey));
+ }
_trueList.add(il.append(new IFNE(null)));
_falseList.add(il.append(new GOTO(null)));
1.14.6.1 +8 -4
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Import.java
Index: Import.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Import.java,v
retrieving revision 1.14
retrieving revision 1.14.6.1
diff -u -r1.14 -r1.14.6.1
--- Import.java 1 Feb 2002 20:07:08 -0000 1.14
+++ Import.java 17 Apr 2002 18:13:41 -0000 1.14.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Import.java,v 1.14 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: Import.java,v 1.14.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -107,10 +107,14 @@
input = loader.loadSource(docToLoad, currLoadedDoc, xsltc);
}
else {
- File file = new File(currLoadedDoc);
- if (file.exists()) currLoadedDoc = "file:"+currLoadedDoc;
- final URL url = new URL(new URL(currLoadedDoc), docToLoad);
+ File file = new File(docToLoad);
+ if (file.exists())
+ docToLoad = "file:///"+docToLoad;
+ else
+ {
+ final URL url = new URL(new URL(currLoadedDoc), docToLoad);
docToLoad = url.toString();
+ }
input = new InputSource(docToLoad);
}
1.10.6.1 +53 -5
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Key.java
Index: Key.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Key.java,v
retrieving revision 1.10
retrieving revision 1.10.6.1
diff -u -r1.10 -r1.10.6.1
--- Key.java 1 Feb 2002 20:07:08 -0000 1.10
+++ Key.java 17 Apr 2002 18:13:41 -0000 1.10.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Key.java,v 1.10 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: Key.java,v 1.10.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -165,6 +165,16 @@
final int getNodeValue = cpg.addInterfaceMethodref(DOM_INTF,
"getNodeValue",
"(I)"+STRING_SIG);
+
+ final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF,
+ "getNodeIdent",
+ "(I)"+NODE_SIG);
+
+ // AbstractTranslet.SetKeyIndexDom(name, Dom) => void
+ final int keyDom = cpg.addMethodref(TRANSLET_CLASS,
+ "setKeyIndexDom",
+ "("+STRING_SIG+DOM_INTF_SIG+")V");
+
// This variable holds the id of the node we found with the "match"
// attribute of xsl:key. This is the id we store, with the value we
@@ -175,6 +185,10 @@
il.getEnd(), null);
// Get the 'parameter' from the stack and store it in a local var.
+ il.append(new ISTORE(parentNode.getIndex()));
+ il.append(methodGen.loadDOM());
+ il.append(new ILOAD(parentNode.getIndex()));
+ il.append(new INVOKEINTERFACE(getNodeIdent, 2));
il.append(new ISTORE(parentNode.getIndex()));
// Save current node and current iterator on the stack
@@ -197,17 +211,22 @@
// Now get the node value and feck it on the parameter stack
il.append(methodGen.loadDOM());
il.append(methodGen.loadCurrentNode());
- il.append(new INVOKEINTERFACE(getNodeValue, 2));
+ il.append(new INVOKEINTERFACE(getNodeValue, 2));
// Finally do the call to add an entry in the index for this key.
il.append(new INVOKEVIRTUAL(buildKeyIndex));
+
+ il.append(classGen.loadTranslet());
+ il.append(new PUSH(cpg, getName()));
+ il.append(methodGen.loadDOM());
+ il.append(new INVOKEVIRTUAL(keyDom));
nextNode.setTarget(il.append(methodGen.loadIterator()));
- il.append(methodGen.nextNode());
+ il.append(methodGen.nextNode());
il.append(DUP);
il.append(methodGen.storeCurrentNode());
- il.append(new IFNE(loop)); // Go on to next matching node....
+ il.append(new IFGE(loop)); // Go on to next matching node....
// Restore current node and current iterator from the stack
il.append(methodGen.storeIterator());
@@ -230,6 +249,15 @@
final int key = cpg.addMethodref(TRANSLET_CLASS,
"buildKeyIndex",
"("+STRING_SIG+"I"+OBJECT_SIG+")V");
+
+ // AbstractTranslet.SetKeyIndexDom(name, Dom) => void
+ final int keyDom = cpg.addMethodref(TRANSLET_CLASS,
+ "setKeyIndexDom",
+ "("+STRING_SIG+DOM_INTF_SIG+")V");
+
+ final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF,
+ "getNodeIdent",
+ "(I)"+NODE_SIG);
// DOM.getAxisIterator(root) => NodeIterator
final int git = cpg.addInterfaceMethodref(DOM_INTF,
@@ -265,21 +293,41 @@
final int dbl = cpg.addMethodref(DOUBLE_CLASS,"<init>", "(D)V");
il.append(classGen.loadTranslet());
+ il.append(DUP);
il.append(new PUSH(cpg, _name.toString()));
+ il.append(DUP_X1);
il.append(methodGen.loadCurrentNode());
il.append(new NEW(cpg.addClass(DOUBLE_CLASS)));
il.append(DUP);
_use.translate(classGen,methodGen);
il.append(new INVOKESPECIAL(dbl));
+ il.append(SWAP);
+ il.append(methodGen.loadDOM());
+ il.append(SWAP);
+ il.append(new INVOKEINTERFACE(getNodeIdent, 2));
+ il.append(SWAP);
il.append(new INVOKEVIRTUAL(key));
+
+ il.append(methodGen.loadDOM());
+ il.append(new INVOKEVIRTUAL(keyDom));
}
else if (_useType instanceof StringType) {
il.append(classGen.loadTranslet());
+ il.append(DUP);
il.append(new PUSH(cpg, _name.toString()));
+ il.append(DUP_X1);
il.append(methodGen.loadCurrentNode());
_use.translate(classGen,methodGen);
+ il.append(SWAP);
+ il.append(methodGen.loadDOM());
+ il.append(SWAP);
+ il.append(new INVOKEINTERFACE(getNodeIdent, 2));
+ il.append(SWAP);
il.append(new INVOKEVIRTUAL(key));
+
+ il.append(methodGen.loadDOM());
+ il.append(new INVOKEVIRTUAL(keyDom));
}
// If this is a node-set we must go through each node in the set
// and create one entry in the key index for each node in the set.
@@ -296,7 +344,7 @@
il.append(methodGen.nextNode());
il.append(DUP);
il.append(methodGen.storeCurrentNode());
- il.append(new IFNE(loop));
+ il.append(new IFGT(loop));
// Restore current node and current iterator from the stack
il.append(methodGen.storeIterator());
1.7.6.1 +18 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/KeyCall.java
Index: KeyCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/KeyCall.java,v
retrieving revision 1.7
retrieving revision 1.7.6.1
diff -u -r1.7 -r1.7.6.1
--- KeyCall.java 1 Feb 2002 20:07:08 -0000 1.7
+++ KeyCall.java 17 Apr 2002 18:13:41 -0000 1.7.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: KeyCall.java,v 1.7 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: KeyCall.java,v 1.7.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -157,16 +157,22 @@
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
+
+ final int getNodeHandle = cpg.addInterfaceMethodref(DOM_INTF,
+ "getNodeHandle",
+ "(I)"+NODE_SIG);
// Wrap the KeyIndex (iterator) inside a duplicate filter iterator
// to pre-read the indexed nodes and cache them.
final int dupInit = cpg.addMethodref(DUP_FILTERED_ITERATOR,
"<init>",
"("+NODE_ITERATOR_SIG+")V");
- il.append(new NEW(cpg.addClass(DUP_FILTERED_ITERATOR)));
+
+ il.append(new NEW(cpg.addClass(DUP_FILTERED_ITERATOR)));
il.append(DUP);
translateCall(classGen, methodGen);
il.append(new INVOKESPECIAL(dupInit));
+
}
/**
@@ -208,6 +214,12 @@
final int indexConstructor = cpg.addMethodref(TRANSLET_CLASS,
"createKeyIndex",
"()"+KEY_INDEX_SIG);
+
+ // KeyIndex.setDom(Dom) => void
+ final int keyDom = cpg.addMethodref(XSLT_PACKAGE + ".dom.KeyIndex",
+ "setDom",
+ "("+DOM_INTF_SIG+")V");
+
// This local variable holds the index/iterator we will return
final LocalVariableGen returnIndex =
@@ -237,6 +249,9 @@
// Create the KeyIndex object (the iterator) we'll return
il.append(classGen.loadTranslet());
il.append(new INVOKEVIRTUAL(indexConstructor));
+ il.append(DUP);
+ il.append(methodGen.loadDOM());
+ il.append(new INVOKEVIRTUAL(keyDom));
il.append(new ASTORE(returnIndex.getIndex()));
// Initialise the index specified in the first parameter of key()
@@ -278,7 +293,7 @@
il.append(methodGen.nextNode());
il.append(DUP);
il.append(methodGen.storeCurrentNode());
- il.append(new IFNE(loop));
+ il.append(new IFGT(loop));
// LOOP ENDS HERE
1.7.6.1 +6 -4
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LastCall.java
Index: LastCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LastCall.java,v
retrieving revision 1.7
retrieving revision 1.7.6.1
diff -u -r1.7 -r1.7.6.1
--- LastCall.java 1 Feb 2002 20:07:08 -0000 1.7
+++ LastCall.java 17 Apr 2002 18:13:41 -0000 1.7.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: LastCall.java,v 1.7 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: LastCall.java,v 1.7.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -69,6 +69,8 @@
import org.apache.xalan.xsltc.DOM;
import org.apache.xalan.xsltc.dom.Axis;
+import org.apache.xml.dtm.DTM;
+
final class LastCall extends FunctionCall {
private int _type = -1;
@@ -103,7 +105,7 @@
if (getParent().getParent() instanceof Predicate) {
Predicate pred = (Predicate)getParent().getParent();
_type = pred.getPosType();
- if ((_type==DOM.ELEMENT) || (_type==DOM.ATTRIBUTE)) _type = -1;
+ if ((_type==DTM.ELEMENT_NODE) || (_type==DTM.ATTRIBUTE_NODE))
_type = -1;
}
}
@@ -111,7 +113,7 @@
// current node's children and not the last in the current iterator.
if (getParent() instanceof Predicate) {
_type = ((Predicate)getParent()).getPosType();
- if ((_type==DOM.ELEMENT) || (_type==DOM.ATTRIBUTE)) _type = -1;
+ if ((_type==DTM.ELEMENT_NODE) || (_type==DTM.ATTRIBUTE_NODE)) _type
= -1;
if (getParent().getParent() instanceof Step) {
lastChild = true;
}
@@ -137,7 +139,7 @@
if (lastChild) {
il.append(methodGen.loadDOM());
il.append(new PUSH(cpg, Axis.CHILD));
- il.append(new PUSH(cpg, DOM.ELEMENT));
+ il.append(new PUSH(cpg, DTM.ELEMENT_NODE));
il.append(new INVOKEINTERFACE(git, 3));
il.append(methodGen.loadCurrentNode());
il.append(new INVOKEINTERFACE(start, 2));
1.19.6.1 +101 -49
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java
Index: Mode.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java,v
retrieving revision 1.19
retrieving revision 1.19.6.1
diff -u -r1.19 -r1.19.6.1
--- Mode.java 1 Feb 2002 20:07:08 -0000 1.19
+++ Mode.java 17 Apr 2002 18:13:41 -0000 1.19.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Mode.java,v 1.19 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: Mode.java,v 1.19.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -76,6 +76,8 @@
import org.apache.xalan.xsltc.compiler.util.*;
import org.apache.xalan.xsltc.DOM;
+import org.apache.xml.dtm.DTM;
+
/**
* Mode gathers all the templates belonging to a given mode; it is
responsible
* for generating an appropriate applyTemplates + (mode name) function
@@ -321,7 +323,7 @@
*/
private void prepareTestSequences() {
final Vector names = _stylesheet.getXSLTC().getNamesIndex();
- _testSeq = new TestSeq[DOM.NTYPES + names.size()];
+ _testSeq = new TestSeq[DTM.NTYPES + names.size()];
final int n = _patternGroups.length;
for (int i = 0; i < n; i++) {
@@ -527,9 +529,9 @@
}
// Add test sequences for known namespace types
- for (int i = DOM.NTYPES; i < (DOM.NTYPES+namesCount); i++) {
+ for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
- String name = (String)names.elementAt(i-DOM.NTYPES);
+ String name = (String)names.elementAt(i-DTM.NTYPES);
String namespace = name.substring(0,name.lastIndexOf(':'));
final int type = xsltc.registerNamespace(namespace);
@@ -596,6 +598,8 @@
argTypes[0] = Util.getJCRefType(DOM_INTF_SIG);
argTypes[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
argTypes[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
+
+ System.out.println("arg " + argTypes[1]);
final String[] argNames = new String[3];
argNames[0] = DOCUMENT_PNAME;
@@ -633,7 +637,7 @@
// The body of this code can get very large - large than can be handled
// by a single IFNE(body.getStart()) instruction - need workaround:
- final BranchHandle ifeq = ilLoop.append(new IFEQ(null));
+ final BranchHandle ifeq = ilLoop.append(new IFLT(null));
final BranchHandle loop = ilLoop.append(new GOTO_W(null));
ifeq.setTarget(ilLoop.append(RETURN)); // applyTemplates() ends here!
final InstructionHandle ihLoop = ilLoop.getStart();
@@ -649,28 +653,28 @@
InstructionHandle ihText = ilText.getStart();
// Distinguish attribute/element/namespace tests for further processing
- final int[] types = new int[DOM.NTYPES + names.size()];
+ final int[] types = new int[DTM.NTYPES + names.size()];
for (int i = 0; i < types.length; i++) types[i] = i;
final boolean[] isAttribute = new boolean[types.length];
final boolean[] isNamespace = new boolean[types.length];
for (int i = 0; i < names.size(); i++) {
final String name = (String)names.elementAt(i);
- isAttribute[i+DOM.NTYPES] = isAttributeName(name);
- isNamespace[i+DOM.NTYPES] = isNamespaceName(name);
+ isAttribute[i+DTM.NTYPES] = isAttributeName(name);
+ isNamespace[i+DTM.NTYPES] = isNamespaceName(name);
}
// (*) Compile all templates - regardless of pattern type
compileTemplates(classGen, methodGen, ihLoop);
// (*) Handle template with explicit "*" pattern
- final TestSeq elemTest = _testSeq[DOM.ELEMENT];
+ final TestSeq elemTest = _testSeq[DTM.ELEMENT_NODE];
InstructionHandle ihElem = ihRecurse;
if (elemTest != null)
ihElem = elemTest.compile(classGen, methodGen, ihRecurse);
// (*) Handle template with explicit "@*" pattern
- final TestSeq attrTest = _testSeq[DOM.ATTRIBUTE];
+ final TestSeq attrTest = _testSeq[DTM.ATTRIBUTE_NODE];
InstructionHandle ihAttr = ihText;
if (attrTest != null)
ihAttr = attrTest.compile(classGen, methodGen, ihAttr);
@@ -719,7 +723,7 @@
// (*) Handle templates with "ns:elem" or "ns:@attr" pattern
final InstructionHandle[] targets = new InstructionHandle[types.length];
- for (int i = DOM.NTYPES; i < targets.length; i++) {
+ for (int i = DTM.NTYPES; i < targets.length; i++) {
final TestSeq testSeq = _testSeq[i];
// Jump straight to namespace tests ?
if (isNamespace[i]) {
@@ -743,43 +747,67 @@
}
// Handle pattern with match on root node - default: traverse children
- targets[DOM.ROOT] = _rootPattern != null
+ targets[DTM.ROOT_NODE] = _rootPattern != null
? getTemplateInstructionHandle(_rootPattern.getTemplate())
: ihRecurse;
-
+
+ // Handle pattern with match on root node - default: traverse
children
+ targets[DTM.DOCUMENT_NODE] = _rootPattern != null
+ ? getTemplateInstructionHandle(_rootPattern.getTemplate())
+ : ihRecurse;
+
// Handle any pattern with match on text nodes - default: output text
- targets[DOM.TEXT] = _testSeq[DOM.TEXT] != null
- ? _testSeq[DOM.TEXT].compile(classGen, methodGen, ihText)
+ targets[DTM.TEXT_NODE] = _testSeq[DTM.TEXT_NODE] != null
+ ? _testSeq[DTM.TEXT_NODE].compile(classGen, methodGen, ihText)
: ihText;
// This DOM-type is not in use - default: process next node
- targets[DOM.NAMESPACE] = ihLoop;
+ targets[DTM.NAMESPACE_NODE] = ihLoop;
// Match unknown element in DOM - default: check for namespace match
- targets[DOM.ELEMENT] = elemNamespaceHandle;
+ targets[DTM.ELEMENT_NODE] = elemNamespaceHandle;
// Match unknown attribute in DOM - default: check for namespace match
- targets[DOM.ATTRIBUTE] = attrNamespaceHandle;
+ targets[DTM.ATTRIBUTE_NODE] = attrNamespaceHandle;
// Match on processing instruction - default: process next node
InstructionHandle ihPI = ihLoop;
if (_nodeTestSeq != null) ihPI = ihElem;
- if (_testSeq[DOM.PROCESSING_INSTRUCTION] != null)
- targets[DOM.PROCESSING_INSTRUCTION] =
- _testSeq[DOM.PROCESSING_INSTRUCTION].
+ if (_testSeq[DTM.PROCESSING_INSTRUCTION_NODE] != null)
+ targets[DTM.PROCESSING_INSTRUCTION_NODE] =
+ _testSeq[DTM.PROCESSING_INSTRUCTION_NODE].
compile(classGen, methodGen, ihPI);
else
- targets[DOM.PROCESSING_INSTRUCTION] = ihPI;
+ targets[DTM.PROCESSING_INSTRUCTION_NODE] = ihPI;
// Match on comments - default: process next node
InstructionHandle ihComment = ihLoop;
if (_nodeTestSeq != null) ihComment = ihElem;
- targets[DOM.COMMENT] = _testSeq[DOM.COMMENT] != null
- ? _testSeq[DOM.COMMENT].compile(classGen, methodGen, ihComment)
+ targets[DTM.COMMENT_NODE] = _testSeq[DTM.COMMENT_NODE] != null
+ ? _testSeq[DTM.COMMENT_NODE].compile(classGen, methodGen, ihComment)
: ihComment;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.CDATA_SECTION_NODE] = ihLoop;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.DOCUMENT_FRAGMENT_NODE] = ihLoop;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.DOCUMENT_TYPE_NODE] = ihLoop;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.ENTITY_NODE] = ihLoop;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.ENTITY_REFERENCE_NODE] = ihLoop;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.NOTATION_NODE] = ihLoop;
+
// Now compile test sequences for various match patterns:
- for (int i = DOM.NTYPES; i < targets.length; i++) {
+ for (int i = DTM.NTYPES; i < targets.length; i++) {
final TestSeq testSeq = _testSeq[i];
// Jump straight to namespace tests ?
if ((testSeq == null) || (isNamespace[i])) {
@@ -958,34 +986,34 @@
// The body of this code can get very large - large than can be handled
// by a single IFNE(body.getStart()) instruction - need workaround:
- final BranchHandle ifeq = ilLoop.append(new IFEQ(null));
+ final BranchHandle ifeq = ilLoop.append(new IFLT(null));
final BranchHandle loop = ilLoop.append(new GOTO_W(null));
ifeq.setTarget(ilLoop.append(RETURN)); // applyTemplates() ends here!
final InstructionHandle ihLoop = ilLoop.getStart();
// Distinguish attribute/element/namespace tests for further processing
- final int[] types = new int[DOM.NTYPES + names.size()];
+ final int[] types = new int[DTM.NTYPES + names.size()];
for (int i = 0; i < types.length; i++) types[i] = i;
final boolean[] isAttribute = new boolean[types.length];
final boolean[] isNamespace = new boolean[types.length];
for (int i = 0; i < names.size(); i++) {
final String name = (String)names.elementAt(i);
- isAttribute[i+DOM.NTYPES] = isAttributeName(name);
- isNamespace[i+DOM.NTYPES] = isNamespaceName(name);
+ isAttribute[i+DTM.NTYPES] = isAttributeName(name);
+ isNamespace[i+DTM.NTYPES] = isNamespaceName(name);
}
// (*) Compile all templates - regardless of pattern type
compileTemplateCalls(classGen, methodGen, ihLoop, min, max);
// (*) Handle template with explicit "*" pattern
- final TestSeq elemTest = _testSeq[DOM.ELEMENT];
+ final TestSeq elemTest = _testSeq[DTM.ELEMENT_NODE];
InstructionHandle ihElem = ihLoop;
if (elemTest != null)
ihElem = elemTest.compile(classGen, methodGen, ihLoop);
// (*) Handle template with explicit "@*" pattern
- final TestSeq attrTest = _testSeq[DOM.ATTRIBUTE];
+ final TestSeq attrTest = _testSeq[DTM.ATTRIBUTE_NODE];
InstructionHandle ihAttr = ihLoop;
if (attrTest != null)
ihAttr = attrTest.compile(classGen, methodGen, ihAttr);
@@ -1035,7 +1063,7 @@
// (*) Handle templates with "ns:elem" or "ns:@attr" pattern
final InstructionHandle[] targets = new InstructionHandle[types.length];
- for (int i = DOM.NTYPES; i < targets.length; i++) {
+ for (int i = DTM.NTYPES; i < targets.length; i++) {
final TestSeq testSeq = _testSeq[i];
// Jump straight to namespace tests ?
if (isNamespace[i]) {
@@ -1059,43 +1087,67 @@
}
// Handle pattern with match on root node - default: loop
- targets[DOM.ROOT] = _rootPattern != null
+ targets[DTM.ROOT_NODE] = _rootPattern != null
? getTemplateInstructionHandle(_rootPattern.getTemplate())
: ihLoop;
+ // Handle pattern with match on root node - default: loop
+ targets[DTM.DOCUMENT_NODE] = _rootPattern != null
+ ? getTemplateInstructionHandle(_rootPattern.getTemplate())
+ : ihLoop;
// Handle any pattern with match on text nodes - default: loop
- targets[DOM.TEXT] = _testSeq[DOM.TEXT] != null
- ? _testSeq[DOM.TEXT].compile(classGen, methodGen, ihText)
+ targets[DTM.TEXT_NODE] = _testSeq[DTM.TEXT_NODE] != null
+ ? _testSeq[DTM.TEXT_NODE].compile(classGen, methodGen, ihText)
: ihText;
// This DOM-type is not in use - default: process next node
- targets[DOM.NAMESPACE] = ihLoop;
+ targets[DTM.NAMESPACE_NODE] = ihLoop;
// Match unknown element in DOM - default: check for namespace match
- targets[DOM.ELEMENT] = elemNamespaceHandle;
+ targets[DTM.ELEMENT_NODE] = elemNamespaceHandle;
// Match unknown attribute in DOM - default: check for namespace match
- targets[DOM.ATTRIBUTE] = attrNamespaceHandle;
+ targets[DTM.ATTRIBUTE_NODE] = attrNamespaceHandle;
// Match on processing instruction - default: loop
InstructionHandle ihPI = ihLoop;
if (_nodeTestSeq != null) ihPI = ihElem;
- if (_testSeq[DOM.PROCESSING_INSTRUCTION] != null)
- targets[DOM.PROCESSING_INSTRUCTION] =
- _testSeq[DOM.PROCESSING_INSTRUCTION].
+ if (_testSeq[DTM.PROCESSING_INSTRUCTION_NODE] != null)
+ targets[DTM.PROCESSING_INSTRUCTION_NODE] =
+ _testSeq[DTM.PROCESSING_INSTRUCTION_NODE].
compile(classGen, methodGen, ihPI);
else
- targets[DOM.PROCESSING_INSTRUCTION] = ihPI;
+ targets[DTM.PROCESSING_INSTRUCTION_NODE] = ihPI;
// Match on comments - default: process next node
InstructionHandle ihComment = ihLoop;
if (_nodeTestSeq != null) ihComment = ihElem;
- targets[DOM.COMMENT] = _testSeq[DOM.COMMENT] != null
- ? _testSeq[DOM.COMMENT].compile(classGen, methodGen, ihComment)
+ targets[DTM.COMMENT_NODE] = _testSeq[DTM.COMMENT_NODE] != null
+ ? _testSeq[DTM.COMMENT_NODE].compile(classGen, methodGen, ihComment)
: ihComment;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.CDATA_SECTION_NODE] = ihLoop;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.DOCUMENT_FRAGMENT_NODE] = ihLoop;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.DOCUMENT_TYPE_NODE] = ihLoop;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.ENTITY_NODE] = ihLoop;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.ENTITY_REFERENCE_NODE] = ihLoop;
+
+ // This DOM-type is not in use - default: process next node
+ targets[DTM.NOTATION_NODE] = ihLoop;
+
+
// Now compile test sequences for various match patterns:
- for (int i = DOM.NTYPES; i < targets.length; i++) {
+ for (int i = DTM.NTYPES; i < targets.length; i++) {
final TestSeq testSeq = _testSeq[i];
// Jump straight to namespace tests ?
if ((testSeq == null) || (isNamespace[i])) {
@@ -1159,8 +1211,8 @@
* Peephole optimization: Remove sequences of [ALOAD, POP].
*/
private void peepHoleOptimization(MethodGenerator methodGen) {
- InstructionList il = methodGen.getInstructionList();
- InstructionFinder find = new InstructionFinder(il);
+ InstructionList il = methodGen.getInstructionList();
+ InstructionFinder find = new InstructionFinder(il);
InstructionHandle ih;
String pattern;
@@ -1198,7 +1250,7 @@
// TODO: move target down into the list
}
}
-
+
// Replace sequences of ALOAD_1, ALOAD_1 with ALOAD_1, DUP
pattern = "`ALOAD_1'`ALOAD_1'`Instruction'";
for(Iterator iter=find.search(pattern); iter.hasNext();){
@@ -1215,7 +1267,7 @@
// TODO: move target down into the list
}
}
-
+
}
public InstructionHandle getTemplateInstructionHandle(Template template)
{
1.6.6.1 +5 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NameBase.java
Index: NameBase.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NameBase.java,v
retrieving revision 1.6
retrieving revision 1.6.6.1
diff -u -r1.6 -r1.6.6.1
--- NameBase.java 1 Feb 2002 20:07:08 -0000 1.6
+++ NameBase.java 17 Apr 2002 18:13:41 -0000 1.6.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NameBase.java,v 1.6 2002/02/01 20:07:08 tmiller Exp $
+ * @(#)$Id: NameBase.java,v 1.6.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -148,8 +148,10 @@
(BASIS_LIBRARY_CLASS,
"referenceToNodeSet",
"(Ljava/lang/Object;)" +
- "Lorg/apache/xalan/xsltc/" +
- "NodeIterator;")));
+ "Lorg/apache/xml/dtm/ref/" +
+ "DTMAxisIterator;")));
+ //"Lorg/apache/xalan/xsltc/" +
+ //"NodeIterator;")));
il.append(methodGen.nextNode());
}
// Function was called with node-set parameter
1.1.14.1 +10 -8
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NodeTest.java
Index: NodeTest.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NodeTest.java,v
retrieving revision 1.1
retrieving revision 1.1.14.1
diff -u -r1.1 -r1.1.14.1
--- NodeTest.java 17 Apr 2001 18:51:38 -0000 1.1
+++ NodeTest.java 17 Apr 2002 18:13:41 -0000 1.1.14.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NodeTest.java,v 1.1 2001/04/17 18:51:38 sboag Exp $
+ * @(#)$Id: NodeTest.java,v 1.1.14.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -65,16 +65,18 @@
import org.apache.xalan.xsltc.DOM;
+import org.apache.xml.dtm.DTM;
+
public interface NodeTest {
- public static final int TEXT = DOM.TEXT;
- public static final int COMMENT = DOM.COMMENT;
- public static final int PI = DOM.PROCESSING_INSTRUCTION;
- public static final int ROOT = DOM.ROOT;
- public static final int ELEMENT = DOM.ELEMENT;
- public static final int ATTRIBUTE = DOM.ATTRIBUTE;
+ public static final int TEXT = DTM.TEXT_NODE;
+ public static final int COMMENT = DTM.COMMENT_NODE;
+ public static final int PI = DTM.PROCESSING_INSTRUCTION_NODE;
+ public static final int ROOT = DTM.DOCUMENT_NODE;
+ public static final int ELEMENT = DTM.ELEMENT_NODE;
+ public static final int ATTRIBUTE = DTM.ATTRIBUTE_NODE;
// generalized type
- public static final int GTYPE = DOM.NTYPES;
+ public static final int GTYPE = DTM.NTYPES;
public static final int ANODE = DOM.FIRST_TYPE - 1;
}
1.16.2.1 +4 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java
Index: ParentLocationPath.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -r1.16 -r1.16.2.1
--- ParentLocationPath.java 14 Mar 2002 20:17:21 -0000 1.16
+++ ParentLocationPath.java 17 Apr 2002 18:13:41 -0000 1.16.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ParentLocationPath.java,v 1.16 2002/03/14 20:17:21 tmiller Exp $
+ * @(#)$Id: ParentLocationPath.java,v 1.16.2.1 2002/04/17 18:13:41 mmidy Exp
$
*
* The Apache Software License, Version 1.1
*
@@ -69,6 +69,8 @@
import org.apache.bcel.generic.*;
import org.apache.xalan.xsltc.compiler.util.*;
+import org.apache.xml.dtm.DTM;
+
final class ParentLocationPath extends RelativeLocationPath {
private Expression _step;
private final RelativeLocationPath _path;
@@ -184,7 +186,7 @@
// one attribute that matches the left step.
if (_path instanceof Step) {
int type = ((Step)_path).getNodeType();
- if (type == DOM.ATTRIBUTE) return true;
+ if (type == DTM.ATTRIBUTE_NODE) return true;
}
}
1.39.2.1 +2 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java
Index: Parser.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java,v
retrieving revision 1.39
retrieving revision 1.39.2.1
diff -u -r1.39 -r1.39.2.1
--- Parser.java 2 Apr 2002 19:01:37 -0000 1.39
+++ Parser.java 17 Apr 2002 18:13:41 -0000 1.39.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Parser.java,v 1.39 2002/04/02 19:01:37 santiagopg Exp $
+ * @(#)$Id: Parser.java,v 1.39.2.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -1013,7 +1013,7 @@
* Common error/warning message handler
*/
public void reportError(final int category, final ErrorMsg error) {
- switch (category) {
+ switch (category) {
case Constants.INTERNAL:
// Unexpected internal errors, such as null-ptr exceptions, etc.
// Immediately terminates compilation, no translet produced
1.2.6.1 +5 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ProcessingInstructionPattern.java
Index: ProcessingInstructionPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ProcessingInstructionPattern.java,v
retrieving revision 1.2
retrieving revision 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- ProcessingInstructionPattern.java 1 Feb 2002 20:07:09 -0000 1.2
+++ ProcessingInstructionPattern.java 17 Apr 2002 18:13:41 -0000 1.2.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ProcessingInstructionPattern.java,v 1.2 2002/02/01 20:07:09
tmiller Exp $
+ * @(#)$Id: ProcessingInstructionPattern.java,v 1.2.6.1 2002/04/17 18:13:41
mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -70,6 +70,8 @@
import org.apache.xalan.xsltc.DOM;
import org.apache.xalan.xsltc.dom.Axis;
+import org.apache.xml.dtm.DTM;
+
final class ProcessingInstructionPattern extends StepPattern {
private String _name = null;
@@ -79,7 +81,7 @@
* Handles calls with no parameter (current node is implicit parameter).
*/
public ProcessingInstructionPattern(String name) {
- super(Axis.CHILD, DOM.PROCESSING_INSTRUCTION, null);
+ super(Axis.CHILD, DTM.PROCESSING_INSTRUCTION_NODE, null);
_name = name;
//if (_name.equals("*")) _typeChecked = true; no wildcard allowed!
}
@@ -140,7 +142,7 @@
il.append(methodGen.loadDOM());
il.append(methodGen.loadCurrentNode());
il.append(new INVOKEINTERFACE(getType, 2));
- il.append(new PUSH(cpg, DOM.PROCESSING_INSTRUCTION));
+ il.append(new PUSH(cpg, DTM.PROCESSING_INSTRUCTION_NODE));
_falseList.add(il.append(new IF_ICMPEQ(null)));
}
1.30.2.1 +16 -13
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java
Index: Step.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java,v
retrieving revision 1.30
retrieving revision 1.30.2.1
diff -u -r1.30 -r1.30.2.1
--- Step.java 11 Mar 2002 22:34:01 -0000 1.30
+++ Step.java 17 Apr 2002 18:13:41 -0000 1.30.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Step.java,v 1.30 2002/03/11 22:34:01 amiro Exp $
+ * @(#)$Id: Step.java,v 1.30.2.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -72,6 +72,8 @@
import org.apache.xalan.xsltc.dom.Axis;
import org.apache.xalan.xsltc.DOM;
+import org.apache.xml.dtm.DTM;
+
final class Step extends RelativeLocationPath {
// This step's axis as defined in class Axis.
@@ -261,26 +263,27 @@
// Do not reverse nodes if we have a parent step that will reverse
// the nodes for us.
- if (hasParentPattern()) return false;
- if (hasPredicates()) return false;
- if (_hadPredicates) return false;
+ // if (hasParentPattern()) return false;
+ if (hasPredicates()) return true; //false;
+ if (_hadPredicates) return true; //false;
// Check if this step occured under an <xsl:apply-templates> element
SyntaxTreeNode parent = this;
- do {
+ // do {
// Get the next ancestor element and check its type
parent = parent.getParent();
// Order node set if descendant of these elements:
- if (parent instanceof ApplyImports) return true;
- if (parent instanceof ApplyTemplates) return true;
- if (parent instanceof ForEach) return true;
- if (parent instanceof FilterParentPath) return true;
+ if (parent instanceof ApplyImports) return false; //true;
+ if (parent instanceof ApplyTemplates) return false; //true;
+ if (parent instanceof ForEach) return false; //true;
+ if (parent instanceof FilterExpr/*FilterParentPath*/) return
false; //true;
// No not order node set if descendant of these elements:
- if (parent instanceof ValueOf) return false;
+ //if (parent instanceof ValueOf) return false;
- } while (parent != null);
+ // } while (parent != null);
+ return true;
}
return false;
}
@@ -371,8 +374,8 @@
String name = null;
int star = 0;
- if (_nodeType >= DOM.NTYPES) {
- name = (String)ni.elementAt(_nodeType-DOM.NTYPES);
+ if (_nodeType >= DTM.NTYPES) {
+ name = (String)ni.elementAt(_nodeType-DTM.NTYPES);
star = name.lastIndexOf('*');
}
1.14.2.1 +6 -4
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java
Index: StepPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- StepPattern.java 11 Mar 2002 22:27:01 -0000 1.14
+++ StepPattern.java 17 Apr 2002 18:13:41 -0000 1.14.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: StepPattern.java,v 1.14 2002/03/11 22:27:01 amiro Exp $
+ * @(#)$Id: StepPattern.java,v 1.14.2.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -71,6 +71,8 @@
import org.apache.bcel.generic.*;
import org.apache.bcel.classfile.Field;
+import org.apache.xml.dtm.DTM;
+
import org.apache.xalan.xsltc.compiler.util.*;
class StepPattern extends RelativePathPattern {
@@ -218,7 +220,7 @@
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- if (_nodeType == DOM.ELEMENT) {
+ if (_nodeType == DTM.ELEMENT_NODE) {
final int check = cpg.addInterfaceMethodref(DOM_INTF,
"isElement", "(I)Z");
il.append(methodGen.loadDOM());
@@ -230,7 +232,7 @@
_falseList.add(il.append(new GOTO_W(null)));
icmp.setTarget(il.append(NOP));
}
- else if (_nodeType == DOM.ATTRIBUTE) {
+ else if (_nodeType == DTM.ATTRIBUTE_NODE) {
final int check = cpg.addInterfaceMethodref(DOM_INTF,
"isAttribute", "(I)Z");
il.append(methodGen.loadDOM());
@@ -451,7 +453,7 @@
begin = il.append(methodGen.nextNode());
il.append(DUP);
il.append(new ISTORE(node2.getIndex()));
- _falseList.add(il.append(new IFEQ(null))); // NodeIterator.END
+ _falseList.add(il.append(new IFLT(null))); // NodeIterator.END
il.append(new ILOAD(node2.getIndex()));
il.append(new ILOAD(node.getIndex()));
1.37.2.1 +21 -16
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
Index: Stylesheet.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java,v
retrieving revision 1.37
retrieving revision 1.37.2.1
diff -u -r1.37 -r1.37.2.1
--- Stylesheet.java 2 Apr 2002 19:01:37 -0000 1.37
+++ Stylesheet.java 17 Apr 2002 18:13:41 -0000 1.37.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Stylesheet.java,v 1.37 2002/04/02 19:01:37 santiagopg Exp $
+ * @(#)$Id: Stylesheet.java,v 1.37.2.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -89,6 +89,8 @@
import org.apache.xalan.xsltc.DOM;
+import org.apache.xml.dtm.DTM;
+
public final class Stylesheet extends SyntaxTreeNode {
private String _version;
@@ -644,7 +646,7 @@
"setFilter",
"(Lorg/apache/xalan/xsltc/StripFilter;)V");
- il.append(new PUSH(cpg, DOM.ROOTNODE));
+ il.append(new PUSH(cpg, DTM.ROOT_NODE));
il.append(new ISTORE(current.getIndex()));
// Resolve any forward referenes and translate global variables/params
@@ -868,7 +870,7 @@
il.append(new PUTFIELD(domField));
// continue with globals initialization
- il.append(new PUSH(cpg, DOM.ROOTNODE));
+ il.append(new PUSH(cpg, DTM.ROOT_NODE));
il.append(new ISTORE(current.getIndex()));
// Transfer the output settings to the output post-processor
@@ -879,19 +881,7 @@
"("+OUTPUT_HANDLER_SIG+")V");
il.append(new INVOKEVIRTUAL(index));
- // Compile buildKeys -- TODO: omit if not needed
- final String keySig = compileBuildKeys(classGen);
- final int keyIdx = cpg.addMethodref(getClassName(),
- "buildKeys", keySig);
- il.append(classGen.loadTranslet()); // The 'this' pointer
- il.append(classGen.loadTranslet());
- il.append(new GETFIELD(domField)); // The DOM reference
- il.append(transf.loadIterator()); // Not really used, but...
- il.append(transf.loadHandler()); // The output handler
- il.append(new PUSH(cpg, DOM.ROOTNODE)); // Start with the root node
- il.append(new INVOKEVIRTUAL(keyIdx));
-
- // Look for top-level elements that need handling
+ // Look for top-level elements that need handling
final Enumeration toplevel = elements();
if ((_globals.size() > 0) || (toplevel.hasMoreElements())) {
// Compile method for handling top-level elements
@@ -909,6 +899,21 @@
il.append(new INVOKEVIRTUAL(topLevelIdx));
}
+ // Compile buildKeys -- TODO: omit if not needed
+
+ final String keySig = compileBuildKeys(classGen);
+ final int keyIdx = cpg.addMethodref(getClassName(),
+ "buildKeys", keySig);
+ il.append(classGen.loadTranslet()); // The 'this' pointer
+ il.append(classGen.loadTranslet());
+ il.append(new GETFIELD(domField)); // The DOM reference
+ il.append(transf.loadIterator()); // Not really used, but...
+ il.append(transf.loadHandler()); // The output handler
+ il.append(new PUSH(cpg, DTM.ROOT_NODE)); // Start with the root node
+ il.append(new INVOKEVIRTUAL(keyIdx));
+
+
+
// start document
il.append(transf.loadHandler());
il.append(transf.startDocument());
1.19.2.1 +17 -9
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java
Index: SyntaxTreeNode.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -u -r1.19 -r1.19.2.1
--- SyntaxTreeNode.java 2 Apr 2002 19:01:37 -0000 1.19
+++ SyntaxTreeNode.java 17 Apr 2002 18:13:41 -0000 1.19.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: SyntaxTreeNode.java,v 1.19 2002/04/02 19:01:37 santiagopg Exp $
+ * @(#)$Id: SyntaxTreeNode.java,v 1.19.2.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -563,19 +563,27 @@
final String DOM_CLASS = classGen.getDOMClass();
// Create new instance of DOM class (with 64 nodes)
- int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
- il.append(new NEW(cpg.addClass(DOM_IMPL)));
- il.append(DUP);
+ //int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
+ //il.append(new NEW(cpg.addClass(DOM_IMPL)));
+
+ il.append(methodGen.loadDOM());
+ int index = cpg.addInterfaceMethodref(DOM_INTF,
+ "getResultTreeFrag",
+ "()" + DOM_INTF_SIG);
+ il.append(new INVOKEINTERFACE(index,1));
+
+
il.append(DUP);
- il.append(new PUSH(cpg, 64));
- il.append(new INVOKESPECIAL(index));
+ //il.append(DUP);
+ //il.append(new PUSH(cpg, 64));
+ //il.append(new INVOKESPECIAL(index));
// Overwrite old handler with DOM handler
- index = cpg.addMethodref(DOM_IMPL,
+ index = cpg.addInterfaceMethodref(DOM_INTF,
"getOutputDomBuilder",
"()" + TRANSLET_OUTPUT_SIG);
- il.append(new INVOKEVIRTUAL(index));
+ il.append(new INVOKEINTERFACE(index,1));
il.append(DUP);
il.append(methodGen.storeHandler());
@@ -594,7 +602,7 @@
// new org.apache.xalan.xsltc.dom.DOMAdapter(DOMImpl,String[]);
index = cpg.addMethodref(DOM_ADAPTER_CLASS,
"<init>",
- "("+DOM_IMPL_SIG+
+ "("+DOM_INTF_SIG+
"["+STRING_SIG+
"["+STRING_SIG+")V");
il.append(new NEW(cpg.addClass(DOM_ADAPTER_CLASS)));
1.6.6.1 +4 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnionPathExpr.java
Index: UnionPathExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnionPathExpr.java,v
retrieving revision 1.6
retrieving revision 1.6.6.1
diff -u -r1.6 -r1.6.6.1
--- UnionPathExpr.java 1 Feb 2002 20:07:09 -0000 1.6
+++ UnionPathExpr.java 17 Apr 2002 18:13:41 -0000 1.6.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: UnionPathExpr.java,v 1.6 2002/02/01 20:07:09 tmiller Exp $
+ * @(#)$Id: UnionPathExpr.java,v 1.6.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -73,6 +73,8 @@
import org.apache.bcel.generic.*;
import org.apache.xalan.xsltc.compiler.util.*;
+import org.apache.xml.dtm.DTM;
+
final class UnionPathExpr extends Expression {
private final Expression _pathExpr;
@@ -102,7 +104,7 @@
final int axis = step.getAxis();
final int type = step.getNodeType();
// Put attribute iterators first
- if ((axis == Axis.ATTRIBUTE) || (type == DOM.ATTRIBUTE)) {
+ if ((axis == Axis.ATTRIBUTE) || (type == DTM.ATTRIBUTE_NODE)) {
_components[i] = _components[0];
_components[0] = step;
}
1.35.6.1 +5 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java
Index: XSLTC.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java,v
retrieving revision 1.35
retrieving revision 1.35.6.1
diff -u -r1.35 -r1.35.6.1
--- XSLTC.java 1 Feb 2002 20:07:09 -0000 1.35
+++ XSLTC.java 17 Apr 2002 18:13:41 -0000 1.35.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: XSLTC.java,v 1.35 2002/02/01 20:07:09 tmiller Exp $
+ * @(#)$Id: XSLTC.java,v 1.35.6.1 2002/04/17 18:13:41 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -89,6 +89,8 @@
import org.apache.xalan.xsltc.DOM;
import org.apache.bcel.classfile.JavaClass;
+import org.apache.xml.dtm.DTM;
+
public final class XSLTC {
// A reference to the main stylesheet parser object.
@@ -175,7 +177,7 @@
* Initializes the compiler to produce a new translet
*/
private void reset() {
- _nextGType = DOM.NTYPES;
+ _nextGType = DTM.NTYPES;
_elements = new Hashtable();
_attributes = new Hashtable();
_namespaces = new Hashtable();
@@ -322,7 +324,7 @@
}
}
catch (Exception e) {
- if (_debug) e.printStackTrace();
+ /*if (_debug)*/ e.printStackTrace();
_parser.reportError(Constants.FATAL, new ErrorMsg(e.getMessage()));
}
catch (Error e) {
No revision
No revision
1.8.6.1 +10 -1
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/MethodGenerator.java
Index: MethodGenerator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/MethodGenerator.java,v
retrieving revision 1.8
retrieving revision 1.8.6.1
diff -u -r1.8 -r1.8.6.1
--- MethodGenerator.java 1 Feb 2002 20:27:46 -0000 1.8
+++ MethodGenerator.java 17 Apr 2002 18:13:43 -0000 1.8.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: MethodGenerator.java,v 1.8 2002/02/01 20:27:46 tmiller Exp $
+ * @(#)$Id: MethodGenerator.java,v 1.8.6.1 2002/04/17 18:13:43 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -66,6 +66,7 @@
import org.apache.bcel.generic.Type;
import org.apache.bcel.generic.*;
import org.apache.xalan.xsltc.compiler.Template;
+import org.apache.xalan.xsltc.dom.SAXImpl;
public class MethodGenerator extends MethodGen
implements org.apache.xalan.xsltc.compiler.Constants {
@@ -101,6 +102,7 @@
private final Instruction _setStartNode;
private final Instruction _reset;
private final Instruction _nextNode;
+ private final Instruction _nextNodeId;
private SlotAllocator _slotAllocator;
@@ -171,6 +173,9 @@
index = cpg.addInterfaceMethodref(NODE_ITERATOR, NEXT, NEXT_SIG);
_nextNode = new INVOKEINTERFACE(index, 1);
+ index =
cpg.addInterfaceMethodref("org.apache.xalan.xsltc.dom.SAXImpl$SingletonNodeIDIterator",
NEXTID, NEXT_SIG);
+ _nextNodeId = new INVOKEINTERFACE(index, 1);
+
_slotAllocator = new SlotAllocator();
_slotAllocator.initialize(getLocalVariables());
}
@@ -228,6 +233,10 @@
public final Instruction nextNode() {
return _nextNode;
+ }
+
+ public final Instruction nextNodeId() {
+ return _nextNodeId;
}
public final Instruction startElement() {
1.9.6.1 +3 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeSetType.java
Index: NodeSetType.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeSetType.java,v
retrieving revision 1.9
retrieving revision 1.9.6.1
diff -u -r1.9 -r1.9.6.1
--- NodeSetType.java 1 Feb 2002 20:08:11 -0000 1.9
+++ NodeSetType.java 17 Apr 2002 18:13:43 -0000 1.9.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NodeSetType.java,v 1.9 2002/02/01 20:08:11 tmiller Exp $
+ * @(#)$Id: NodeSetType.java,v 1.9.6.1 2002/04/17 18:13:43 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -149,7 +149,7 @@
final InstructionList il = methodGen.getInstructionList();
getFirstNode(classGen, methodGen);
il.append(DUP);
- final BranchHandle falsec = il.append(new IFEQ(null));
+ final BranchHandle falsec = il.append(new IFLT(null));
Type.Node.translateTo(classGen, methodGen, type);
final BranchHandle truec = il.append(new GOTO(null));
falsec.setTarget(il.append(POP));
@@ -191,7 +191,7 @@
BooleanType type) {
final InstructionList il = methodGen.getInstructionList();
getFirstNode(classGen, methodGen);
- return new FlowList(il.append(new IFEQ(null)));
+ return new FlowList(il.append(new IFLT(null)));
}
/**
1.10.6.1 +23 -11
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java
Index: ResultTreeType.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java,v
retrieving revision 1.10
retrieving revision 1.10.6.1
diff -u -r1.10 -r1.10.6.1
--- ResultTreeType.java 1 Feb 2002 20:08:11 -0000 1.10
+++ ResultTreeType.java 17 Apr 2002 18:13:43 -0000 1.10.6.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ResultTreeType.java,v 1.10 2002/02/01 20:08:11 tmiller Exp $
+ * @(#)$Id: ResultTreeType.java,v 1.10.6.1 2002/04/17 18:13:43 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -72,6 +72,8 @@
import org.apache.xalan.xsltc.compiler.FlowList;
import org.apache.xalan.xsltc.compiler.Constants;
+import org.apache.xml.dtm.DTM;
+
public final class ResultTreeType extends Type {
private final String _methodName;
@@ -265,12 +267,17 @@
il.append(methodGen.loadDOM());
// Create new instance of DOM class (with 64 nodes)
- int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
- il.append(new NEW(cpg.addClass(DOM_IMPL)));
- il.append(DUP);
+ il.append(methodGen.loadDOM());
+ int index = cpg.addInterfaceMethodref(DOM_INTF,
+ "getResultTreeFrag",
+ "()" + DOM_INTF_SIG);
+ il.append(new INVOKEINTERFACE(index,1));
+ // int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
+ // il.append(new NEW(cpg.addClass(DOM_IMPL)));
+ // il.append(DUP);
il.append(DUP);
- il.append(new PUSH(cpg, 64));
- il.append(new INVOKESPECIAL(index));
+ // il.append(new PUSH(cpg, 64));
+ // il.append(new INVOKESPECIAL(index));
// Store new DOM into a local variable
newDom = methodGen.addLocalVariable("rt_to_reference_dom",
@@ -280,10 +287,15 @@
il.append(new ASTORE(newDom.getIndex()));
// Overwrite old handler with DOM handler
- index = cpg.addMethodref(DOM_IMPL,
- "getOutputDomBuilder",
- "()" + TRANSLET_OUTPUT_SIG);
- il.append(new INVOKEVIRTUAL(index));
+ index = cpg.addInterfaceMethodref(DOM_INTF,
+ "getOutputDomBuilder",
+ "()" + TRANSLET_OUTPUT_SIG);
+
+ il.append(new INVOKEINTERFACE(index,1));
+ //index = cpg.addMethodref(DOM_IMPL,
+ // "getOutputDomBuilder",
+ // "()" + TRANSLET_OUTPUT_SIG);
+ //il.append(new INVOKEVIRTUAL(index));
il.append(DUP);
il.append(DUP);
@@ -363,7 +375,7 @@
final int iter = cpg.addInterfaceMethodref(DOM_INTF,
"getChildren",
"(I)"+NODE_ITERATOR_SIG);
- il.append(new PUSH(cpg, DOM.ROOTNODE));
+ il.append(new PUSH(cpg, DTM.ROOT_NODE));
il.append(new INVOKEINTERFACE(iter, 2));
}
No revision
No revision
1.6.10.1 +12 -9
xml-xalan/java/src/org/apache/xalan/xsltc/dom/AbsoluteIterator.java
Index: AbsoluteIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/AbsoluteIterator.java,v
retrieving revision 1.6
retrieving revision 1.6.10.1
diff -u -r1.6 -r1.6.10.1
--- AbsoluteIterator.java 4 Dec 2001 10:30:07 -0000 1.6
+++ AbsoluteIterator.java 17 Apr 2002 18:13:43 -0000 1.6.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AbsoluteIterator.java,v 1.6 2001/12/04 10:30:07 morten Exp $
+ * @(#)$Id: AbsoluteIterator.java,v 1.6.10.1 2002/04/17 18:13:43 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -66,11 +66,14 @@
import org.apache.xalan.xsltc.DOM;
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMDefaultBase;
-public final class AbsoluteIterator extends NodeIteratorBase {
- private NodeIterator _source;
+public final class AbsoluteIterator extends DTMAxisIteratorBase {
+ private DTMAxisIterator _source;
- public AbsoluteIterator(NodeIterator source) {
+ public AbsoluteIterator(DTMAxisIterator source) {
_source = source;
}
@@ -83,16 +86,16 @@
_source.setRestartable(isRestartable);
}
- public NodeIterator setStartNode(int node) {
- _startNode = DOM.ROOTNODE;
+ public DTMAxisIterator setStartNode(int node) {
+ _startNode = DTMDefaultBase.ROOTNODE;
if (_isRestartable) {
resetPosition();
- return _source.setStartNode(_startNode = DOM.ROOTNODE);
+ return _source.setStartNode(_startNode = DTMDefaultBase.ROOTNODE);
}
return reset();
}
- public NodeIterator cloneIterator() {
+ public DTMAxisIterator cloneIterator() {
try {
final AbsoluteIterator clone = (AbsoluteIterator)super.clone();
clone.setRestartable(false);
@@ -106,7 +109,7 @@
}
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
_source.reset();
return resetPosition();
}
1.1.14.1 +18 -9
xml-xalan/java/src/org/apache/xalan/xsltc/dom/AnyNodeCounter.java
Index: AnyNodeCounter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/AnyNodeCounter.java,v
retrieving revision 1.1
retrieving revision 1.1.14.1
diff -u -r1.1 -r1.1.14.1
--- AnyNodeCounter.java 17 Apr 2001 18:52:26 -0000 1.1
+++ AnyNodeCounter.java 17 Apr 2002 18:13:43 -0000 1.1.14.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AnyNodeCounter.java,v 1.1 2001/04/17 18:52:26 sboag Exp $
+ * @(#)$Id: AnyNodeCounter.java,v 1.1.14.1 2002/04/17 18:13:43 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -67,9 +67,12 @@
import org.apache.xalan.xsltc.Translet;
import org.apache.xalan.xsltc.NodeIterator;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMDefaultBase;
+
public abstract class AnyNodeCounter extends NodeCounter {
public AnyNodeCounter(Translet translet,
- DOM document, NodeIterator iterator) {
+ DOM document, DTMAxisIterator iterator) {
super(translet, document, iterator);
}
@@ -85,13 +88,16 @@
result = _value;
}
else {
- int next = _node;
+ int next = _node;
result = 0;
- while (next >= 0 && !matchesFrom(next)) {
+ while (next >=0 && !matchesFrom(next)) {
if (matchesCount(next)) {
++result;
}
- --next;
+ if (_document.getNodeIdent(next) == DTMDefaultBase.ROOTNODE)
+ break;
+ else
+ --next;
}
}
return formatNumbers(result);
@@ -99,13 +105,13 @@
public static NodeCounter getDefaultNodeCounter(Translet translet,
DOM document,
- NodeIterator iterator) {
+ DTMAxisIterator iterator) {
return new DefaultAnyNodeCounter(translet, document, iterator);
}
static class DefaultAnyNodeCounter extends AnyNodeCounter {
public DefaultAnyNodeCounter(Translet translet,
- DOM document, NodeIterator iterator) {
+ DOM document, DTMAxisIterator iterator) {
super(translet, document, iterator);
}
@@ -117,12 +123,15 @@
else {
int next = _node;
result = 0;
- final int ntype = _document.getType(_node);
+ final int ntype = _document.getType(_node);
while (next >= 0) {
if (ntype == _document.getType(next)) {
result++;
}
- next--;
+ if (_document.getNodeIdent(next) == DTMDefaultBase.ROOTNODE)
+ break;
+ else
+ --next;
}
}
return formatNumbers(result);
1.3.10.1 +5 -3 xml-xalan/java/src/org/apache/xalan/xsltc/dom/Axis.java
Index: Axis.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Axis.java,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -r1.3 -r1.3.10.1
--- Axis.java 8 Nov 2001 12:59:42 -0000 1.3
+++ Axis.java 17 Apr 2002 18:13:43 -0000 1.3.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Axis.java,v 1.3 2001/11/08 12:59:42 morten Exp $
+ * @(#)$Id: Axis.java,v 1.3.10.1 2002/04/17 18:13:43 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -69,8 +69,9 @@
* org.apache.xml.dtm.Axis (very similar)
*/
-public interface Axis {
-
+public interface Axis extends org.apache.xml.dtm.Axis
+{
+/*
public static final int ANCESTOR = 0;
public static final int ANCESTORORSELF = 1;
public static final int ATTRIBUTE = 2;
@@ -102,6 +103,7 @@
"preceding-sibling",
"self"
};
+ */
public static final boolean[] isReverse = {
true, // ancestor
1.3.10.1 +3 -2
xml-xalan/java/src/org/apache/xalan/xsltc/dom/BitArray.java
Index: BitArray.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/BitArray.java,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -r1.3 -r1.3.10.1
--- BitArray.java 5 Oct 2001 06:26:50 -0000 1.3
+++ BitArray.java 17 Apr 2002 18:13:43 -0000 1.3.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: BitArray.java,v 1.3 2001/10/05 06:26:50 morten Exp $
+ * @(#)$Id: BitArray.java,v 1.3.10.1 2002/04/17 18:13:43 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -69,6 +69,7 @@
import org.apache.xalan.xsltc.DOM;
import org.apache.xalan.xsltc.NodeIterator;
+import org.apache.xml.dtm.DTMAxisIterator;
public class BitArray implements Externalizable {
@@ -151,7 +152,7 @@
}
startBit = 0;
}
- return(NodeIterator.END);
+ return(DTMAxisIterator.END);
}
/**
1.1.14.1 +3 -2
xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListFilter.java
Index: CurrentNodeListFilter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListFilter.java,v
retrieving revision 1.1
retrieving revision 1.1.14.1
diff -u -r1.1 -r1.1.14.1
--- CurrentNodeListFilter.java 17 Apr 2001 18:52:27 -0000 1.1
+++ CurrentNodeListFilter.java 17 Apr 2002 18:13:43 -0000 1.1.14.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: CurrentNodeListFilter.java,v 1.1 2001/04/17 18:52:27 sboag Exp $
+ * @(#)$Id: CurrentNodeListFilter.java,v 1.1.14.1 2002/04/17 18:13:43 mmidy
Exp $
*
* The Apache Software License, Version 1.1
*
@@ -66,8 +66,9 @@
import org.apache.xalan.xsltc.*;
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
+import org.apache.xml.dtm.DTMAxisIterator;
public interface CurrentNodeListFilter {
public abstract boolean test(int node, int position, int last, int
current,
- AbstractTranslet translet, NodeIterator iter);
+ AbstractTranslet translet, DTMAxisIterator
iter);
}
1.6.2.1 +17 -9
xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListIterator.java
Index: CurrentNodeListIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListIterator.java,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- CurrentNodeListIterator.java 11 Mar 2002 22:31:32 -0000 1.6
+++ CurrentNodeListIterator.java 17 Apr 2002 18:13:43 -0000 1.6.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: CurrentNodeListIterator.java,v 1.6 2002/03/11 22:31:32 amiro Exp
$
+ * @(#)$Id: CurrentNodeListIterator.java,v 1.6.2.1 2002/04/17 18:13:43 mmidy
Exp $
*
* The Apache Software License, Version 1.1
*
@@ -69,8 +69,11 @@
import org.apache.xalan.xsltc.util.IntegerArray;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
-public final class CurrentNodeListIterator extends NodeIteratorBase {
- private NodeIterator _source;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+import org.apache.xml.dtm.DTMAxisIterator;
+
+public final class CurrentNodeListIterator extends DTMAxisIteratorBase {
+ private DTMAxisIterator _source;
private boolean _docOrder;
private final CurrentNodeListFilter _filter;
private IntegerArray _nodes = new IntegerArray();
@@ -81,14 +84,14 @@
private final int _currentNode;
private int _last;
- public CurrentNodeListIterator(NodeIterator source,
+ public CurrentNodeListIterator(DTMAxisIterator source,
CurrentNodeListFilter filter,
int currentNode,
AbstractTranslet translet) {
this(source, !source.isReverse(), filter, currentNode, translet);
}
- public CurrentNodeListIterator(NodeIterator source, boolean docOrder,
+ public CurrentNodeListIterator(DTMAxisIterator source, boolean docOrder,
CurrentNodeListFilter filter,
int currentNode,
AbstractTranslet translet) {
@@ -99,6 +102,11 @@
_currentNode = currentNode;
}
+ public DTMAxisIterator forceNaturalOrder() {
+ _docOrder = true;
+ return this;
+ }
+
public void setRestartable(boolean isRestartable) {
_isRestartable = isRestartable;
_source.setRestartable(isRestartable);
@@ -108,7 +116,7 @@
return !_docOrder;
}
- public NodeIterator cloneIterator() {
+ public DTMAxisIterator cloneIterator() {
try {
final CurrentNodeListIterator clone =
(CurrentNodeListIterator)super.clone();
@@ -123,7 +131,7 @@
}
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
_current = 0;
return resetPosition();
}
@@ -158,8 +166,8 @@
return lastPosition;
}
- public NodeIterator setStartNode(int node) {
- NodeIterator retval = this;
+ public DTMAxisIterator setStartNode(int node) {
+ DTMAxisIterator retval = this;
if (_isRestartable) {
// iterator is not a clone
1.11.10.1 +271 -127
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java
Index: DOMAdapter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java,v
retrieving revision 1.11
retrieving revision 1.11.10.1
diff -u -r1.11 -r1.11.10.1
--- DOMAdapter.java 26 Nov 2001 14:03:09 -0000 1.11
+++ DOMAdapter.java 17 Apr 2002 18:13:43 -0000 1.11.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOMAdapter.java,v 1.11 2001/11/26 14:03:09 morten Exp $
+ * @(#)$Id: DOMAdapter.java,v 1.11.10.1 2002/04/17 18:13:43 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -72,210 +72,354 @@
import org.apache.xalan.xsltc.TransletOutputHandler;
import org.apache.xalan.xsltc.TransletException;
-public final class DOMAdapter implements DOM {
- private final DOMImpl _domImpl;
+import org.apache.xml.dtm.*;
+import org.apache.xml.dtm.ref.*;
+
+public final class DOMAdapter implements DOM
+{
+ private final DOM _domImpl;
private short[] _mapping;
- private short[] _reverse;
+ private int[] _reverse;
private short[] _NSmapping;
private short[] _NSreverse;
private StripFilter _filter = null;
- public DOMAdapter(DOMImpl dom,
- String[] namesArray,
- String[] namespaceArray) {
- _domImpl = dom;
- _mapping = dom.getMapping(namesArray);
- _reverse = dom.getReverseMapping(namesArray);
- _NSmapping = dom.getNamespaceMapping(namespaceArray);
- _NSreverse = dom.getReverseNamespaceMapping(namespaceArray);
+ public DOMAdapter(DOM dom,
+ String[] namesArray,
+ String[] namespaceArray)
+ {
+ _domImpl = dom;
+ if (_domImpl instanceof DOMImpl )
+ {
+ _mapping = ((DOMImpl)dom).getMapping(namesArray);
+ _reverse = ((DOMImpl)dom).getReverseMapping(namesArray);
+ _NSmapping = ((DOMImpl)dom).getNamespaceMapping(namespaceArray);
+ _NSreverse =
((DOMImpl)dom).getReverseNamespaceMapping(namespaceArray);
+ }
+ else
+ {
+ _mapping = ((SAXImpl)dom).getMapping(namesArray);
+ _reverse = ((SAXImpl)dom).getReverseMapping(namesArray);
+ _NSmapping = ((SAXImpl)dom).getNamespaceMapping(namespaceArray);
+ _NSreverse =
((SAXImpl)dom).getReverseNamespaceMapping(namespaceArray);
+ }
+ }
+
+ public void setupMapping(String[] names, String[] namespaces)
+ {
+ if (_domImpl instanceof DOMImpl )
+ {
+ _mapping = ((DOMImpl)_domImpl).getMapping(names);
+ _reverse = ((DOMImpl)_domImpl).getReverseMapping(names);
+ _NSmapping = ((DOMImpl)_domImpl).getNamespaceMapping(namespaces);
+ _NSreverse =
((DOMImpl)_domImpl).getReverseNamespaceMapping(namespaces);
+ }
+ else
+ {
+ _mapping = ((SAXImpl)_domImpl).getMapping(names);
+ _reverse = ((SAXImpl)_domImpl).getReverseMapping(names);
+ _NSmapping = ((SAXImpl)_domImpl).getNamespaceMapping(namespaces);
+ _NSreverse =
((SAXImpl)_domImpl).getReverseNamespaceMapping(namespaces);
+ }
}
-
- public void setupMapping(String[] names, String[] namespaces) {
- _mapping = _domImpl.getMapping(names);
- _reverse = _domImpl.getReverseMapping(names);
- _NSmapping = _domImpl.getNamespaceMapping(namespaces);
- _NSreverse = _domImpl.getReverseNamespaceMapping(namespaces);
+
+
+ public DOM getDOMImpl()
+ {
+ return _domImpl;
}
/** returns singleton iterator containg the document root */
- public NodeIterator getIterator() {
- return _domImpl.getIterator();
+ public DTMAxisIterator getIterator()
+ {
+ return _domImpl.getIterator();
+ }
+
+ public String getStringValue()
+ {
+ return _domImpl.getStringValue();
+ }
+
+ public DTMAxisIterator getChildren(final int node)
+ {
+ DTMAxisIterator iterator = _domImpl.getChildren(node);
+ if (_filter == null) {
+ return(iterator.setStartNode(node));
+ }
+ else {
+ if (_domImpl instanceof DOMImpl )
+ iterator =
((DOMImpl)_domImpl).strippingIterator(iterator,_mapping,_filter);
+ else
+ iterator =
((SAXImpl)_domImpl).strippingIterator(iterator,_mapping,_filter);
+ return(iterator.setStartNode(node));
+ }
+ }
+
+ public void setFilter(StripFilter filter)
+ {
+ _filter = filter;
+ }
+
+ public DTMAxisIterator getTypedChildren(final int type)
+ {
+ DTMAxisIterator iterator = _domImpl.getTypedChildren(_reverse[type]);
+ if ((_reverse[type] == DTM.TEXT_NODE) && (_filter != null))
+ {
+ if (_domImpl instanceof DOMImpl )
+ iterator =
((DOMImpl)_domImpl).strippingIterator(iterator,_mapping,_filter);
+ else
+ iterator =
((SAXImpl)_domImpl).strippingIterator(iterator,_mapping,_filter);
+ }
+ return(iterator);
+ }
+
+ public DTMAxisIterator getNamespaceAxisIterator(final int axis, final
int ns)
+ {
+ return _domImpl.getNamespaceAxisIterator(axis,_NSreverse[ns]);
+ }
+
+ public DTMAxisIterator getAxisIterator(final int axis)
+ {
+ DTMAxisIterator iterator = _domImpl.getAxisIterator(axis);
+ if (_filter != null)
+ {
+ if (_domImpl instanceof DOMImpl )
+ iterator =
((DOMImpl)_domImpl).strippingIterator(iterator,_mapping,_filter);
+ else
+ iterator =
((SAXImpl)_domImpl).strippingIterator(iterator,_mapping,_filter);
+ }
+ return(iterator);
+ }
+
+ public DTMAxisIterator getTypedAxisIterator(final int axis, final int
type)
+ {
+ DTMAxisIterator iterator;
+
+ if (axis == Axis.NAMESPACE)
+ {
+ if ((type == NO_TYPE) || (type > _NSreverse.length))
+ iterator = _domImpl.getAxisIterator(axis);
+ else
+ iterator = _domImpl.getTypedAxisIterator(axis,_NSreverse[type]);
+ }
+ else
+ iterator = _domImpl.getTypedAxisIterator(axis, _reverse[type]);
+
+ if ((_reverse[type] == DTM.TEXT_NODE) && (_filter != null))
+ {
+ if (_domImpl instanceof DOMImpl )
+ iterator =
((DOMImpl)_domImpl).strippingIterator(iterator,_mapping,_filter);
+ else
+ iterator =
((SAXImpl)_domImpl).strippingIterator(iterator,_mapping,_filter);
+
+ }
+ return(iterator);
}
- public String getStringValue() {
- return _domImpl.getStringValue();
- }
public String getTreeString() {
return _domImpl.getTreeString();
}
- public NodeIterator getChildren(final int node) {
- NodeIterator iterator = _domImpl.getChildren(node);
- if (_filter == null) {
- return(iterator.setStartNode(node));
- }
- else {
- iterator = _domImpl.strippingIterator(iterator,_mapping,_filter);
- return(iterator.setStartNode(node));
- }
- }
- public void setFilter(StripFilter filter) {
- _filter = filter;
- }
-
- public NodeIterator getTypedChildren(final int type) {
- NodeIterator iterator = _domImpl.getTypedChildren(_reverse[type]);
- if ((_reverse[type] == DOM.TEXT) && (_filter != null))
- iterator = _domImpl.strippingIterator(iterator,_mapping,_filter);
- return(iterator);
+ public DTMAxisIterator getNthDescendant(int type, int n, boolean
includeself)
+ {
+ return _domImpl.getNthDescendant(_reverse[type], n, includeself);
}
- public NodeIterator getNamespaceAxisIterator(final int axis, final int
ns) {
- return _domImpl.getNamespaceAxisIterator(axis,_NSreverse[ns]);
+ public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iterator,
int type,
+ String value, boolean op)
+ {
+ return _domImpl.getNodeValueIterator(iterator, type, value, op);
}
- public NodeIterator getAxisIterator(final int axis) {
- NodeIterator iterator = _domImpl.getAxisIterator(axis);
- if (_filter != null)
- iterator = _domImpl.strippingIterator(iterator,_mapping,_filter);
- return(iterator);
+ public DTMAxisIterator orderNodes(DTMAxisIterator source, int node)
+ {
+ return _domImpl.orderNodes(source, node);
}
- public NodeIterator getTypedAxisIterator(final int axis, final int type)
{
- NodeIterator iterator;
-
- if (axis == Axis.NAMESPACE) {
- if ((type == NO_TYPE) || (type > _NSreverse.length))
- iterator = _domImpl.getAxisIterator(axis);
- else
- iterator = _domImpl.getTypedAxisIterator(axis,_NSreverse[type]);
- }
- else
- iterator = _domImpl.getTypedAxisIterator(axis, _reverse[type]);
-
- if ((_reverse[type] == DOM.TEXT) && (_filter != null))
- iterator = _domImpl.strippingIterator(iterator,_mapping,_filter);
- return(iterator);
- }
-
- public NodeIterator getNthDescendant(int type, int n, boolean
includeself) {
- return _domImpl.getNthDescendant(_reverse[type], n, includeself);
+ public int getType(final int node)
+ {
+ //System.out.println("<<<" +_mapping[_domImpl.getType(node)]);
+ return _mapping[_domImpl.getType(node)];
}
- public NodeIterator getNodeValueIterator(NodeIterator iterator, int type,
- String value, boolean op) {
- return _domImpl.getNodeValueIterator(iterator, type, value, op);
- }
-
- public NodeIterator orderNodes(NodeIterator source, int node) {
- return _domImpl.orderNodes(source, node);
- }
-
- public int getType(final int node) {
- return _mapping[_domImpl.getType(node)];
- }
-
- public int getNamespaceType(final int node) {
- return _NSmapping[_domImpl.getNamespaceType(node)];
+ public int getNamespaceType(final int node)
+ {
+
+ return _NSmapping[_domImpl.getNSType(node)];
+ //return _NSmapping[_domImpl.getNamespaceType(node)];
}
- public int getParent(final int node) {
- return _domImpl.getParent(node);
+ public int getNSType(int node)
+ {
+ return _domImpl.getNSType(node);
+ }
+
+ public int getParent(final int node)
+ {
+ return _domImpl.getParent(node);
}
- public int getTypedPosition(int type, int node) {
- return _domImpl.getTypedPosition(_reverse[type], node);
+ public int getTypedPosition(int type, int node)
+ {
+ return _domImpl.getTypedPosition(_reverse[type], node);
}
- public int getTypedLast(int type, int node) {
- return _domImpl.getTypedLast(_reverse[type], node);
+ public int getTypedLast(int type, int node)
+ {
+ return _domImpl.getTypedLast(_reverse[type], node);
}
- public int getAttributeNode(final int type, final int element) {
- return _domImpl.getAttributeNode(_reverse[type], element);
+ public int getAttributeNode(final int type, final int element)
+ {
+ return _domImpl.getAttributeNode(_reverse[type], element);
}
- public String getNodeName(final int node) {
- return _domImpl.getNodeName(node);
+ public String getNodeName(final int node)
+ {
+ if (node == DTM.NULL)
+ return "";
+ return _domImpl.getNodeName(node);
}
- public String getNamespaceName(final int node) {
- return _domImpl.getNamespaceName(node);
+ public String getNamespaceName(final int node)
+ {
+ if (node == DTM.NULL)
+ return "";
+ return _domImpl.getNamespaceName(node);
}
- public String getNodeValue(final int node) {
- return _domImpl.getNodeValue(node);
+ public String getNodeValue(final int node)
+ {
+ if (node == DTM.NULL)
+ return "";
+ return _domImpl.getNodeValue(node);
}
public void copy(final int node, TransletOutputHandler handler)
- throws TransletException {
+ throws TransletException
+ {
_domImpl.copy(node, handler);
}
- public void copy(NodeIterator nodes, TransletOutputHandler handler)
- throws TransletException {
+ public void copy(DTMAxisIterator nodes, TransletOutputHandler handler)
+ throws TransletException
+ {
_domImpl.copy(nodes, handler);
}
public String shallowCopy(final int node, TransletOutputHandler handler)
- throws TransletException {
+ throws TransletException
+ {
return _domImpl.shallowCopy(node, handler);
}
- public boolean lessThan(final int node1, final int node2) {
- return _domImpl.lessThan(node1, node2);
+ public boolean lessThan(final int node1, final int node2)
+ {
+ return _domImpl.lessThan(node1, node2);
}
public void characters(final int textNode, TransletOutputHandler handler)
- throws TransletException {
- _domImpl.characters(textNode, handler);
+ throws TransletException
+ {
+ _domImpl.characters(textNode, handler);
}
- public Node makeNode(int index) {
- return _domImpl.makeNode(index);
+ public Node makeNode(int index)
+ {
+ return _domImpl.makeNode(index);
}
- public Node makeNode(NodeIterator iter) {
- return _domImpl.makeNode(iter);
+ public Node makeNode(DTMAxisIterator iter)
+ {
+ return _domImpl.makeNode(iter);
}
- public NodeList makeNodeList(int index) {
- return _domImpl.makeNodeList(index);
+ public NodeList makeNodeList(int index)
+ {
+ return _domImpl.makeNodeList(index);
}
- public NodeList makeNodeList(NodeIterator iter) {
- return _domImpl.makeNodeList(iter);
+ public NodeList makeNodeList(DTMIterator iter)
+ {
+ return _domImpl.makeNodeList(iter);
}
- public String getLanguage(int node) {
- return _domImpl.getLanguage(node);
+ public String getLanguage(int node)
+ {
+ return _domImpl.getLanguage(node);
}
- public int getSize() {
- return _domImpl.getSize();
+ public int getSize()
+ {
+ return _domImpl.getSize();
}
- public void setDocumentURI(String uri) {
- _domImpl.setDocumentURI(uri);
+ public void setDocumentURI(String uri)
+ {
+ if (_domImpl instanceof DOMImpl )
+ ((DOMImpl)_domImpl).setDocumentURI(uri);
+ else
+ ((SAXImpl)_domImpl).setDocumentURI(uri);
}
- public String getDocumentURI() {
- return(_domImpl.getDocumentURI());
+ public String getDocumentURI()
+ {
+ if (_domImpl instanceof DOMImpl )
+ return(((DOMImpl)_domImpl).getDocumentURI());
+ else
+ return(((SAXImpl)_domImpl).getDocumentURI());
}
- public String getDocumentURI(int node) {
- return(_domImpl.getDocumentURI());
+ public String getDocumentURI(int node)
+ {
+ if (_domImpl instanceof DOMImpl)
+ return(((DOMImpl)_domImpl).getDocumentURI());
+ else
+ return(((SAXImpl)_domImpl).getDocumentURI());
+ }
+
+ public int getDocument()
+ {
+ return(((DTMDefaultBase)_domImpl).getDocument());
}
- public boolean isElement(final int node) {
- return(_domImpl.isElement(node));
+ public boolean isElement(final int node)
+ {
+ return(_domImpl.isElement(node));
}
- public boolean isAttribute(final int node) {
- return(_domImpl.isAttribute(node));
+ public boolean isAttribute(final int node)
+ {
+ return(_domImpl.isAttribute(node));
+ }
+
+ public int getNodeIdent(int nodeHandle)
+ {
+ return _domImpl.getNodeIdent(nodeHandle);
+ }
+
+ public int getNodeHandle(int nodeId)
+ {
+ return _domImpl.getNodeHandle(nodeId);
+ }
+
+ /**
+ * Return a instance of a DOM class to be used as an RTF
+ */
+ public DOM getResultTreeFrag()
+ {
+ return _domImpl.getResultTreeFrag();
+ }
+
+ /**
+ * Returns a DOMBuilder class wrapped in a SAX adapter.
+ */
+ public TransletOutputHandler getOutputDomBuilder()
+ {
+ return _domImpl.getOutputDomBuilder();
}
}
1.68.2.1 +1890
-1474xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
Index: DOMImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
retrieving revision 1.68
retrieving revision 1.68.2.1
diff -u -r1.68 -r1.68.2.1
--- DOMImpl.java 2 Apr 2002 19:01:38 -0000 1.68
+++ DOMImpl.java 17 Apr 2002 18:13:43 -0000 1.68.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOMImpl.java,v 1.68 2002/04/02 19:01:38 santiagopg Exp $
+ * @(#)$Id: DOMImpl.java,v 1.68.2.1 2002/04/17 18:13:43 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -88,25 +88,35 @@
import org.apache.xalan.xsltc.runtime.SAXAdapter;
import org.apache.xalan.xsltc.runtime.Hashtable;
-public final class DOMImpl implements DOM, Externalizable {
+import org.apache.xml.dtm.ref.*;
+import org.apache.xml.dtm.*;
+import org.apache.xml.dtm.ref.dom2dtm.DOM2DTM;
+import org.apache.xml.utils.XMLStringFactory;
+
+import javax.xml.transform.dom.DOMSource;
+
+public final class DOMImpl extends DOM2DTM implements DOM, Externalizable
+{
// empty String for null attribute values
private final static String EMPTYSTRING = "";
// empty iterator to be returned when there are no children
- private final static NodeIterator EMPTYITERATOR = new NodeIterator() {
- public NodeIterator reset() { return this; }
- public NodeIterator setStartNode(int node) { return this; }
- public int next() { return NULL; }
+ private final static DTMAxisIterator EMPTYITERATOR = new
DTMAxisIteratorBase() {
+ public DTMAxisIterator reset() { return this; }
+ public DTMAxisIterator setStartNode(int node) { return this; }
+ public int next() { return DTM.NULL; }
public void setMark() {}
public void gotoMark() {}
public int getLast() { return 0; }
public int getPosition() { return 0; }
- public NodeIterator cloneIterator() { return this; }
- public boolean isReverse() { return false; }
- public NodeIterator resetOnce() { return this; }
- public NodeIterator includeSelf() { return this; }
- public void setRestartable(boolean isRestartable) { }
+
+ public DTMAxisIterator cloneIterator() { return this; }
+ //public boolean isReverse() { return false; }
+ // public DTMAxisIterator resetOnce() { return this; }
+ // public DTMAxisIterator includeSelf() { return this; }
+ public void setRestartable(boolean isRestartable) { }
+
};
// Contains the number of nodes and attribute nodes in the tree
@@ -114,13 +124,13 @@
private int _firstAttributeNode;
// Node-to-type, type-to-name, and name-to-type mappings
- private short[] _type;
- private Hashtable _types = null;
+ //private short[] _type;
+ private int[] _types;
private String[] _namesArray;
// Tree navigation arrays
- private int[] _parent;
- private int[] _nextSibling;
+ //private int[] _parent;
+ // private int[] _nextSibling;
private int[] _offsetOrChild; // Serves two purposes !!!
private int[] _lengthOrAttr; // Serves two purposes !!!
@@ -129,9 +139,9 @@
// Namespace related stuff
private String[] _uriArray;
- private String[] _prefixArray;
+ private /*String[]*/ Hashtable _prefixArray;
private short[] _namespace;
- private short[] _prefix;
+ // private short[] _prefix;
private Hashtable _nsIndex = new Hashtable();
// Tracks which textnodes are whitespaces and which are not
@@ -155,46 +165,57 @@
/**
* Define the origin of the document from which the tree was built
*/
- public void setDocumentURI(String uri) {
- _documentURI = uri;
+ public void setDocumentURI(String uri)
+ {
+ setDocumentBaseURI(uri);
+ _documentURI = uri;
}
/**
* Returns the origin of the document from which the tree was built
*/
- public String getDocumentURI() {
- return(_documentURI);
+ public String getDocumentURI()
+ {
+ return getDocumentBaseURI();
+ //return(_documentURI);
}
- public String getDocumentURI(int node) {
- return(_documentURI);
+ public String getDocumentURI(int node)
+ {
+ return getDocumentBaseURI();
+ //return(_documentURI);
}
- public void setupMapping(String[] names, String[] namespaces) {
+ public void setupMapping(String[] names, String[] namespaces)
+ {
// This method only has a function in DOM adapters
}
/**
* Returns 'true' if a specific node is an element (of any type)
*/
- public boolean isElement(final int node) {
- final int type = _type[node];
- return ((node < _firstAttributeNode) && (type >= NTYPES));
+ public boolean isElement(final int node)
+ {
+ final int type = getType(node); //_type[node];
+ return (((node < _firstAttributeNode) && (type >= DTM.NTYPES)) ||
getNodeType(node) == DTM.ELEMENT_NODE);
}
/**
* Returns 'true' if a specific node is an element (of any type)
*/
- public boolean isAttribute(final int node) {
- final int type = _type[node];
- return ((node >= _firstAttributeNode) && (type >= NTYPES));
+ public boolean isAttribute(final int node)
+ {
+ final int type = getType(node); //_type[node];
+ return ((node >= _firstAttributeNode) && (type >= DTM.NTYPES));
}
/**
* Returns the number of nodes in the tree (used for indexing)
*/
- public int getSize() {
- return(_type.length);
+ public int getSize()
+ {
+ return getNumberOfNodes();
+ //return(_type.length);
}
/**
@@ -206,73 +227,96 @@
/**
* Returns true if node1 comes before node2 in document order
*/
- public boolean lessThan(int node1, int node2) {
- // Hack for ordering attribute nodes
- if (node1 >= _firstAttributeNode) node1 = _parent[node1];
- if (node2 >= _firstAttributeNode) node2 = _parent[node2];
-
- if ((node2 < _treeNodeLimit) && (node1 < node2))
- return(true);
- else
- return(false);
+ public boolean lessThan(int node1, int node2)
+ {
+ if (node1 == DTM.NULL)
+ return false;
+ if (node2 == DTM.NULL)
+ return true;
+
+ // Hack for ordering attribute nodes
+ //if (getNodeIdent(node1) >= _firstAttributeNode)
+ if (getNodeType(node1) == DTM.ATTRIBUTE_NODE) node1 = getParent(node1);
+ // if (getNodeIdent(node2) >= _firstAttributeNode)
+ if (getNodeType(node2) == DTM.ATTRIBUTE_NODE)node2 = getParent(node2);
+
+ if (/*(getNodeIdent(node2) <= _treeNodeLimit) &&*/ (node1 < node2))
+ return(true);
+ else
+ return(false);
}
/**
* Create an org.w3c.dom.Node from a node in the tree
*/
- public Node makeNode(int index) {
- if (_nodes == null) {
- _nodes = new Node[_type.length];
- }
- return _nodes[index] != null
- ? _nodes[index]
- : (_nodes[index] = new NodeImpl(index));
+ public Node makeNode(int index)
+ {
+ if (_nodes == null)
+ {
+ _nodes = new Node[_namesArray.length + DTM.NTYPES]; //_type.length];
+ }
+ return _nodes[index] != null
+ ? _nodes[index]
+ : (_nodes[index] = new DTMNodeProxy((DTM)this, index));
}
/**
* Create an org.w3c.dom.Node from a node in an iterator
* The iterator most be started before this method is called
*/
- public Node makeNode(NodeIterator iter) {
- return makeNode(iter.next());
+ public Node makeNode(DTMAxisIterator iter)
+ {
+ return makeNode(iter.next());
}
/**
* Create an org.w3c.dom.NodeList from a node in the tree
*/
- public NodeList makeNodeList(int index) {
- if (_nodeLists == null) {
- _nodeLists = new NodeList[_type.length];
- }
- return _nodeLists[index] != null
- ? _nodeLists[index]
- : (_nodeLists[index] = new NodeListImpl(index));
+ public NodeList makeNodeList(int index)
+ {
+ if (_nodeLists == null)
+ {
+ _nodeLists = new NodeList[_namesArray.length + DTM.NTYPES];
//_type.length];
+ }
+ try
+ {
+ return _nodeLists[index] != null
+ ? _nodeLists[index]
+ : (_nodeLists[index] = new DTMNodeList(new
org.apache.xpath.axes.SingletonIterator(index)));
+ }
+ catch (javax.xml.transform.TransformerException te)
+ {return null;}
}
/**
* Create an org.w3c.dom.NodeList from a node iterator
* The iterator most be started before this method is called
*/
- public NodeList makeNodeList(NodeIterator iter) {
- return new NodeListImpl(iter);
+ public NodeList makeNodeList(DTMIterator iter)
+ {
+ return new DTMNodeList(iter);
}
/**
* Create an empty org.w3c.dom.NodeList
*/
- private NodeList getEmptyNodeList() {
- return EmptyNodeList != null
- ? EmptyNodeList
- : (EmptyNodeList = new NodeListImpl(new int[0]));
+ private NodeList getEmptyNodeList()
+ {
+ return EmptyNodeList != null
+ ? EmptyNodeList
+ : (EmptyNodeList = new DTMNodeList(null));
+ //(NodeListImpl(new int[0]));
}
/**
* Create an empty org.w3c.dom.NamedNodeMap
*/
- private NamedNodeMap getEmptyNamedNodeMap() {
- return EmptyNamedNodeMap != null
- ? EmptyNamedNodeMap
- : (EmptyNamedNodeMap = new NamedNodeMapImpl(new int[0]));
+ private NamedNodeMap getEmptyNamedNodeMap()
+ {
+ return EmptyNamedNodeMap != null
+ ? EmptyNamedNodeMap
+ : (EmptyNamedNodeMap = new DTMNamedNodeMap(this, DTM.NULL));
+ //NamedNodeMapImpl(new int[0]));
}
/**
@@ -288,6 +332,7 @@
/**************************************************************
* Implementation of org.w3c.dom.NodeList
*/
+ /*
private final class NodeListImpl implements NodeList {
private final int[] _nodes;
@@ -300,10 +345,10 @@
_nodes = nodes;
}
- public NodeListImpl(NodeIterator iter) {
+ public NodeListImpl(DTMAxisIterator iter) {
final IntegerArray list = new IntegerArray();
int node;
- while ((node = iter.next()) != NodeIterator.END) {
+ while ((node = iter.next()) != DTMAxisIterator.END) {
list.add(node);
}
_nodes = list.toIntArray();
@@ -318,10 +363,11 @@
}
}
-
+ */
/**************************************************************
* Implementation of org.w3c.dom.NamedNodeMap
*/
+ /*
private final class NamedNodeMapImpl implements NamedNodeMap {
private final int[] _nodes;
@@ -368,12 +414,14 @@
}
}
-
+*/
/**************************************************************
* Implementation of org.w3c.dom.Node
*/
- private final class NodeImpl implements Node {
+ /*
+ private final class NodeImpl implements Node
+ {
private final int _index;
@@ -569,22 +617,34 @@
}
}
+ NodeImpl end */
// A single copy (cache) of ElementFilter
- private Filter _elementFilter;
+ private DTMFilter _elementFilter;
/**
* Returns a filter that lets only element nodes through
*/
- private Filter getElementFilter() {
- if (_elementFilter == null) {
- _elementFilter = new Filter() {
- public boolean test(int node) {
- return isElement(node);
- }
- };
- }
- return _elementFilter;
+ private DTMFilter getElementFilter()
+ {
+ if (_elementFilter == null)
+ {
+ _elementFilter = new DTMFilter() {
+ public short acceptNode(int node, int whatToShow)
+ {
+ short nodeType = getNodeType(node);
+ int nodebit = DTMFilter.SHOW_ELEMENT & (0x00000001 << (nodeType
-1)) ;
+ return nodebit ==0 ? DTMIterator.FILTER_REJECT :
DTMIterator.FILTER_ACCEPT;//isElement(node);
+ }
+ public short acceptNode(int node, int whatToShow, int
expandedName)
+ {
+ short nodeType = getNodeType(node);
+ int nodebit = DTMFilter.SHOW_ELEMENT & (0x00000001 << (nodeType
-1)) ;
+ return nodebit ==0 ? DTMIterator.FILTER_REJECT :
DTMIterator.FILTER_ACCEPT;//return isElement(node);
+ }
+ };
+ }
+ return _elementFilter;
}
/**
@@ -599,7 +659,7 @@
}
public boolean test(int node) {
- return _type[node] == _nodeType;
+ return getType(node) == _nodeType;
}
}
@@ -614,6 +674,7 @@
/**************************************************************
* Iterator that returns all children of a given node
*/
+ /*
private final class ChildrenIterator extends NodeIteratorBase {
// child to return next
private int _currentChild;
@@ -675,11 +736,12 @@
}
} // end of ChildrenIterator
-
+*/
/**************************************************************
* Iterator that returns the parent of a given node
*/
+ /*
private final class ParentIterator extends NodeIteratorBase {
// candidate parent node
private int _node;
@@ -716,7 +778,7 @@
_node = _markedNode;
}
} // end of ParentIterator
-
+*/
/**************************************************************
* Iterator that returns children of a given type for a given node.
@@ -724,6 +786,7 @@
* of a basic child iterator, but a specialised iterator is used
* for efficiency (both speed and size of translet).
*/
+ /*
private final class TypedChildrenIterator extends NodeIteratorBase {
private int _nodeType;
// node to consider next
@@ -786,13 +849,14 @@
}
} // end of TypedChildrenIterator
-
+*/
/**************************************************************
* Iterator that returns children within a given namespace for a
* given node. The functionality chould be achieved by putting a
* filter on top of a basic child iterator, but a specialised
* iterator is used for efficiency (both speed and size of translet).
*/
+ /*
private final class NamespaceChildrenIterator extends NodeIteratorBase {
private final int _nsType;
private int _currentChild;
@@ -832,10 +896,11 @@
} // end of TypedChildrenIterator
-
+*/
/**************************************************************
* Iterator that returns attributes within a given namespace for a node.
*/
+ /*
private final class NamespaceAttributeIterator extends NodeIteratorBase {
private final int _nsType;
@@ -882,10 +947,11 @@
} // end of TypedChildrenIterator
-
+*/
/**************************************************************
* Iterator that returns all siblings of a given node.
*/
+ /*
private class FollowingSiblingIterator extends NodeIteratorBase {
private int _node;
@@ -911,10 +977,11 @@
}
} // end of FollowingSiblingIterator
-
+*/
/**************************************************************
* Iterator that returns all following siblings of a given node.
*/
+ /*
private final class TypedFollowingSiblingIterator
extends FollowingSiblingIterator {
private final int _nodeType;
@@ -934,10 +1001,11 @@
} // end of TypedFollowingSiblingIterator
-
+*/
/**************************************************************
* Iterator that returns attribute nodes (of what nodes?)
*/
+ /*
private final class AttributeIterator extends NodeIteratorBase {
private int _attribute;
@@ -973,11 +1041,12 @@
_attribute = _markedNode;
}
} // end of AttributeIterator
-
+*/
/**************************************************************
* Iterator that returns attribute nodes of a given type
*/
+ /*
private final class TypedAttributeIterator extends NodeIteratorBase {
private final int _nodeType;
private int _attribute;
@@ -1021,11 +1090,12 @@
_attribute = _markedNode;
}
} // end of TypedAttributeIterator
-
+*/
/**************************************************************
* Iterator that returns namespace nodes
*/
+ /*
private class NamespaceIterator extends NodeIteratorBase {
protected int _node;
@@ -1078,10 +1148,11 @@
} // end of NamespaceIterator
-
+*/
/**************************************************************
* Iterator that returns namespace nodes
*/
+ /*
private final class TypedNamespaceIterator extends NamespaceIterator {
final int _uriType;
@@ -1107,12 +1178,13 @@
return DOM.NULL;
}
- } // end of AttributeIterator
-
+ } // end of TypedNamespaceIterator
+*/
/**************************************************************
* Iterator that returns preceding siblings of a given node
*/
+ /*
private class PrecedingSiblingIterator extends NodeIteratorBase {
private int _node;
@@ -1166,11 +1238,12 @@
} // end of PrecedingSiblingIterator
-
+*/
/**************************************************************
* Iterator that returns preceding siblings of a given type for
* a given node
*/
+ /*
private final class TypedPrecedingSiblingIterator
extends PrecedingSiblingIterator {
private final int _nodeType;
@@ -1186,14 +1259,15 @@
return(node);
}
- } // end of PrecedingSiblingIterator
-
+ } // end of TypedPrecedingSiblingIterator
+*/
/**************************************************************
* Iterator that returns preceding nodes of a given node.
* This includes the node set {root+1, start-1}, but excludes
* all ancestors.
*/
+ /*
private class PrecedingIterator extends NodeIteratorBase {
private int _node = 0;
@@ -1252,12 +1326,13 @@
} // end of PrecedingIterator
-
+*/
/**************************************************************
* Iterator that returns preceding nodes of agiven type for a
* given node. This includes the node set {root+1, start-1}, but
* excludes all ancestors.
*/
+ /*
private final class TypedPrecedingIterator extends PrecedingIterator {
private final int _nodeType;
@@ -1274,10 +1349,11 @@
} // end of TypedPrecedingIterator
-
+*/
/**************************************************************
* Iterator that returns following nodes of for a given node.
*/
+ /*
private class FollowingIterator extends NodeIteratorBase {
// _node precedes search for next
protected int _node;
@@ -1318,10 +1394,11 @@
}
} // end of FollowingIterator
-
+*/
/**************************************************************
* Iterator that returns following nodes of a given type for a given
node.
*/
+ /*
private final class TypedFollowingIterator extends FollowingIterator {
private final int _nodeType;
@@ -1339,13 +1416,14 @@
}
} // end of TypedFollowingIterator
-
+*/
/**************************************************************
* Iterator that returns the ancestors of a given node.
* The nodes are returned in reverse document order, so you
* get the context node (or its parent node) first, and the
* root node in the very, very end.
- */
+ */
+ /*
private class AncestorIterator extends NodeIteratorBase {
protected int _index;
@@ -1418,11 +1496,12 @@
_index = _markedNode;
}
} // end of AncestorIterator
-
+*/
/**************************************************************
* Typed iterator that returns the ancestors of a given node.
- */
+ */
+ /*
private final class TypedAncestorIterator extends AncestorIterator {
private final int _nodeType;
@@ -1453,10 +1532,11 @@
} // end of TypedAncestorIterator
-
+*/
/**************************************************************
* Iterator that returns the descendants of a given node.
- */
+ */
+ /*
private class DescendantIterator extends NodeIteratorBase {
// _node precedes search for next
protected int _node;
@@ -1501,11 +1581,12 @@
}
} // end of DescendantIterator
-
+*/
/**************************************************************
* Typed iterator that returns the descendants of a given node.
- */
+ */
+ /*
private final class TypedDescendantIterator extends DescendantIterator {
private final int _nodeType;
@@ -1527,10 +1608,11 @@
} // end of TypedDescendantIterator
-
+*/
/**************************************************************
* Iterator that returns the descendants of a given node.
- */
+ */
+ /*
private class NthDescendantIterator extends DescendantIterator {
final NodeIterator _source;
@@ -1585,10 +1667,11 @@
} // end of NthDescendantIterator
-
+*/
/**************************************************************
* Iterator that returns a given node only if it is of a given type.
- */
+ */
+ /*
private final class TypedSingletonIterator extends SingletonIterator {
private final int _nodeType;
@@ -1602,14 +1685,15 @@
}
} // end of TypedSingletonIterator
-
+*/
/**************************************************************
* Iterator to put on top of other iterators. It will take the
* nodes from the underlaying iterator and return all but
* whitespace text nodes. The iterator needs to be a supplied
* with a filter that tells it what nodes are WS text.
*/
- private final class StrippingIterator extends NodeIteratorBase {
+ private final class StrippingIterator extends InternalAxisIteratorBase
//NodeIteratorBase
+ {
private static final int USE_PREDICATE = 0;
private static final int STRIP_SPACE = 1;
@@ -1617,133 +1701,150 @@
private StripFilter _filter = null;
private short[] _mapping = null;
- private final NodeIterator _source;
+ private final DTMAxisIterator _source;
private boolean _children = false;
private int _action = USE_PREDICATE;
private int _last = -1;
- public StrippingIterator(NodeIterator source,
- short[] mapping,
- StripFilter filter) {
+ public StrippingIterator(DTMAxisIterator source,
+ short[] mapping,
+ StripFilter filter)
+ {
+
+ _filter = filter;
+ _mapping = mapping;
+ _source = source;
+
+ if (_source instanceof ChildrenIterator ||
+ _source instanceof TypedChildrenIterator)
+ {
+ _children = true;
+ }
+ }
+
+ public DTMAxisIterator setStartNode(int node)
+ {
+ if (_children)
+ {
+ if (_filter.stripSpace((DOM)DOMImpl.this, node,
+ _mapping[getType(node)]))
+ _action = STRIP_SPACE;
+ else
+ _action = PRESERVE_SPACE;
+ }
+
+ _source.setStartNode(node);
+ //return resetPosition();
+ return(this);
+ }
+
+ public int next()
+ {
+ int node;
+ while ((node = _source.next()) != END)
+ {
+ switch(_action)
+ {
+ case STRIP_SPACE:
+ if (_whitespace.getBit(getNodeIdent(node))) continue;
+ // fall through...
+ case PRESERVE_SPACE:
+ return returnNode(node);
+ case USE_PREDICATE:
+ default:
+ if (_whitespace.getBit(getNodeIdent(node)) &&
+ _filter.stripSpace((DOM)DOMImpl.this, node,
+ _mapping[getType(getParent(node))]))
+ continue;
+ return returnNode(node);
+ }
+ }
+ return END;
+ }
- _filter = filter;
- _mapping = mapping;
- _source = source;
-
- if (_source instanceof ChildrenIterator ||
- _source instanceof TypedChildrenIterator) {
- _children = true;
- }
- }
public void setRestartable(boolean isRestartable) {
_isRestartable = isRestartable;
_source.setRestartable(isRestartable);
}
+
- public NodeIterator setStartNode(int node) {
- if (_children) {
- if (_filter.stripSpace((DOM)DOMImpl.this, node,
- _mapping[_type[node]]))
- _action = STRIP_SPACE;
- else
- _action = PRESERVE_SPACE;
- }
-
- _source.setStartNode(node);
- //return resetPosition();
- return(this);
- }
-
- public int next() {
- int node;
- while ((node = _source.next()) != END) {
- switch(_action) {
- case STRIP_SPACE:
- if (_whitespace.getBit(node)) continue;
- // fall through...
- case PRESERVE_SPACE:
- return returnNode(node);
- case USE_PREDICATE:
- default:
- if (_whitespace.getBit(node) &&
- _filter.stripSpace((DOM)DOMImpl.this, node,
- _mapping[_type[_parent[node]]]))
- continue;
- return returnNode(node);
- }
- }
- return END;
- }
-
- public NodeIterator reset() {
+ public DTMAxisIterator reset()
+ {
_source.reset();
return this;
}
- public void setMark() {
+ public void setMark()
+ {
_source.setMark();
}
- public void gotoMark() {
+ public void gotoMark()
+ {
_source.gotoMark();
}
- public int getLast() {
- // Return chached value (if we have it)
- if (_last != -1) return _last;
-
- int count = getPosition();
- int node;
-
- _source.setMark();
- while ((node = _source.next()) != END) {
- switch(_action) {
- case STRIP_SPACE:
- if (_whitespace.getBit(node))
- continue;
- // fall through...
- case PRESERVE_SPACE:
- count++;
- break;
- case USE_PREDICATE:
- default:
- if (_whitespace.getBit(node) &&
- _filter.stripSpace((DOM)DOMImpl.this, node,
- _mapping[_type[_parent[node]]]))
- continue;
- else
- count++;
- }
- }
- _source.gotoMark();
- _last = count;
- return(count);
- }
-
- } // end of StrippingIterator
-
- public NodeIterator strippingIterator(NodeIterator iterator,
- short[] mapping,
- StripFilter filter) {
- return(new StrippingIterator(iterator, mapping, filter));
+ public int getLast()
+ {
+ // Return chached value (if we have it)
+ if (_last != -1) return _last;
+
+ int count = getPosition();
+ int node;
+
+ _source.setMark();
+ while ((node = _source.next()) != END)
+ {
+ switch(_action)
+ {
+ case STRIP_SPACE:
+ if (_whitespace.getBit(getNodeIdent(node)))
+ continue;
+ // fall through...
+ case PRESERVE_SPACE:
+ count++;
+ break;
+ case USE_PREDICATE:
+ default:
+ if (_whitespace.getBit(getNodeIdent(node)) &&
+ _filter.stripSpace((DOM)DOMImpl.this, node,
+ _mapping[getType(getParent(node))]))
+ continue;
+ else
+ count++;
+ }
+ }
+ _source.gotoMark();
+ _last = count;
+ return(count);
+ }
+
+} // end of StrippingIterator
+
+ public DTMAxisIterator strippingIterator(DTMAxisIterator iterator,
+ short[] mapping,
+ StripFilter filter)
+ {
+ return(new StrippingIterator(iterator, mapping, filter));
}
/**************************************************************
* This is a specialised iterator for predicates comparing node or
* attribute values to variable or parameter values.
*/
- private final class NodeValueIterator extends NodeIteratorBase {
+ private final class NodeValueIterator extends InternalAxisIteratorBase
//NodeIteratorBase
+ {
- private NodeIterator _source;
+ private DTMAxisIterator _source;
private String _value;
private boolean _op;
private final boolean _isReverse;
- private int _returnType = RETURN_PARENT;
- private int _pos;
+ private int _returnType = RETURN_PARENT;
- public NodeValueIterator(NodeIterator source, int returnType,
- String value, boolean op) {
+ public NodeValueIterator(DTMAxisIterator source, int returnType,
+ String value, boolean op)
+ {
_source = source;
_returnType = returnType;
_value = value;
@@ -1751,259 +1852,313 @@
_isReverse = source.isReverse();
}
- public boolean isReverse() {
+ public boolean isReverse()
+ {
return _isReverse;
}
+
+ public DTMAxisIterator cloneIterator()
+ {
+ try
+ {
+ NodeValueIterator clone = (NodeValueIterator)super.clone();
+ clone._isRestartable = false;
+ clone._source = _source.cloneIterator();
+ clone._value = _value;
+ clone._op = _op;
+ return clone.reset();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
+ e.toString());
+ return null;
+ }
+ }
+
public void setRestartable(boolean isRestartable) {
_isRestartable = isRestartable;
_source.setRestartable(isRestartable);
}
-
- public NodeIterator cloneIterator() {
- try {
- NodeValueIterator clone = (NodeValueIterator)super.clone();
- clone._source = _source.cloneIterator();
- clone.setRestartable(false);
- return clone.reset();
- }
- catch (CloneNotSupportedException e) {
- BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
- e.toString());
- return null;
- }
- }
- public NodeIterator reset() {
+ public DTMAxisIterator reset()
+ {
_source.reset();
return resetPosition();
}
- public int next() {
+ public int next()
+ {
- int node;
- while ((node = _source.next()) != END) {
- String val = getNodeValue(node);
- if (_value.equals(val) == _op) {
- if (_returnType == RETURN_CURRENT)
- return returnNode(node);
- else
- return returnNode(_parent[node]);
- }
- }
- return END;
- }
-
- public NodeIterator setStartNode(int node) {
- if (_isRestartable) {
- _source.setStartNode(_startNode = node);
- return resetPosition();
- }
- return this;
- }
+ int node;
+ while ((node = _source.next()) != END)
+ {
+ String val = getNodeValue(node);
+ if (_value.equals(val) == _op)
+ {
+ if (_returnType == RETURN_CURRENT)
+ return returnNode(node);
+ else
+ return returnNode(getParent(node));
+ }
+ }
+ return END;
+ }
+
+ public DTMAxisIterator setStartNode(int node)
+ {
+ if (_isRestartable)
+ {
+ _source.setStartNode(_startNode = node);
+ return resetPosition();
+ }
+ return this;
+ }
- public void setMark() {
+ public void setMark()
+ {
_source.setMark();
- _pos = _position;
}
- public void gotoMark() {
+ public void gotoMark()
+ {
_source.gotoMark();
- _position = _pos;
}
- }
+ }
+
+ // end NodeValueIterator
- public NodeIterator getNodeValueIterator(NodeIterator iterator, int type,
- String value, boolean op) {
- return(new NodeValueIterator(iterator, type, value, op));
+ public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iterator,
int type,
+ String value, boolean op)
+ {
+ return(DTMAxisIterator)(new NodeValueIterator(iterator, type,
value, op));
}
/**
* Encapsulates an iterator in an OrderedIterator to ensure node order
*/
- public NodeIterator orderNodes(NodeIterator source, int node) {
- return new DupFilterIterator(source);
+ public DTMAxisIterator orderNodes(DTMAxisIterator source, int node)
+ {
+ return new DupFilterIterator(source);
}
/**
* Returns the leftmost descendant of a node (bottom left in sub-tree)
*/
- private int leftmostDescendant(int node) {
- int current;
- while (_type[current = node] >= NTYPES
- && (node = _offsetOrChild[node]) != NULL) {
- }
- return current;
+ private int leftmostDescendant(int node)
+ {
+ int current;
+ while (getType(current = node) >= DTM.NTYPES
+ && (node = getFirstChild(node)) != DTM.NULL)
+ {
+ }
+ return current;
}
/**
* Returns index of last child or 0 if no children
+ * (returns DTM.NULL in fact)
*/
- private int lastChild(int node) {
- if (isElement(node) || node == ROOTNODE) {
- int child;
- if ((child = _offsetOrChild[node]) != NULL) {
- while ((child = _nextSibling[node = child]) != NULL) {
- }
- return node;
- }
- }
- return 0;
+ private int lastChild(int node)
+ {
+ return getLastChild(node);
}
/**
* Returns the parent of a node
- */
+ *
public int getParent(final int node) {
return _parent[node];
- }
-
- public int getElementPosition(int node) {
- // Initialize with the first sbiling of the current node
- int match = 0;
- int curr = _offsetOrChild[_parent[node]];
- if (isElement(curr)) match++;
+ } use DTM's */
- // Then traverse all other siblings up until the current node
- while (curr != node) {
- curr = _nextSibling[curr];
- if (isElement(curr)) match++;
- }
+ public int getElementPosition(int node)
+ {
+ // Initialize with the first sbiling of the current node
+ int match = 0;
+ int curr = getFirstChild(getParent(node));
+ if (isElement(curr)) match++;
+
+ // Then traverse all other siblings up until the current node
+ while (curr != node)
+ {
+ curr = getNextSibling(curr);
+ if (isElement(curr)) match++;
+ }
+
+ // And finally return number of matches
+ return match;
+ }
+
+ public int getAttributePosition(int attr)
+ {
+ // Initialize with the first sbiling of the current node
+ int match = 1;
+ int curr = getFirstChild(getParent(attr));
+
+ // Then traverse all other siblings up until the current node
+ while (curr != attr)
+ {
+ curr = getNextSibling(curr);
+ match++;
+ }
- // And finally return number of matches
- return match;
- }
-
- public int getAttributePosition(int attr) {
- // Initialize with the first sbiling of the current node
- int match = 1;
- int curr = _lengthOrAttr[_parent[attr]];
-
- // Then traverse all other siblings up until the current node
- while (curr != attr) {
- curr = _nextSibling[curr];
- match++;
- }
-
- // And finally return number of matches
- return match;
+ // And finally return number of matches
+ return match;
}
/**
* Returns a node's position amongst other nodes of the same type
*/
- public int getTypedPosition(int type, int node) {
- // Just return the basic position if no type is specified
- switch(type) {
- case ELEMENT:
- return getElementPosition(node);
- case ATTRIBUTE:
- return getAttributePosition(node);
- case -1:
- type = _type[node];
- }
-
- // Initialize with the first sbiling of the current node
- int match = 0;
- int curr = _offsetOrChild[_parent[node]];
- if (_type[curr] == type) match++;
-
- // Then traverse all other siblings up until the current node
- while (curr != node) {
- curr = _nextSibling[curr];
- if (_type[curr] == type) match++;
- }
+ public int getTypedPosition(int type, int node)
+ {
+ // Just return the basic position if no type is specified
+ switch(type)
+ {
+ case DTM.ELEMENT_NODE:
+ return getElementPosition(node);
+ case DTM.ATTRIBUTE_NODE:
+ return getAttributePosition(node);
+ case -1:
+ type = getNodeType(node);
+ }
+
+ // Initialize with the first sbiling of the current node
+ int match = 0;
+ int curr = getFirstChild(getParent(node));
+ if (getExpandedTypeID(curr) == type) match++;
+
+ // Then traverse all other siblings up until the current node
+ while (curr != node)
+ {
+ curr = getNextSibling(curr);
+ if (getExpandedTypeID(curr) == type) match++;
+ }
- // And finally return number of matches
- return match;
+ // And finally return number of matches
+ return match;
}
-
+
/**
* Returns an iterator's last node of a given type
*/
- public int getTypedLast(int type, int node) {
- // Just return the basic position if no type is specified
- if (type == -1) type = _type[node];
-
- // Initialize with the first sbiling of the current node
- int match = 0;
- int curr = _offsetOrChild[_parent[node]];
- if (_type[curr] == type) match++;
-
- // Then traverse all other siblings up until the very last one
- while (curr != NULL) {
- curr = _nextSibling[curr];
- if (_type[curr] == type) match++;
- }
+ public int getTypedLast(int type, int node)
+ {
+ // Just return the basic position if no type is specified
+ if (type == -1) type = getNodeType(node);
+
+ // Initialize with the first sbiling of the current node
+ int match = 0;
+ int curr = getFirstChild(getParent(node));
+ if (getExpandedTypeID(curr) == type) match++;
+
+ // Then traverse all other siblings up until the very last one
+ while (curr != DTM.NULL)
+ {
+ curr = getNextSibling(curr);
+ if (getExpandedTypeID(curr) == type) match++;
+ }
- return match;
+ return match;
}
/**
* Returns singleton iterator containg the document root
* Works for them main document (mark == 0)
*/
- public NodeIterator getIterator() {
- return new SingletonIterator(ROOTNODE);
+ public DTMAxisIterator getIterator()
+ {
+ return new SingletonIterator(getDocument()); //ROOTNODE);
}
/**
* Returns the type of a specific node
*/
- public int getType(final int node) {
+ public int getType(final int node)
+ {
+ return getExpandedTypeID(node);
+
+ /*
+ Integer intType = (Integer)_types.get(new Integer(type));
+ if (intType == null)
+ return getNodeType(node); // a base DTM type
+ else
+ return intType.intValue(); // a custom type
+ //return getNodeType(node);
+ /*
if (node >= _type.length)
return(0);
else
- return _type[node];
+ return _type[node];*/
+ }
+
+ /**
+ * Get mapping from DOM namespace types to external namespace types
+ */
+ public int getNSType(int node)
+ {
+ int eType = super.getNamespaceType(node);
+ return ((Integer)_nsIndex.get(new Integer(eType))).intValue();
}
+
/**
* Returns the namespace type of a specific node
*/
- public int getNamespaceType(final int node) {
- final int type = _type[node];
- if (type >= NTYPES)
- return(_namespace[type-NTYPES]);
- else
- return(0); // default namespace
+ public int getNamespaceType(final int node)
+ {
+ /* int type = this.getExpandedTypeID(node);
+ Integer intType = (Integer)_nsIndex.get(new Integer(type));
+ if (intType == null)
+ return (0); // default namespace
+ else
+ return intType.intValue(); // a custom type*/
+ return super.getNamespaceType(node);
+ /* final int type = getNodeType(node);
+ if (type >= DTM.NTYPES)
+ return(_namespace[type-DTM.NTYPES]);
+ else
+ return(0); // default namespace */
}
/**
* Returns the node-to-type mapping array
- */
- public short[] getTypeArray() {
- return _type;
- }
+ *
+ public short[] getTypeArray()
+ {
+ return _type;
+ } */
/**
* Returns the (String) value of any node in the tree
*/
- public String getNodeValue(final int node) {
- // NS prefix = _prefixArray[_prefix[node]]
- if ((node == NULL) || (node > _treeNodeLimit)) return EMPTYSTRING;
- switch(_type[node]) {
- case ROOT:
- return getNodeValue(_offsetOrChild[node]);
- case TEXT:
- // GTM - add escapign code here too.
- case COMMENT:
- return makeStringValue(node);
- case PROCESSING_INSTRUCTION:
- final String pistr = makeStringValue(node);
- final int col = pistr.indexOf(' ');
+ public String getNodeValue(final int node)
+ {
+ if (node == DTM.NULL) return EMPTYSTRING;
+ switch(getNodeType(node)) {
+ case DTM.ROOT_NODE:
+ case DTM.DOCUMENT_NODE:
+ return getStringValue(getFirstChild(node)).toString();
+ case DTM.TEXT_NODE:
+ // GTM - add escapign code here too.
+ case DTM.COMMENT_NODE:
+ return getStringValue(node).toString(); //makeStringValue(node);
+ case DTM.PROCESSING_INSTRUCTION_NODE:
+ final String pistr = getStringValue(node).toString();
//makeStringValue(node);
+ /* final int col = pistr.indexOf(' ');
if (col > 0)
return pistr.substring(col+1);
- else
+ else*/
return pistr;
+ // case DTM.ELEMENT_NODE:
+ // return getElementValue(node); // element string value
default:
- if (node < _firstAttributeNode)
- return getElementValue(node); // element string value
- else
- return makeStringValue(node); // attribute value
+ return getStringValue(node).toString();
//makeStringValue(node); // attribute value
}
}
- private String getLocalName(int node) {
+/* private String getLocalName(int node)
+ {
final int type = _type[node] - NTYPES;
final String qname = _namesArray[type];
final String uri = _uriArray[_namespace[type]];
@@ -2013,160 +2168,220 @@
if (len > 0) return qname.substring(len+1);
}
return qname;
- }
+ } Call DTM's */
/**
* Sets up a translet-to-dom type mapping table
*/
- private Hashtable setupMapping(String[] namesArray) {
- final int nNames = namesArray.length;
- final Hashtable types = new Hashtable(nNames);
- for (int i = 0; i < nNames; i++) {
- types.put(namesArray[i], new Integer(i + NTYPES));
- }
- return types;
+ private int[] setupMapping(String[] namesArray)
+ {
+ final int nNames = namesArray.length;
+ // Padding with number of names, because they
+ // may need to be added, i.e for RTFs. See copy03
+ final int[] types = new int[m_expandedNameTable.getSize() + nNames];
//(nNames);
+ for (int i = 0; i < nNames; i++) {
+ //types.put(namesArray[i], new Integer(i + DTM.NTYPES));
+ types[getGeneralizedType(namesArray[i])] =
getGeneralizedType(namesArray[i]); //(i + DTM.NTYPES);
+ }
+ return types;
}
/**
- * Returns the internal type associated with an expaneded QName
- */
- public int getGeneralizedType(final String name) {
- final Integer type = (Integer)_types.get(name);
- if (type == null) {
- // memorize default type
- final int code = name.charAt(0) == '@' ? ATTRIBUTE : ELEMENT;
- _types.put(name, new Integer(code));
- return code;
- }
- else {
- return type.intValue();
- }
+ * Returns the internal type associated with an expanded QName
+ */
+ public int getGeneralizedType(final String name)
+ {
+ //final Integer type = (Integer)_types.get(name);
+ //if (type == null) {
+ String lName, ns = null;
+ int index = -1;
+ if ((index = name.lastIndexOf(":"))> -1)
+ {
+ ns = name.substring(0,index);
+ lName = name.substring(index+1);
+ }
+ else
+ lName = name;
+ // memorize default type
+ final int code = lName.charAt(0) == '@' ? DTM.ATTRIBUTE_NODE :
DTM.ELEMENT_NODE;
+ lName = (lName.charAt(0) == '@') ? lName.substring(1) : lName;
+
+ return this.getExpandedTypeID(ns, lName, code);
+
+ // _types.put(name, new Integer(code));
+ //return code;
+ //}
+ // else {
+ // return type.intValue();
+ // }
+
}
/**
* Get mapping from DOM element/attribute types to external types
*/
- public short[] getMapping(String[] names) {
- int i;
- final int namesLength = names.length;
- final int mappingLength = _namesArray.length + NTYPES;
- final short[] result = new short[mappingLength];
-
- // primitive types map to themselves
- for (i = 0; i < NTYPES; i++)
- result[i] = (short)i;
-
- // extended types initialized to "beyond caller's types"
- // unknown element or Attr
- for (i = NTYPES; i < mappingLength; i++) {
- final int type = i - NTYPES;
- final String name = _namesArray[type];
- final String uri = _uriArray[_namespace[type]];
- int len = 0;
- if (uri != null) {
- len = uri.length();
- if (len > 0) len++;
- }
+ public short[] getMapping(String[] names)
+ {
+ int i;
+ final int namesLength = names.length;
+ final int mappingLength = _namesArray.length + NTYPES;
+ final int exLength = m_expandedNameTable.getSize();
+ final short[] result = new short[exLength];
+
+ // primitive types map to themselves
+ for (i = 0; i < DTM.NTYPES; i++)
+ result[i] = (short)i;
+
+ for (i = NTYPES; i < exLength; i++)
+ result[i] = m_expandedNameTable.getType(i);
+
+
+ // extended types initialized to "beyond caller's types"
+ // unknown element or Attr
+ for (i = NTYPES; i < mappingLength; i++) {
+ final int type = i - DTM.NTYPES;
+ final String name = _namesArray[type];
+ // Could this whole thing be replace by a call to len =
indexOf(":") ??
+
+ final String uri;
+ if(_namespace[type] < _uriArray.length)
+ uri = _uriArray[_namespace[type]];
+ else
+ uri = null;
+ int len = 0;
+ if (uri != null) {
+ len = uri.length();
+ if (len > 0) len++;
+ }
- if ((name.length() > 0) && (name.charAt(len) == '@'))
- result[i] = (short)ATTRIBUTE;
- else
- result[i] = (short)ELEMENT;
- }
+ if ((name.length() > 0) && (name.charAt(len) == '@'))
+ result[getGeneralizedType(name)] = DTM.ATTRIBUTE_NODE;
+ else
+ result[getGeneralizedType(name)] = DTM.ELEMENT_NODE;
+ }
+
+ // actual mapping of caller requested names
+ for (i = 0; i < namesLength; i++) {
+ int genType = getGeneralizedType(names[i]);
+ if (genType < _types.length && genType == _types[genType])
+ {
+ /* int index;
+ index = ((index = names[i].lastIndexOf(":"))< 0)? 0 :index+1;
+ type = new Integer(names[i].charAt(index) == '@' ?
DTM.ATTRIBUTE_NODE : DTM.ELEMENT_NODE);
+ _types.put(genType, type);*/
+
+ result[genType] = (short)(i + DTM.NTYPES);
+ }
+ //result[getGeneralizedType(names[i])] = (short)(i + DTM.NTYPES);
+ }
- // actual mapping of caller requested names
- for (i = 0; i < namesLength; i++) {
- result[getGeneralizedType(names[i])] = (short)(i + NTYPES);
- }
-
- return(result);
+ return(result);
}
/**
* Get mapping from external element/attribute types to DOM types
*/
- public short[] getReverseMapping(String[] names) {
- int i;
- final short[] result = new short[names.length + NTYPES];
- // primitive types map to themselves
- for (i = 0; i < NTYPES; i++) {
- result[i] = (short)i;
- }
- // caller's types map into appropriate dom types
- for (i = 0; i < names.length; i++) {
- result[i + NTYPES] = (short)getGeneralizedType(names[i]);
- if (result[i + NTYPES] == ELEMENT)
- result[i + NTYPES] = NO_TYPE;
- }
- return(result);
+ public int[] getReverseMapping(String[] names)
+ {
+ int i;
+ final int[] result = new int[names.length + DTM.NTYPES];
+ // primitive types map to themselves
+ for (i = 0; i < DTM.NTYPES; i++)
+ {
+ result[i] = i;
+ }
+ // caller's types map into appropriate dom types
+ for (i = 0; i < names.length; i++)
+ {
+ int type = getGeneralizedType(names[i]);
+ /* Integer iType = ((Integer)_types.get(new Integer(type)));
+ // if (iType != null)
+ // {
+ result[iType.intValue()] = type;
+ if (result[iType.intValue()] == DTM.ELEMENT_NODE)
+ result[iType.intValue()] = NO_TYPE;
+ }
+ else */
+ result[i+DTM.NTYPES] = type;
+ }
+ return(result);
}
/**
* Get mapping from DOM namespace types to external namespace types
*/
- public short[] getNamespaceMapping(String[] namespaces) {
- int i;
- final int nsLength = namespaces.length;
- final int mappingLength = _uriArray.length;
- final short[] result = new short[mappingLength];
-
- // Initialize all entries to -1
- for (i=0; i<mappingLength; i++)
- result[i] = (-1);
-
- for (i=0; i<nsLength; i++) {
- Integer type = (Integer)_nsIndex.get(namespaces[i]);
- if (type != null) {
- result[type.intValue()] = (short)i;
- }
- }
+ public short[] getNamespaceMapping(String[] namespaces)
+ {
+ int i;
+ final int nsLength = namespaces.length;
+ final int mappingLength = _uriArray.length;
+ final short[] result = new short[mappingLength];
+
+ // Initialize all entries to -1
+ for (i=0; i<mappingLength; i++)
+ result[i] = (short)(-1);
+
+ for (i=0; i<nsLength; i++)
+ {
+ int eType = getExpandedTypeID(namespaces[i],
(String)_prefixArray.get(namespaces[i]) , DTM.NAMESPACE_NODE); // need to make
it public in SAX2DTM...
+ Integer type = (Integer)_nsIndex.get(new Integer(eType));
+ if (type != null)
+ {
+ result[type.intValue()] = (short)i;
+ }
+ }
- return(result);
+ return(result);
}
/**
* Get mapping from external namespace types to DOM namespace types
*/
- public short[] getReverseNamespaceMapping(String[] namespaces) {
- int i;
- final int length = namespaces.length;
- final short[] result = new short[length];
-
- for (i=0; i<length; i++) {
- Integer type = (Integer)_nsIndex.get(namespaces[i]);
- if (type == null)
- result[i] = -1;
- else
- result[i] = type.shortValue();
- }
+ public short[] getReverseNamespaceMapping(String[] namespaces)
+ {
+ int i;
+ final int length = namespaces.length;
+ final short[] result = new short[length];
+
+ for (i=0; i<length; i++)
+ {
+ int eType = getExpandedTypeID(namespaces[i],
(String)_prefixArray.get(namespaces[i]) , DTM.NAMESPACE_NODE);
+ Integer type = (Integer)_nsIndex.get(new Integer (eType));
+ if (type == null)
+ result[i] = -1;
+ else
+ result[i] = type.shortValue();
+ }
- return(result);
+ return(result);
}
/**
* Dump the whole tree to a file (serialized)
*/
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeInt(_treeNodeLimit); // number of nodes in DOM
- out.writeInt(_firstAttributeNode); // index of first attribute node
- out.writeObject(_documentURI); // URI of original document
-
- out.writeObject(_type); // type of every node in DOM
- out.writeObject(_namespace); // namespace URI of each type
- out.writeObject(_prefix); // prefix type of every node in DOM
-
- out.writeObject(_parent); // parent of every node in DOM
- out.writeObject(_nextSibling); // next sibling of every node in DOM
- out.writeObject(_offsetOrChild); // first child of every node in DOM
- out.writeObject(_lengthOrAttr); // first attr of every node in DOM
-
- out.writeObject(_text); // all text in DOM (text, PIs, etc)
- out.writeObject(_namesArray); // names of all element/attr types
- out.writeObject(_uriArray); // name of all URIs
- out.writeObject(_prefixArray); // name of all prefixes
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeInt(_treeNodeLimit); // number of nodes in DOM
+ out.writeInt(_firstAttributeNode); // index of first attribute node
+ out.writeObject(_documentURI); // URI of original document
+
+ //out.writeObject(_type); // type of every node in DOM
+ out.writeObject(_namespace); // namespace URI of each type
+ // out.writeObject(_prefix); // prefix type of every node in
DOM
+
+ //out.writeObject(_parent); // parent of every node in DOM
+ //out.writeObject(_nextSibling); // next sibling of every node in
DOM
+ out.writeObject(_offsetOrChild); // first child of every node in DOM
+ out.writeObject(_lengthOrAttr); // first attr of every node in DOM
+
+ out.writeObject(_text); // all text in DOM (text, PIs, etc)
+ out.writeObject(_namesArray); // names of all element/attr types
+ out.writeObject(_uriArray); // name of all URIs
+ out.writeObject(_prefixArray); // name of all prefixes
+
+ out.writeObject(_whitespace);
- out.writeObject(_whitespace);
if (_dontEscape != null) {
out.writeObject(_dontEscape);
@@ -2176,32 +2391,35 @@
}
out.flush();
+
}
/**
* Read the whole tree from a file (serialized)
*/
public void readExternal(ObjectInput in)
- throws IOException, ClassNotFoundException {
- _treeNodeLimit = in.readInt();
- _firstAttributeNode = in.readInt();
- _documentURI = (String)in.readObject();
-
- _type = (short[])in.readObject();
- _namespace = (short[])in.readObject();
- _prefix = (short[])in.readObject();
-
- _parent = (int[])in.readObject();
- _nextSibling = (int[])in.readObject();
- _offsetOrChild = (int[])in.readObject();
- _lengthOrAttr = (int[])in.readObject();
-
- _text = (char[])in.readObject();
- _namesArray = (String[])in.readObject();
- _uriArray = (String[])in.readObject();
- _prefixArray = (String[])in.readObject();
+ throws IOException, ClassNotFoundException
+ {
+ _treeNodeLimit = in.readInt();
+ _firstAttributeNode = in.readInt();
+ _documentURI = (String)in.readObject();
+
+ //_type = (short[])in.readObject();
+ _namespace = (short[])in.readObject();
+ // _prefix = (short[])in.readObject();
+
+ //_parent = (int[])in.readObject();
+ //_nextSibling = (int[])in.readObject();
+ _offsetOrChild = (int[])in.readObject();
+ _lengthOrAttr = (int[])in.readObject();
+
+ _text = (char[])in.readObject();
+ _namesArray = (String[])in.readObject();
+ _uriArray = (String[])in.readObject();
+ // _prefixArray = (String[])in.readObject();
+
+ _whitespace = (BitArray)in.readObject();
- _whitespace = (BitArray)in.readObject();
_dontEscape = (BitArray)in.readObject();
if (_dontEscape.size() == 0) {
@@ -2209,89 +2427,127 @@
}
_types = setupMapping(_namesArray);
+
}
/**
* Constructor - defaults to 32K nodes
*/
- public DOMImpl() {
- //this(32*1024);
- this(8*1024);
+
+ public DOMImpl(DTMManager mgr, DOMSource domSource,
+ int dtmIdentity, DTMWSFilter whiteSpaceFilter,
+ XMLStringFactory xstringfactory,
+ boolean doIndexing)
+ {
+ super(mgr, domSource,
+ dtmIdentity, whiteSpaceFilter,
+ xstringfactory,
+ doIndexing);
+ initSize(8*1024);
}
-
+
+ public DOMImpl(DTMManager mgr, DOMSource domSource,
+ int dtmIdentity, DTMWSFilter whiteSpaceFilter,
+ XMLStringFactory xstringfactory,
+ boolean doIndexing, int size)
+ {
+ super(mgr, domSource,
+ dtmIdentity, whiteSpaceFilter,
+ xstringfactory,
+ doIndexing);
+ initSize(size);
+ }
+
+ /* public DOMImpl()
+ {
+ //this(32*1024);
+ this(8*1024);
+ }*/
+
/**
- * Constructor - defines initial size
+ * defines initial size
*/
- public DOMImpl(int size) {
- _type = new short[size];
- _parent = new int[size];
- _nextSibling = new int[size];
- _offsetOrChild = new int[size];
- _lengthOrAttr = new int[size];
- _text = new char[size * 10];
- _whitespace = new BitArray(size);
- _prefix = new short[size];
- // _namesArray[] and _uriArray[] are allocated in endDocument
+ public void initSize(int size)
+ {
+ //_type = new short[size];
+ //_parent = new int[size];
+ //_nextSibling = new int[size];
+ _offsetOrChild = new int[size];
+ _lengthOrAttr = new int[size];
+ _text = new char[size * 10];
+ _whitespace = new BitArray(size);
+ // _prefix = new short[size];
+ // _namesArray[] and _uriArray[] are allocated in endDocument
}
/**
* Prints the whole tree to standard output
*/
- public void print(int node, int level) {
- switch(_type[node]) {
- case ROOT:
- print(_offsetOrChild[node], level);
+ public void print(int node, int level)
+ {
+ switch(getNodeType(node))
+ {
+ case DTM.ROOT_NODE:
+ case DTM.DOCUMENT_NODE:
+ print(getFirstChild(node), level);
break;
- case TEXT:
- case COMMENT:
- case PROCESSING_INSTRUCTION:
- System.out.print(makeStringValue(node));
+ case DTM.TEXT_NODE:
+ case DTM.COMMENT_NODE:
+ case DTM.PROCESSING_INSTRUCTION_NODE:
+ System.out.print(getStringValue(node).toString());
break;
default: // element
final String name = getNodeName(node);
System.out.print("<" + name);
- for (int a = _lengthOrAttr[node]; a != NULL; a = _nextSibling[a]) {
- System.out.print("\n" + getNodeName(a) +
- "=\"" + makeStringValue(a) + "\"");
+ for (int a = getFirstAttribute(node); a != DTM.NULL; a =
getNextAttribute(a))
+ {
+ System.out.print("\n" + getNodeName(a) +
+ "=\"" + getStringValue(a).toString() + "\"");
}
System.out.print('>');
- for (int child = _offsetOrChild[node]; child != NULL;
- child = _nextSibling[child]) {
- print(child, level + 1);
+ for (int child = getFirstChild(node); child != DTM.NULL;
+ child = getNextSibling(child))
+ {
+ print(child, level + 1);
}
System.out.println("</" + name + '>');
break;
}
- }
+}
/**
* Returns the name of a node (attribute or element).
*/
- public String getNodeName(final int node) {
+public String getNodeName(final int node)
+ {
// Get the node type and make sure that it is within limits
- final short type = _type[node];
- switch(type) {
- case DOM.ROOT:
- case DOM.TEXT:
- case DOM.ELEMENT:
- case DOM.ATTRIBUTE:
- case DOM.COMMENT:
+ int nodeh = node; //makeNodeHandle(node);
+ final short type = getNodeType(nodeh);
+ switch(type)
+ {
+ case DTM.ROOT_NODE:
+ case DTM.DOCUMENT_NODE:
+ case DTM.TEXT_NODE:
+ //case DTM.ELEMENT_NODE:
+ //case DTM.ATTRIBUTE_NODE:
+ case DTM.COMMENT_NODE:
return EMPTYSTRING;
- case DOM.NAMESPACE:
- final int index = _prefix[node];
- if (index < _prefixArray.length)
- return _prefixArray[index];
- else
- return EMPTYSTRING;
- case DOM.PROCESSING_INSTRUCTION:
+ case DTM.NAMESPACE_NODE:
+ //final int index = _prefix[node];
+ // if (index < _prefixArray.length)
+ return this.getLocalName(nodeh); //_prefixArray[index];
+ //else
+ //return EMPTYSTRING;
+ /*case DTM.PROCESSING_INSTRUCTION_NODE:
final String pistr = makeStringValue(node);
final int col = pistr.indexOf(' ');
if (col > -1)
return(pistr.substring(0,col));
else
- return pistr;
+ return pistr;*/
default:
- // Construct the local part (omit '@' for attributes)
+ return super.getNodeName(nodeh);
+ /* // Construct the local part (omit '@' for attributes)
String name = getLocalName(node);
if (node >= _firstAttributeNode)
name = name.substring(1);
@@ -2302,103 +2558,104 @@
if (prefix != EMPTYSTRING)
name = prefix+':'+name;
}
- return name;
+ return name;*/
}
}
+
/**
* Returns the namespace URI to which a node belongs
*/
- public String getNamespaceName(final int node) {
- if (_type[node] == NAMESPACE) {
- return(EMPTYSTRING); //return getNodeValue(node);
- }
- else {
- final int type = getNamespaceType(node);
- final String name = _uriArray[type];
- if (name == null)
- return(EMPTYSTRING);
- else
- return(name);
- }
+
+ public String getNamespaceName(final int node)
+ {
+ if (node == DTM.NULL)
+ return "";
+ String s;
+ return (( s = getNamespaceURI(node)) == null ? "" : s);
}
/**
* Returns the string value of a single text/comment node or
* attribute value (they are all stored in the same array).
*/
- private String makeStringValue(final int node) {
- return new String(_text, _offsetOrChild[node], _lengthOrAttr[node]);
+ private String makeStringValue(final int node)
+ {
+ return getStringValue(node).toString();
+ //new String(_text, _offsetOrChild[node], _lengthOrAttr[node]);
}
/**
* Returns the attribute node of a given type (if any) for an element
*/
- public int getAttributeNode(final int type, final int element) {
- for (int attr = _lengthOrAttr[element];
- attr != NULL;
- attr = _nextSibling[attr]) {
- if (_type[attr] == type) return attr;
- }
- return NULL;
+ public int getAttributeNode(final int type, final int element)
+ {
+ for (int attr = getFirstAttribute(element);
+ attr != DTM.NULL;
+ attr = getNextAttribute(attr))
+ {
+ if (getExpandedTypeID(attr) == type) return attr;
+ }
+ return DTM.NULL;
}
/**
* Returns the value of a given attribute type of a given element
*/
- public String getAttributeValue(final int type, final int element) {
- final int attr = getAttributeNode(type, element);
- if (attr != NULL)
- return makeStringValue(attr);
- else
- return EMPTYSTRING;
+ public String getAttributeValue(final int type, final int element)
+ {
+ final int attr = getAttributeNode(type, element);
+ if (attr != DTM.NULL)
+ return getStringValue(attr).toString();
+ else
+ return EMPTYSTRING;
}
/**
* Returns true if a given element has an attribute of a given type
*/
- public boolean hasAttribute(final int type, final int node) {
- if (getAttributeNode(type, node) != NULL)
- return true;
- else
- return false;
+ public boolean hasAttribute(final int type, final int node)
+ {
+ if (getAttributeNode(type, node) != DTM.NULL)
+ return true;
+ else
+ return false;
}
/**
* This method is for testing/debugging only
*/
- public String getAttributeValue(final String name, final int element) {
- return getAttributeValue(getGeneralizedType(name), element);
+ public String getAttributeValue(final String name, final int element)
+ {
+ return getAttributeValue(getGeneralizedType(name), element);
}
/**
* Returns true if the given element has any children
*/
- private boolean hasChildren(final int node) {
- if (node < _firstAttributeNode) {
- final int type = _type[node];
- return(((type >= NTYPES) || (type == ROOT)) &&
- (_offsetOrChild[node] != 0));
- }
- return(false);
+ private boolean hasChildren(final int node)
+ {
+ return(hasChildNodes(node));
}
/**
* Returns an iterator with all the children of a given node
*/
- public NodeIterator getChildren(final int node) {
- if (hasChildren(node))
- return(new ChildrenIterator());
- else
- return(EMPTYITERATOR);
+ public DTMAxisIterator getChildren(final int node)
+ {
+ if (hasChildren(node))
+ return(new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.ChildrenIterator());
+ else
+ return(EMPTYITERATOR);
}
/**
* Returns an iterator with all children of a specific type
* for a given node (element)
*/
- public NodeIterator getTypedChildren(final int type) {
- return(new TypedChildrenIterator(type));
+ public DTMAxisIterator getTypedChildren(final int type)
+ {
+ return(new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedChildrenIterator(type));
}
/**
@@ -2407,117 +2664,124 @@
* Returns a bare-bones iterator that must be initialized
* with a start node (using iterator.setStartNode()).
*/
- public NodeIterator getAxisIterator(final int axis) {
- NodeIterator iterator = null;
-
- switch (axis) {
- case Axis.SELF:
- iterator = new SingletonIterator();
- break;
- case Axis.CHILD:
- iterator = new ChildrenIterator();
- break;
- case Axis.PARENT:
- return(new ParentIterator());
- case Axis.ANCESTOR:
- return(new AncestorIterator());
- case Axis.ANCESTORORSELF:
- return((new AncestorIterator()).includeSelf());
- case Axis.ATTRIBUTE:
- return(new AttributeIterator());
- case Axis.DESCENDANT:
- iterator = new DescendantIterator();
- break;
- case Axis.DESCENDANTORSELF:
- iterator = (new DescendantIterator()).includeSelf();
- break;
- case Axis.FOLLOWING:
- iterator = new FollowingIterator();
- break;
- case Axis.PRECEDING:
- iterator = new PrecedingIterator();
- break;
- case Axis.FOLLOWINGSIBLING:
- iterator = new FollowingSiblingIterator();
- break;
- case Axis.PRECEDINGSIBLING:
- iterator = new PrecedingSiblingIterator();
- break;
- case Axis.NAMESPACE:
- iterator = new NamespaceIterator();
- break;
- default:
- BasisLibrary.runTimeError(BasisLibrary.AXIS_SUPPORT_ERR,
- Axis.names[axis]);
- }
- return(iterator);
+ public DTMAxisIterator getAxisIterator(final int axis)
+ {
+ DTMAxisIterator iterator = null;
+
+ switch (axis)
+ {
+ case Axis.SELF:
+ iterator = new SingletonIterator();
+ break;
+ case Axis.CHILD:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.ChildrenIterator();
+ break;
+ case Axis.PARENT:
+ return(new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.ParentIterator());
+ case Axis.ANCESTOR:
+ return(new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.AncestorIterator());
+ case Axis.ANCESTORORSELF:
+ return((new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.AncestorIterator()).includeSelf());
+ case Axis.ATTRIBUTE:
+ return(new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.AttributeIterator());
+ case Axis.DESCENDANT:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.DescendantIterator();
+ break;
+ case Axis.DESCENDANTORSELF:
+ iterator = (new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.DescendantIterator()).includeSelf();
+ break;
+ case Axis.FOLLOWING:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.FollowingIterator();
+ break;
+ case Axis.PRECEDING:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.PrecedingIterator();
+ break;
+ case Axis.FOLLOWINGSIBLING:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.FollowingSiblingIterator();
+ break;
+ case Axis.PRECEDINGSIBLING:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.PrecedingSiblingIterator();
+ break;
+ case Axis.NAMESPACE:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.NamespaceIterator();
+ break;
+ default:
+ BasisLibrary.runTimeError(BasisLibrary.AXIS_SUPPORT_ERR,
+ Axis.names[axis]);
+ }
+ return(iterator);
}
/**
* Similar to getAxisIterator, but this one returns an iterator
* containing nodes of a typed axis (ex.: child::foo)
*/
- public NodeIterator getTypedAxisIterator(int axis, int type) {
- NodeIterator iterator = null;
-
- /* This causes an error when using patterns for elements that
- do not exist in the DOM (translet types which do not correspond
- to a DOM type are mapped to the DOM.ELEMENT type).
- */
-
- if (type == NO_TYPE) {
- return(EMPTYITERATOR);
- }
- else if ((type == ELEMENT) && (axis != Axis.NAMESPACE)) {
- iterator = new FilterIterator(getAxisIterator(axis),
- getElementFilter());
- }
- else {
- switch (axis) {
- case Axis.SELF:
- iterator = new TypedSingletonIterator(type);
- break;
- case Axis.CHILD:
- iterator = new TypedChildrenIterator(type);
- break;
- case Axis.PARENT:
- return(new ParentIterator().setNodeType(type));
- case Axis.ANCESTOR:
- return(new TypedAncestorIterator(type));
- case Axis.ANCESTORORSELF:
- return((new TypedAncestorIterator(type)).includeSelf());
- case Axis.ATTRIBUTE:
- return(new TypedAttributeIterator(type));
- case Axis.DESCENDANT:
- iterator = new TypedDescendantIterator(type);
- break;
- case Axis.DESCENDANTORSELF:
- iterator = (new TypedDescendantIterator(type)).includeSelf();
- break;
- case Axis.FOLLOWING:
- iterator = new TypedFollowingIterator(type);
- break;
- case Axis.PRECEDING:
- iterator = new TypedPrecedingIterator(type);
- break;
- case Axis.FOLLOWINGSIBLING:
- iterator = new TypedFollowingSiblingIterator(type);
- break;
- case Axis.PRECEDINGSIBLING:
- iterator = new TypedPrecedingSiblingIterator(type);
- break;
- case Axis.NAMESPACE:
- if (type == ELEMENT)
- iterator = new NamespaceIterator();
- else
- iterator = new TypedNamespaceIterator(type);
- break;
- default:
- BasisLibrary.runTimeError(BasisLibrary.TYPED_AXIS_SUPPORT_ERR,
- Axis.names[axis]);
- }
- }
- return(iterator);
+ public DTMAxisIterator getTypedAxisIterator(int axis, int type)
+ {
+ DTMAxisIterator iterator = null;
+
+ /* This causes an error when using patterns for elements that
+ do not exist in the DOM (translet types which do not correspond
+ to a DOM type are mapped to the DOM.ELEMENT type).
+ */
+
+ if (type == NO_TYPE)
+ {
+ return(EMPTYITERATOR);
+ }
+ else if ((type == DTM.ELEMENT_NODE) && (axis != Axis.NAMESPACE))
+ {
+ iterator = new FilterIterator(getAxisIterator(axis),
+ getElementFilter());
+ }
+ else
+ {
+ switch (axis)
+ {
+ case Axis.SELF:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedSingletonIterator(type);
+ break;
+ case Axis.CHILD:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedChildrenIterator(type);
+ break;
+ case Axis.PARENT:
+ return(new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.ParentIterator().setNodeType(type));
+ case Axis.ANCESTOR:
+ return(new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedAncestorIterator(type));
+ case Axis.ANCESTORORSELF:
+ return((new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedAncestorIterator(type)).includeSelf());
+ case Axis.ATTRIBUTE:
+ return(new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedAttributeIterator(type));
+ case Axis.DESCENDANT:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedDescendantIterator(type);
+ break;
+ case Axis.DESCENDANTORSELF:
+ iterator = (new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedDescendantIterator(type)).includeSelf();
+ break;
+ case Axis.FOLLOWING:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedFollowingIterator(type);
+ break;
+ case Axis.PRECEDING:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedPrecedingIterator(type);
+ break;
+ case Axis.FOLLOWINGSIBLING:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedFollowingSiblingIterator(type);
+ break;
+ case Axis.PRECEDINGSIBLING:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedPrecedingSiblingIterator(type);
+ break;
+ case Axis.NAMESPACE:
+ if (type == DTM.ELEMENT_NODE)
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.NamespaceIterator();
+ else
+ iterator = new
/*org.apache.xml.dtm.ref.DTMDefaultBaseIterators.*/TypedNamespaceIterator(type);
+ break;
+ default:
+ BasisLibrary.runTimeError(BasisLibrary.TYPED_AXIS_SUPPORT_ERR,
+ Axis.names[axis]);
+ }
+ }
+ return(iterator);
}
/**
@@ -2527,83 +2791,98 @@
* The 'axis' specifies the axis for the base iterator from which the
* nodes are taken, while 'ns' specifies the namespace URI type.
*/
- public NodeIterator getNamespaceAxisIterator(int axis, int ns) {
+ public DTMAxisIterator getNamespaceAxisIterator(int axis, int ns)
+ {
- NodeIterator iterator = null;
+ DTMAxisIterator iterator = null;
- if (ns == NO_TYPE) {
- return(EMPTYITERATOR);
- }
- else {
- switch (axis) {
- case Axis.CHILD:
- iterator = new NamespaceChildrenIterator(ns);
- break;
- case Axis.ATTRIBUTE:
- iterator = new NamespaceAttributeIterator(ns);
- break;
- default:
- BasisLibrary.runTimeError(BasisLibrary.TYPED_AXIS_SUPPORT_ERR,
- Axis.names[axis]);
- }
- }
- return(iterator);
+ if (ns == NO_TYPE)
+ {
+ return(EMPTYITERATOR);
+ }
+ else
+ {
+ switch (axis)
+ {
+ case Axis.CHILD:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.NamespaceChildrenIterator(ns);
+ break;
+ case Axis.ATTRIBUTE:
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.NamespaceAttributeIterator(ns);
+ break;
+ default:
+ BasisLibrary.runTimeError(BasisLibrary.TYPED_AXIS_SUPPORT_ERR,
+ Axis.names[axis]);
+ }
+ }
+ return(iterator);
}
/**
* Returns an iterator with all descendants of a node that are of
* a given type.
*/
- public NodeIterator getTypedDescendantIterator(int type) {
- NodeIterator iterator;
- if (type == ELEMENT)
- iterator = new FilterIterator(new DescendantIterator(),
- getElementFilter());
- else
- iterator = new TypedDescendantIterator(type);
- return(iterator);
+ public DTMAxisIterator getTypedDescendantIterator(int type)
+ {
+ DTMAxisIterator iterator;
+ if (type == DTM.ELEMENT_NODE)
+ iterator = new FilterIterator(new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.DescendantIterator(),
+ getElementFilter());
+ else
+ iterator = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedDescendantIterator(type);
+ return(iterator);
}
/**
* Returns the nth descendant of a node
*/
- public NodeIterator getNthDescendant(int type, int n, boolean
includeself) {
- NodeIterator source;
- if (type == ELEMENT)
- source = new FilterIterator(new DescendantIterator(),
- getElementFilter());
- else
- source = new TypedDescendantIterator(type);
- if (includeself) ((NodeIteratorBase)source).includeSelf();
- return(new NthDescendantIterator(source, n, type));
+ public DTMAxisIterator getNthDescendant(int type, int n, boolean
includeself)
+ {
+ DTMAxisIterator source;
+ if (type == DTM.ELEMENT_NODE)
+ source = new FilterIterator(new DescendantIterator(),
+ getElementFilter());
+ else
+ source = new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.TypedDescendantIterator(type);
+ //TODO?? if (includeself)
+ // ((NodeIteratorBase)source).includeSelf();
+ return(new
org.apache.xml.dtm.ref.DTMDefaultBaseIterators.NthDescendantIterator(n));
}
/**
* Copy the contents of a text-node to an output handler
*/
public void characters(final int textNode, TransletOutputHandler handler)
- throws TransletException {
- handler.characters(_text,
- _offsetOrChild[textNode],
- _lengthOrAttr[textNode]);
+ throws TransletException
+ {
+ //TODO: child of a text node== null!!
+ /* handler.characters(_text,
+ _offsetOrChild[textNode],
+ _lengthOrAttr[textNode]); */
+ char[] buffer;
+ buffer = getNodeValue(textNode).toCharArray();
+ handler.characters(buffer, 0, buffer.length);
}
/**
* Copy a node-set to an output handler
*/
- public void copy(NodeIterator nodes, TransletOutputHandler handler)
- throws TransletException {
- int node;
- while ((node = nodes.next()) != NULL) {
- copy(node, handler);
- }
+ public void copy(DTMAxisIterator nodes, TransletOutputHandler handler)
+ throws TransletException
+ {
+ int node;
+ while ((node = nodes.next()) != DTM.NULL)
+ {
+ copy(node, handler);
+ }
}
/**
* Copy the whole tree to an output handler
*/
- public void copy(TransletOutputHandler handler) throws TransletException
{
- copy(ROOTNODE, handler);
+ public void copy(TransletOutputHandler handler) throws TransletException
+ {
+ copy(getDocument()/*(DTMDefaultBase.ROOTNODE*/, handler);
}
/**
@@ -2614,233 +2893,263 @@
* TODO: Copy comment nodes
*/
public void copy(final int node, TransletOutputHandler handler)
- throws TransletException {
+ throws TransletException
+ {
- final int type = _type[node];
+ final int type = getNodeType(node); //_type[node];
+
+
+ switch(type)
+ {
+ case DTM.ROOT_NODE:
+ case DTM.DOCUMENT_NODE:
+ for(int c=getFirstChild(node); c!=DTM.NULL; c=getNextSibling(c))
+ //for (int c=_offsetOrChild[node]; c!=NULL; c=_nextSibling[c])
+ copy(c, handler);
+ break;
+ case DTM.PROCESSING_INSTRUCTION_NODE:
+ copyPI(node, handler);
+ break;
+ case DTM.COMMENT_NODE:
+ handler.comment(getNodeValue(node)/*_text,
+ _offsetOrChild[node],
+ _lengthOrAttr[node])*/);
+ break;
+ case DTM.TEXT_NODE:
+ char[] buffer = getNodeValue(node).toCharArray();
+ handler.characters(buffer, 0, buffer.length);/*_text,
+ _offsetOrChild[node],
+ _lengthOrAttr[node]);*/
+ break;
+ case DTM.ATTRIBUTE_NODE:
+ shallowCopy(node, handler);
+ break;
+ case DTM.NAMESPACE_NODE:
+ shallowCopy(node, handler);
+ break;
+ default:
+ if (isElement(node)) {
+ // Start element definition
+ final String name = copyElement(node, type, handler);
+ // Copy element attribute
+ for(int a=getFirstAttribute(node); a!=DTM.NULL;
a=getNextAttribute(a)){
+ //for (int a=_lengthOrAttr[node]; a!=NULL; a=_nextSibling[a]) {
+ // if (getNodeType(a)/*_type[a]*/ != DTM.NAMESPACE_NODE)
//NAMESPACE)
+ final String uri = getNamespaceName(a);
+ if (uri != EMPTYSTRING) {
+ final String prefix = getPrefix(a);
//_prefixArray[_prefix[a]];
+ handler.namespace(prefix, uri);
+ }
+ handler.attribute(getNodeName(a), getNodeValue(a));
//makeStringValue(a));
+ }
+ for(int a=getFirstNamespaceNode(node, true); a!=DTM.NULL;
a=getNextNamespaceNode(node, a, true))
+ {
+ handler.namespace(getNodeNameX(a), //_prefixArray[_prefix[a]],
+ getNodeValue(a)); //makeStringValue(a));
+ }
+
+ // Copy element children
+ for(int c=getFirstChild(node); c!=DTM.NULL; c=getNextSibling(c))
+ //for (int c=_offsetOrChild[node]; c!=NULL; c=_nextSibling[c])
+ copy(c, handler);
+ // Close element definition
+ handler.endElement(name);
+ }
+ // Shallow copy of attribute to output handler
+ else {
+ final String uri = getNamespaceName(node);
+ if (uri != EMPTYSTRING) {
+ final String prefix = getPrefix(node);
//_prefixArray[_prefix[node]];
+ handler.namespace(prefix, uri);
+ }
+ handler.attribute(getNodeName(node), getNodeValue(node));
//makeStringValue(node));
+ }
+ break;
+ }
+
- switch(type) {
- case ROOT:
- for (int c=_offsetOrChild[node]; c!=NULL; c=_nextSibling[c])
- copy(c, handler);
- break;
- case PROCESSING_INSTRUCTION:
- copyPI(node, handler);
- break;
- case COMMENT:
- handler.comment(new String(_text,
- _offsetOrChild[node],
- _lengthOrAttr[node]));
- break;
- case TEXT:
- boolean last = false;
- boolean escapeBit = false;
-
- if (_dontEscape != null) {
- escapeBit = _dontEscape.getBit(node);
- if (escapeBit) {
- last = handler.setEscaping(false);
- }
- }
-
- handler.characters(_text,
- _offsetOrChild[node],
- _lengthOrAttr[node]);
-
- if (_dontEscape != null && escapeBit) {
- handler.setEscaping(last);
- }
- break;
- case ATTRIBUTE:
- shallowCopy(node, handler);
- break;
- case NAMESPACE:
- shallowCopy(node, handler);
- break;
- default:
- if (isElement(node)) {
- // Start element definition
- final String name = copyElement(node, type, handler);
-
- // Copy element attribute
- for (int a=_lengthOrAttr[node]; a!=NULL; a=_nextSibling[a]) {
- if (_type[a] != NAMESPACE) {
- final String uri = getNamespaceName(a);
- if (uri != EMPTYSTRING) {
- final String prefix = _prefixArray[_prefix[a]];
- handler.namespace(prefix, uri);
- }
- handler.attribute(getNodeName(a), makeStringValue(a));
- }
- else {
- handler.namespace(_prefixArray[_prefix[a]],
- makeStringValue(a));
- }
- }
- // Copy element children
- for (int c=_offsetOrChild[node]; c!=NULL; c=_nextSibling[c])
- copy(c, handler);
- // Close element definition
- handler.endElement(name);
- }
- // Shallow copy of attribute to output handler
- else {
- final String uri = getNamespaceName(node);
- if (uri != EMPTYSTRING) {
- final String prefix = _prefixArray[_prefix[node]];
- handler.namespace(prefix, uri);
- }
- handler.attribute(getNodeName(node), makeStringValue(node));
- }
- break;
- }
}
/**
* Copies a processing instruction node to an output handler
*/
private void copyPI(final int node, TransletOutputHandler handler)
- throws TransletException {
- final char[] text = _text;
- final int start = _offsetOrChild[node];
- final int length = _lengthOrAttr[node];
-
- // Target and Value are separated by a whitespace - find it!
- int i = start;
- while (text[i] != ' ') i++;
-
- final int len = i - start;
- final String target = new String(text, start, len);
- final String value = new String(text, i + 1, length - len - 1);
-
- handler.processingInstruction(target, value);
+ throws TransletException
+ {
+ //TODO
+ /* final char[] text = _text;
+ final int start = _offsetOrChild[node];
+ final int length = _lengthOrAttr[node];
+
+ // Target and Value are separated by a whitespace - find it!
+ int i = start;
+ while (text[i] != ' ') i++;
+
+ final int len = i - start;
+ final String target = new String(text, start, len);
+ final String value = new String(text, i + 1, length - len - 1);
+ */
+ final String target = getNodeName(node);
+ final String value = getStringValue(node).toString();
+ handler.processingInstruction(target, value);
}
/**
* Performs a shallow copy (ref. XSLs copy())
*/
public String shallowCopy(final int node, TransletOutputHandler handler)
- throws TransletException {
-
- final int type = _type[node];
-
- switch(type) {
- case ROOT: // do nothing
- return EMPTYSTRING;
- case TEXT:
-
- handler.characters(_text,
- _offsetOrChild[node],
- _lengthOrAttr[node]);
+ throws TransletException
+ {
- return null;
- case PROCESSING_INSTRUCTION:
- copyPI(node, handler);
- return null;
- case COMMENT:
- final String comment = new String(_text,
- _offsetOrChild[node],
- _lengthOrAttr[node]);
- handler.comment(comment);
- return null;
- case NAMESPACE:
- handler.namespace(_prefixArray[_prefix[node]],
- makeStringValue(node));
- return null;
- default:
- if (isElement(node)) {
- return(copyElement(node, type, handler));
- }
- else {
- final String uri = getNamespaceName(node);
- if (uri != EMPTYSTRING) {
- final String prefix = _prefixArray[_prefix[node]];
- handler.namespace(prefix, uri);
- }
- handler.attribute(getNodeName(node), makeStringValue(node));
- return null;
- }
- }
+ final int type = getNodeType(node);
+ switch(type)
+ {
+ case DTM.ROOT_NODE: // do nothing
+ case DTM.DOCUMENT_NODE:
+ return EMPTYSTRING;
+ case DTM.TEXT_NODE:
+ char[] buffer = this.getNodeValue(node).toCharArray();
+ handler.characters(buffer, 0, buffer.length); /*_text,
+ _offsetOrChild[node],
+ _lengthOrAttr[node]); */
+ return null;
+ case DTM.PROCESSING_INSTRUCTION_NODE:
+ copyPI(node, handler);
+ return null;
+ case DTM.COMMENT_NODE:
+ final String comment = getNodeValue(node); /*)new String(_text,
+ _offsetOrChild[node],
+ _lengthOrAttr[node]);*/
+ handler.comment(comment);
+ return null;
+ case DTM.NAMESPACE_NODE:
+ handler.namespace(getNodeNameX(node), //_prefixArray[_prefix[node]],
+ getNodeValue(node)); //makeStringValue(node));
+ return null;
+ case DTM.ATTRIBUTE_NODE:
+ final String uri = getNamespaceName(node);
+ if (uri != EMPTYSTRING) {
+ final String prefix = getPrefix(node); //
_prefixArray[_prefix[node]];
+ handler.namespace(prefix, uri);
+ }
+ handler.attribute(getNodeName(node), getNodeValue(node));
//makeStringValue(node));
+ return null;
+ default:
+ if (type == DTM.ELEMENT_NODE) //isElement(node))
+ {
+ return(copyElement(node, type, handler));
+ }
+ else
+ {
+ final String uri1 = getNamespaceName(node);
+ if (uri1 != EMPTYSTRING) {
+ final String prefix = getPrefix(node); //
_prefixArray[_prefix[node]];
+ handler.namespace(prefix, uri1);
+ }
+ handler.attribute(getNodeName(node), getNodeValue(node));
//makeStringValue(node));
+ return null;
+ }
+ }
}
private String copyElement(int node, int type,
- TransletOutputHandler handler)
- throws TransletException {
-
- type = type - NTYPES;
- String name = _namesArray[type];
- final int pi = _prefix[node];
- final int ui = _namespace[type];
- if (pi > 0) {
- final String prefix = _prefixArray[pi];
- final String uri = _uriArray[ui];
- final String local = getLocalName(node);
- if (prefix.equals(EMPTYSTRING))
- name = local;
- else
- name = prefix+':'+local;
- handler.startElement(name);
- handler.namespace(prefix, uri);
- }
- else {
- if (ui > 0) {
- handler.startElement(getLocalName(node));
- handler.namespace(EMPTYSTRING, _uriArray[ui]);
- }
- else {
- handler.startElement(name);
- }
- }
- return name;
+ TransletOutputHandler handler)
+ throws TransletException
+ {
+
+ //type = type - DTM.NTYPES;
+ String name = null; //_namesArray[type];
+ //final int pi = _prefix[node];
+ //final int ui = _namespace[type];
+ //if (pi > 0)
+ //{
+ final String prefix = getPrefix(node); //_prefixArray[pi];
+ final String uri = getNamespaceName(node); //_uriArray[ui];
+ final String local = getLocalName(node);
+ if (prefix.equals(EMPTYSTRING))
+ name = local;
+ else
+ name = prefix+':'+local;
+
+ if (uri != null)
+ {
+ handler.startElement(name);
+ handler.namespace(prefix, uri);
+ }
+ else
+ {
+ // if (ui > 0)
+ // {
+ // handler.startElement(getLocalName(node));
+ // handler.namespace(EMPTYSTRING, _uriArray[ui]);
+ // }
+ // else
+ // {
+ handler.startElement(name);
+ }
+ //}
+ return name;
}
+
/**
* Returns the string value of the entire tree
*/
- public String getStringValue() {
- return getElementValue(ROOTNODE);
+ public String getStringValue()
+ {
+ return getElementValue(getDocument()); //DTMDefaultBase.ROOTNODE);
}
/**
* Returns the string value of any element
*/
- public String getElementValue(final int element) {
- // optimization: only create StringBuffer if > 1 child
- final int child = _offsetOrChild[element];
- if (child == NULL)
- return EMPTYSTRING;
- if ((_type[child] == TEXT) && (_nextSibling[child] == NULL))
- return makeStringValue(child);
- else
- return stringValueAux(new StringBuffer(), element).toString();
+ public String getElementValue(final int element)
+ {
+ // optimization: only create StringBuffer if > 1 child
+ final int child = getFirstChild(element);
+ if (child == DTM.NULL)
+ return EMPTYSTRING;
+ if ((getNodeType(child) == DTM.TEXT_NODE) && (getNextSibling(child) ==
DTM.NULL))
+ return getStringValue(child).toString();
+ else
+ return stringValueAux(new StringBuffer(), element).toString();
}
/**
* Helper to getElementValue() above
*/
- private StringBuffer stringValueAux(StringBuffer buffer, final int
element) {
- for (int child = _offsetOrChild[element];
- child != NULL;
- child = _nextSibling[child]) {
- switch (_type[child]) {
- case TEXT:
- buffer.append(_text,
- _offsetOrChild[child],
- _lengthOrAttr[child]);
- break;
- case PROCESSING_INSTRUCTION:
- case COMMENT:
- // This method should not return anything for PIs and comments
- break;
- default:
- stringValueAux(buffer, child);
- }
- }
- return buffer;
+ private StringBuffer stringValueAux(StringBuffer buffer, final int
element)
+ {
+ for (int child = getFirstChild(element);
+ child != DTM.NULL;
+ child = getNextSibling(child)) {
+ switch (getNodeType(child))
+ {
+ case DTM.COMMENT_NODE:
+ break;
+ case DTM.TEXT_NODE:
+ buffer.append(getStringValue(child).toString());/*_text,
+ _offsetOrChild[child],
+ _lengthOrAttr[child]);*/
+ break;
+ case DTM.PROCESSING_INSTRUCTION_NODE:
+ /* This method should not return anything for PIs
+ buffer.append(_text,
+ _offsetOrChild[child],
+ _lengthOrAttr[child]);
+ */
+ break;
+ default:
+ stringValueAux(buffer, child);
+ }
+ }
+ return buffer;
+
}
public String getTreeString() {
StringBuffer buf = new StringBuffer();
- buf = getElementString(buf, ROOTNODE);
+ buf = getElementString(buf, getDocument());
return buf.toString();
}
@@ -2854,7 +3163,7 @@
if ((name = getNodeName(element)) != null) {
buffer.append('<');
buffer.append(name);
- if (_offsetOrChild[element] == NULL) {
+ if (getFirstChild(element) == DTM.NULL) {
buffer.append("/>");
return buffer;
}
@@ -2862,27 +3171,27 @@
}
}
- for (int child = _offsetOrChild[element];
- child != NULL;
- child = _nextSibling[child]) {
- switch (_type[child]) {
- case COMMENT:
+ for (int child = getFirstChild(element);
+ child != DTM.NULL;
+ child = getNextSibling(child)) {
+ switch (getNodeType(child)) {
+ case DTM.COMMENT_NODE:
buffer.append("<!--");
- buffer.append(_text,
+
buffer.append(buffer.append(getStringValue(child).toString()));/*_text,
_offsetOrChild[child],
- _lengthOrAttr[child]);
+ _lengthOrAttr[child]);*/
buffer.append("-->");
break;
- case TEXT:
- buffer.append(_text,
+ case DTM.TEXT_NODE:
+
buffer.append(buffer.append(getStringValue(child).toString()));/*_text,
_offsetOrChild[child],
- _lengthOrAttr[child]);
+ _lengthOrAttr[child]);*/
break;
- case PROCESSING_INSTRUCTION:
+ case DTM.PROCESSING_INSTRUCTION_NODE:
buffer.append("<?");
- buffer.append(_text,
+
buffer.append(buffer.append(getStringValue(child).toString()));/*_text,
_offsetOrChild[child],
- _lengthOrAttr[child]);
+ _lengthOrAttr[child]);*/
buffer.append("?>");
break;
default:
@@ -2895,36 +3204,40 @@
buffer.append(name);
buffer.append(">");
}
-
return buffer;
}
/**
* Returns a node' defined language for a node (if any)
*/
- public String getLanguage(int node) {
- final Integer langType = (Integer)_types.get(XML_LANG_ATTRIBUTE);
- if (langType != null) {
- final int type = langType.intValue();
- while (node != DOM.NULL) {
- int attr = _lengthOrAttr[node];
- while (attr != DOM.NULL) {
- if (_type[attr] == type)
- return(getNodeValue(attr));
- attr = _nextSibling[attr];
- }
- node = getParent(node);
- }
- }
- return(null);
+ public String getLanguage(int node)
+ {
+ int parent = node;
+ while (DTM.NULL != parent)
+ {
+ if (DTM.ELEMENT_NODE == getNodeType(parent))
+ {
+ int langAttr = getAttributeNode(parent,
"http://www.w3.org/XML/1998/namespace", "lang");
+
+ if (DTM.NULL != langAttr)
+ {
+ return getNodeValue(langAttr);
+ }
+ }
+
+ parent = getParent(parent);
+ }
+ return(null);
}
+
/**
* Returns an instance of the DOMBuilder inner class
* This class will consume the input document through a SAX2
* interface and populate the tree.
*/
- public DOMBuilder getBuilder() {
+ public DOMBuilder getBuilder()
+ {
return new DOMBuilderImpl();
}
@@ -2933,8 +3246,20 @@
* I am not sure if we need this one anymore now that the
* DOM builder's interface is pure SAX2 (must investigate)
*/
- public TransletOutputHandler getOutputDomBuilder() {
- return new SAXAdapter(new DOMBuilderImpl());
+ public TransletOutputHandler getOutputDomBuilder()
+ {
+ //DOMBuilder builder = getBuilder();
+ // return new SAXAdapter(builder, builder);
+ return new SAXAdapter(new DOMBuilderImpl());
+ }
+
+ /**
+ * Return a instance of a DOM class to be used as an RTF
+ */
+ public DOM getResultTreeFrag()
+ {
+ return ((SAXImpl)m_mgr.getDTM(null, true, m_wsfilter, false, false));
+
}
/**
@@ -2949,7 +3274,9 @@
/****************************************************************/
/* DOM builder class definition */
/****************************************************************/
- private final class DOMBuilderImpl implements DOMBuilder {
+ private final class DOMBuilderImpl implements DOMBuilder
+ // I think this may not even be needed for the DOM case???
+ {
private final static int ATTR_ARRAY_SIZE = 32;
private final static int REUSABLE_TEXT_SIZE = 32;
@@ -2961,7 +3288,7 @@
private int _nextNameCode = NTYPES;
private int _parentStackLength = INIT_STACK_LENGTH;
private int[] _parentStack = new int[INIT_STACK_LENGTH];
- private int[] _previousSiblingStack = new int[INIT_STACK_LENGTH];
+ //private int[] _previousSiblingStack = new int[INIT_STACK_LENGTH];
private int _sp;
private int _baseOffset = 0;
private int _currentOffset = 0;
@@ -3002,75 +3329,87 @@
/**
* Default constructor for the DOMBuiler class
*/
- public DOMBuilderImpl() {
- _xmlSpaceStack[0] = DOM.ROOTNODE;
+ public DOMBuilderImpl()
+ {
+ _xmlSpaceStack[0] = DTMDefaultBase.ROOTNODE;
}
/**
* Returns the namespace URI that a prefix currently maps to
*/
- private String getNamespaceURI(String prefix) {
- // Get the stack associated with this namespace prefix
- final Stack stack = (Stack)_nsPrefixes.get(prefix);
- if ((stack != null) && (!stack.empty())) {
- return((String)stack.peek());
- }
- else
- return(EMPTYSTRING);
- }
+ private String getNamespaceURI(String prefix)
+ {
+ // Get the stack associated with this namespace prefix
+ final Stack stack = (Stack)_nsPrefixes.get(prefix);
+ if ((stack != null) && (!stack.empty()))
+ {
+ return((String)stack.peek());
+ }
+ else
+ return(EMPTYSTRING);
+ }
/**
* Call this when an xml:space attribute is encountered to
* define the whitespace strip/preserve settings.
*/
- private void xmlSpaceDefine(String val, final int node) {
- final boolean setting = val.equals(PRESERVE_STRING);
- if (setting != _preserve) {
- _xmlSpaceStack[_idx++] = node;
- _preserve = setting;
- }
- }
+ private void xmlSpaceDefine(String val, final int node)
+ {
+ final boolean setting = val.equals(PRESERVE_STRING);
+ if (setting != _preserve)
+ {
+ _xmlSpaceStack[_idx++] = node;
+ _preserve = setting;
+ }
+ }
/**
* Call this from endElement() to revert strip/preserve setting
* to whatever it was before the corresponding startElement()
*/
- private void xmlSpaceRevert(final int node) {
- if (node == _xmlSpaceStack[_idx - 1]) {
- _idx--;
- _preserve = !_preserve;
- }
- }
+ private void xmlSpaceRevert(final int node)
+ {
+ if (node == _xmlSpaceStack[_idx - 1])
+ {
+ _idx--;
+ _preserve = !_preserve;
+ }
+ }
/**
* Returns the next available node. Increases the various arrays
* that constitute the node if necessary.
*/
- private int nextNode() {
- final int index = _currentNode++;
- if (index == _type.length) {
- resizeArrays(_type.length * 2, index);
- }
- return index;
- }
+ private int nextNode()
+ {
+ final int index = _currentNode++;
+ /* if (index == _names.length + DTM.NTYPES) //_type.length)
+ {
+ resizeArrays((_names.length + DTM.NTYPES) * 2, index);
+ } */
+ return index;
+ }
/**
* Returns the next available attribute node. Increases the
* various arrays that constitute the attribute if necessary
*/
- private int nextAttributeNode() {
- final int index = _currentAttributeNode++;
- if (index == _type2.length) {
- resizeArrays2(_type2.length * 2, index);
- }
- return index;
- }
+ private int nextAttributeNode()
+ {
+ final int index = _currentAttributeNode++;
+ if (index == _type2.length)
+ {
+ resizeArrays2(_type2.length * 2, index);
+ }
+ return index;
+ }
/**
* Resize the character array that holds the contents of
* all text nodes, comments and attribute values
*/
- private void resizeTextArray(final int newSize) {
+ private void resizeTextArray(final int newSize)
+ {
final char[] newText = new char[newSize];
System.arraycopy(_text, 0, newText, 0, _currentOffset);
_text = newText;
@@ -3079,91 +3418,106 @@
/**
* Links together the children of a node. Child nodes are linked
* through the _nextSibling array
- */
- private void linkChildren(final int node) {
- _parent[node] = _parentStack[_sp];
- if (_previousSiblingStack[_sp] != 0) { // current not first child
- _nextSibling[_previousSiblingStack[_sp]] = node;
- }
- else {
- _offsetOrChild[_parentStack[_sp]] = node;
- }
- _previousSiblingStack[_sp] = node;
- }
+ *
+ private void linkChildren(final int node)
+ {
+ _parent[node] = _parentStack[_sp];
+ if (_previousSiblingStack[_sp] != 0)
+ { // current not first child
+ _nextSibling[_previousSiblingStack[_sp]] = node;
+ }
+ else
+ {
+ _offsetOrChild[_parentStack[_sp]] = node;
+ }
+ _previousSiblingStack[_sp] = node;
+ } */
/**
* Sets the current parent
*/
- private void linkParent(final int node) {
- if (++_sp >= _parentStackLength) {
- int length = _parentStackLength;
- _parentStackLength = length + INIT_STACK_LENGTH;
-
- final int newParent[] = new int[_parentStackLength];
- System.arraycopy(_parentStack,0,newParent,0,length);
- _parentStack = newParent;
-
- final int newSibling[] = new int[_parentStackLength];
- System.arraycopy(_previousSiblingStack,0,newSibling,0,length);
- _previousSiblingStack = newSibling;
- }
- _parentStack[_sp] = node;
- }
+ private void linkParent(final int node)
+ {
+ if (++_sp >= _parentStackLength)
+ {
+ int length = _parentStackLength;
+ _parentStackLength = length + INIT_STACK_LENGTH;
+
+ final int newParent[] = new int[_parentStackLength];
+ System.arraycopy(_parentStack,0,newParent,0,length);
+ _parentStack = newParent;
+
+ // final int newSibling[] = new int[_parentStackLength];
+ // System.arraycopy(_previousSiblingStack,0,newSibling,0,length);
+ // _previousSiblingStack = newSibling;
+ }
+ _parentStack[_sp] = node;
+ }
/**
* Generate the internal type for an element's expanded QName
*/
private short makeElementNode(String uri, String localname)
- throws SAXException {
- final String name;
- if (uri != EMPTYSTRING)
- name = uri + ':' + localname;
- else
- name = localname;
- // Stuff the QName into the names vector & hashtable
- Integer obj = (Integer)_names.get(name);
- if (obj == null) {
- _names.put(name, obj = new Integer(_nextNameCode++));
- }
- return (short)obj.intValue();
- }
+ throws SAXException
+ {
+
+ final String name;
+ if (uri != EMPTYSTRING)
+ name = uri + ':' + localname;
+ else
+ name = localname;
+
+ // Stuff the QName into the names vector & hashtable
+ Integer obj = (Integer)_names.get(name);
+ if (obj == null)
+ {
+ _names.put(name, obj = new Integer(_nextNameCode++));
+ }
+ return (short)obj.intValue();
+ }
/**
* Generate the internal type for an element's expanded QName
*/
private short makeElementNode(String name, int col)
- throws SAXException {
- // Expand prefix:localname to full QName
- if (col > -1) {
- final String uri = getNamespaceURI(name.substring(0, col));
- name = uri + name.substring(col);
- }
- // Append default namespace with the name has no prefix
- else {
- final String uri = getNamespaceURI(EMPTYSTRING);
- if (!uri.equals(EMPTYSTRING)) name = uri + ':' + name;
- }
-
- // Stuff the QName into the names vector & hashtable
- Integer obj = (Integer)_names.get(name);
- if (obj == null) {
- _names.put(name, obj = new Integer(_nextNameCode++));
- }
- return (short)obj.intValue();
- }
+ throws SAXException
+ {
+ // Expand prefix:localname to full QName
+ if (col > -1)
+ {
+ final String uri = getNamespaceURI(name.substring(0, col));
+ name = uri + name.substring(col);
+ }
+ // Append default namespace with the name has no prefix
+ else
+ {
+ final String uri = getNamespaceURI(EMPTYSTRING);
+ if (!uri.equals(EMPTYSTRING)) name = uri + ':' + name;
+ }
+
+ // Stuff the QName into the names vector & hashtable
+ Integer obj = (Integer)_names.get(name);
+ if (obj == null)
+ {
+ _names.put(name, obj = new Integer(_nextNameCode++));
+ }
+ return (short)obj.intValue();
+ }
/**
*
*/
- private short registerPrefix(String prefix) {
- Stack stack = (Stack)_nsPrefixes.get(prefix);
- if (stack != null) {
- Integer obj = (Integer)stack.elementAt(0);
- return (short)obj.intValue();
- }
- return 0;
- }
+ private short registerPrefix(String prefix)
+ {
+ Stack stack = (Stack)_nsPrefixes.get(prefix);
+ if (stack != null)
+ {
+ Integer obj = (Integer)stack.elementAt(0);
+ return (short)obj.intValue();
+ }
+ return 0;
+ }
/*
* This method will check if the current text node contains text that
@@ -3173,31 +3527,36 @@
* offset of the new instance is inserted.
* Updates the globals _baseOffset and _currentOffset
*/
- private int maybeReuseText(final int length) {
- final int base = _baseOffset;
- if (length <= REUSABLE_TEXT_SIZE) {
- // Use a char array instead of string for performance benefit
- char[] chars = new char[length];
- System.arraycopy(_text, base, chars, 0, length);
- final Integer offsetObj = (Integer)_shortTexts.get(chars);
-
- if (offsetObj != null) {
- _currentOffset = base; // step back current
- return offsetObj.intValue(); // reuse previous string
- }
- else {
- _shortTexts.put(chars, new Integer(base));
- }
- }
- _baseOffset = _currentOffset; // advance base to current
- return base;
- }
+ private int maybeReuseText(final int length)
+ {
+ final int base = _baseOffset;
+ if (length <= REUSABLE_TEXT_SIZE)
+ {
+ // Use a char array instead of string for performance benefit
+ char[] chars = new char[length];
+ System.arraycopy(_text, base, chars, 0, length);
+ final Integer offsetObj = (Integer)_shortTexts.get(chars);
+
+ if (offsetObj != null)
+ {
+ _currentOffset = base; // step back current
+ return offsetObj.intValue(); // reuse previous string
+ }
+ else
+ {
+ _shortTexts.put(chars, new Integer(base));
+ }
+ }
+ _baseOffset = _currentOffset; // advance base to current
+ return base;
+ }
/**
* Links a text reference (an occurance of a sequence of characters
* in the _text[] array) to a specific node index.
*/
- private void storeTextRef(final int node) {
+ private void storeTextRef(final int node)
+ {
final int length = _currentOffset - _baseOffset;
_offsetOrChild[node] = maybeReuseText(length);
_lengthOrAttr[node] = length;
@@ -3205,56 +3564,71 @@
/**
* Creates a text-node and checks if it is a whitespace node.
- */
- private int makeTextNode(boolean isWhitespace) {
- if (_currentOffset > _baseOffset) {
+ */
+ private int makeTextNode(boolean isWhitespace)
+ {
+ //if (_currentOffset > _baseOffset)
+ {
+ final int node = getNumberOfNodes()-1; //nextNode();
+ // System.out.println("text ");
+ //for (int i = 0; i< _text.length; i++)
+// System.out.print( _text[_currentOffset]);
+ //final int limit = _currentOffset;
+ // Tag as whitespace node if the parser tells us that it is...
+ if (isWhitespace)
+ {
+ _whitespace.setBit(node);
+ }
+ // ...otherwise we check if this is a whitespace node, unless
+ // the node is protected by an xml:space="preserve" attribute.
+ else if (!_preserve)
+ {
+ while (_currentNode < node)
+ {
+ int nodeh = makeNodeHandle(++_currentNode);
+ if(getNodeType(nodeh) == DTM.TEXT_NODE)
+ {
+ int i = 0; //_baseOffset;
+ char[] chars = getNodeValue(nodeh).toCharArray();
+ final int limit = chars.length;
+ // while (isWhitespaceChar(_text[i++]) && i < limit);
+ while (isWhitespaceChar(chars[i++]) && i < limit);
+ // if ((i == limit) && isWhitespaceChar(_text[i-1]))
+ if ((i == limit) && isWhitespaceChar(chars[i-1]))
+ {
+ //System.out.println("<<<set bit2 " +
SAXImpl.this.getNodeIdent(node)+ " " + node);
+ _whitespace.setBit(_currentNode);
+ }
+ }
+ }
+ }
+ //_type[node] = DTM.TEXT_NODE;
+ // _types.put(new Integer(getExpandedTypeID(node)), new
Integer(DTM.TEXT_NODE));
+ //linkChildren(node);
+ storeTextRef(node);
+ return node;
+ }
+ //return -1;
+ }
- final int node = nextNode();
- final int limit = _currentOffset;
- // Tag as whitespace node if the parser tells us that it is...
- if (isWhitespace) {
- _whitespace.setBit(node);
- }
- // ...otherwise we check if this is a whitespace node, unless
- // the node is protected by an xml:space="preserve" attribute.
- else if (!_preserve) {
- int i = _baseOffset;
- while (isWhitespaceChar(_text[i++]) && i < limit) ;
- if ((i == limit) && isWhitespaceChar(_text[i-1])) {
- _whitespace.setBit(node);
- }
- }
- _type[node] = TEXT;
- linkChildren(node);
- storeTextRef(node);
-
- if (_disableEscaping) {
- if (_dontEscape == null) {
- _dontEscape = new BitArray(_whitespace.size());
- }
- _dontEscape.setBit(node);
- _disableEscaping = false;
- }
- return node;
- }
- return -1;
- }
/**
* Links an attribute value (an occurance of a sequence of characters
* in the _text[] array) to a specific attribute node index.
*/
- private void storeAttrValRef(final int attributeNode) {
+ private void storeAttrValRef(final int attributeNode)
+ {
final int length = _currentOffset - _baseOffset;
_offset[attributeNode] = maybeReuseText(length);
_length[attributeNode] = length;
}
private int makeNamespaceNode(String prefix, String uri)
- throws SAXException {
+ throws SAXException
+ {
final int node = nextAttributeNode();
- _type2[node] = NAMESPACE;
+ _type2[node] = DTM.NAMESPACE_NODE;
characters(uri);
storeAttrValRef(node);
return node;
@@ -3263,49 +3637,60 @@
/**
* Creates an attribute node
*/
- private int makeAttributeNode(int parent, Attributes attList, int i)
- throws SAXException
- {
- final int node = nextAttributeNode();
- final String qname = attList.getQName(i);
- String localname = attList.getLocalName(i);
- final String value = attList.getValue(i);
- StringBuffer namebuf = new StringBuffer(EMPTYSTRING);
-
- if (qname.startsWith(XMLSPACE_STRING)) {
- xmlSpaceDefine(attList.getValue(i), parent);
- }
-
- // Create the internal attribute node name ([EMAIL PROTECTED])
- final String uri = attList.getURI(i);
- if (uri != null && !uri.equals(EMPTYSTRING)) {
- namebuf.append(uri);
- namebuf.append(':');
- }
- namebuf.append('@');
- namebuf.append(localname.length() > 0 ? localname : qname);
-
- String name = namebuf.toString();
-
- // Get the index of the attribute node name (create new if non-ex).
- Integer obj = (Integer)_names.get(name);
- if (obj == null) {
- _type2[node] = (short)_nextNameCode;
- _names.put(name, obj = new Integer(_nextNameCode++));
- }
- else {
- _type2[node] = (short)obj.intValue();
- }
+ private int makeAttributeNode(int parent, Attributes attList, int i)
+ throws SAXException
+ {
+
+ final int node = nextAttributeNode();
+
+ final String qname = attList.getQName(i);
+ final String localname = attList.getLocalName(i);
+ final String value = attList.getValue(i);
+ StringBuffer namebuf = new StringBuffer(EMPTYSTRING);
+
+ // Create the internal attribute node name ([EMAIL PROTECTED])
+ // if (qname.startsWith(XML_STRING))
+ //{
+ if (qname.startsWith(XMLSPACE_STRING))
+ xmlSpaceDefine(attList.getValue(i), parent);
+ //}
+ final String uri = attList.getURI(i);
+ if ((uri != null) && (!uri.equals(EMPTYSTRING)))
+ {
+ namebuf.append(uri);
+ namebuf.append(':');
+ }
+ namebuf.append('@');
+ if (localname != null )
+ namebuf.append(localname);
+ else
+ namebuf.append(qname);
- final int col = qname.lastIndexOf(':');
- if (col > 0) {
- _prefix2[node] = registerPrefix(qname.substring(0, col));
- }
+ String name = namebuf.toString();
+
+ // Get the index of the attribute node name (create new if non-ex).
+ Integer obj = (Integer)_names.get(name);
+ if (obj == null)
+ {
+ _type2[node] = (short)_nextNameCode;
+ _names.put(name, obj = new Integer(_nextNameCode++));
+ }
+ else
+ {
+ _type2[node] = (short)obj.intValue();
+ }
+
+ final int col = qname.lastIndexOf(':');
+ if (col > 0)
+ {
+ _prefix2[node] = registerPrefix(qname.substring(0, col));
+ }
+
+ characters(attList.getValue(i));
+ storeAttrValRef(node);
+ return node;
+ }
- characters(attList.getValue(i));
- storeAttrValRef(node);
- return node;
- }
/****************************************************************/
/* SAX Interface Starts Here */
@@ -3328,178 +3713,188 @@
}
+
/**
* SAX2: Receive notification of the beginning of a document.
*/
- public void startDocument() throws SAXException {
+ public void startDocument() throws SAXException
+ {
_shortTexts = new Hashtable();
_names = new Hashtable();
_sp = 0;
- _parentStack[0] = ROOTNODE; // root
- _currentNode = ROOTNODE + 1;
+ _parentStack[0] = DTMDefaultBase.ROOTNODE; // root
+ _currentNode = DTMDefaultBase.ROOTNODE + 1;
_currentAttributeNode = 1;
- _type2[0] = NAMESPACE;
+ _type2[0] = DTM.NAMESPACE_NODE;
startPrefixMapping(EMPTYSTRING, EMPTYSTRING);
+
startPrefixMapping(XML_PREFIX,
"http://www.w3.org/XML/1998/namespace");
- _lengthOrAttr[ROOTNODE] = _nextNamespace;
- _parent2[_nextNamespace] = ROOTNODE;
- _nextNamespace = DOM.NULL;
+ _lengthOrAttr[DTMDefaultBase.ROOTNODE] = _nextNamespace;
+ _parent2[_nextNamespace] = DTMDefaultBase.ROOTNODE;
+ _nextNamespace = DTM.NULL;
+
}
/**
* SAX2: Receive notification of the end of a document.
*/
- public void endDocument() {
- makeTextNode(false);
-
- _shortTexts = null;
- final int namesSize = _nextNameCode - NTYPES;
-
- // Fill the _namesArray[] array
- _namesArray = new String[namesSize];
- Enumeration keys = _names.keys();
- while (keys.hasMoreElements()) {
- final String name = (String)keys.nextElement();
- final Integer idx = (Integer)_names.get(name);
- _namesArray[idx.intValue() - NTYPES] = name;
- }
+ public void endDocument()
+ {
+ makeTextNode(false);
+
+ _shortTexts = null;
+ final int namesSize = _nextNameCode - DTM.NTYPES;
+
+ // Fill the _namesArray[] array
+ _namesArray = new String[namesSize];
+ Enumeration keys = _names.keys();
+ while (keys.hasMoreElements())
+ {
+ final String name = (String)keys.nextElement();
+ final Integer idx = (Integer)_names.get(name);
+ _namesArray[idx.intValue() - DTM.NTYPES] = name;
+ }
- _names = null;
- _types = setupMapping(_namesArray);
+ _names = null;
+ _types = setupMapping(_namesArray);
- // trim arrays' sizes
- resizeTextArray(_currentOffset);
-
- _firstAttributeNode = _currentNode;
- shiftAttributes(_currentNode);
- resizeArrays(_currentNode + _currentAttributeNode, _currentNode);
- appendAttributes();
- _treeNodeLimit = _currentNode + _currentAttributeNode;
-
- // Fill the _namespace[] and _uriArray[] array
- _namespace = new short[namesSize];
- _uriArray = new String[_uriCount];
- for (int i = 0; i<namesSize; i++) {
- final String qname = _namesArray[i];
- final int col = _namesArray[i].lastIndexOf(':');
- // Elements/attributes with the xml prefix are not in a NS
- if ((!qname.startsWith(XML_STRING)) && (col > -1)) {
- final String uri = _namesArray[i].substring(0, col);
- final Integer idx = (Integer)_nsIndex.get(uri);
- if (idx != null) {
- _namespace[i] = idx.shortValue();
- _uriArray[idx.intValue()] = uri;
- }
- }
- }
+ // trim arrays' sizes
+ resizeTextArray(_currentOffset);
+
+ _firstAttributeNode = _currentNode;
+ shiftAttributes(_currentNode);
+ resizeArrays(_currentNode + _currentAttributeNode, _currentNode);
+ appendAttributes();
+ _treeNodeLimit = _currentNode + _currentAttributeNode;
+
+ // Fill the _namespace[] and _uriArray[] array
+ _namespace = new short[namesSize];
+ _uriArray = new String[_uriCount];
+ for (int i = 0; i<namesSize; i++)
+ {
+ final String qname = _namesArray[i];
+ final int col = _namesArray[i].lastIndexOf(':');
+ // Elements/attributes with the xml prefix are not in a NS
+ if ((!qname.startsWith(XML_STRING)) && (col > -1))
+ {
+ final String uri = _namesArray[i].substring(0, col);
+ Integer eType = new Integer (getExpandedTypeID(uri,
(String)_prefixArray.get(uri), DTM.NAMESPACE_NODE));
+ final Integer idx = (Integer)_nsIndex.get(eType);
+ if (idx != null)
+ {
+ _namespace[i] = idx.shortValue();
+ _uriArray[idx.intValue()] = uri;
+ }
+ }
+ }
- _prefixArray = new String[_prefixCount];
- Enumeration p = _nsPrefixes.keys();
- while (p.hasMoreElements()) {
- final String prefix = (String)p.nextElement();
- final Stack stack = (Stack)_nsPrefixes.get(prefix);
- final Integer I = (Integer)stack.elementAt(0);
- _prefixArray[I.shortValue()] = prefix;
- }
- }
+ _prefixArray = new Hashtable(); //String[_prefixCount];
+ Enumeration p = _nsPrefixes.keys();
+ while (p.hasMoreElements())
+ {
+ final String prefix = (String)p.nextElement();
+ final Stack stack = (Stack)_nsPrefixes.get(prefix);
+ final Integer I = (Integer)stack.elementAt(0);
+ //_prefixArray[I.shortValue()] = prefix;
+ }
+ }
/**
* SAX2: Receive notification of the beginning of an element.
*/
public void startElement(String uri, String localName,
String qname, Attributes attributes)
- throws SAXException {
-
- makeTextNode(false);
-
- // Get node index and setup parent/child references
- final int node = nextNode();
- linkChildren(node);
- linkParent(node);
-
- _lengthOrAttr[node] = DOM.NULL;
-
- int last = -1;
- final int count = attributes.getLength();
-
- // Append any namespace nodes
- if (_nextNamespace != DOM.NULL) {
- _lengthOrAttr[node] = _nextNamespace;
-
- while (_nextNamespace != DOM.NULL) {
- _parent2[_nextNamespace] = node;
- _nextNamespace = _nextSibling2[last = _nextNamespace];
- // Chain last namespace node to following attribute node(s)
- if (_nextNamespace == DOM.NULL && count > 0) {
- _nextSibling2[last] = _currentAttributeNode;
- }
- }
- }
-
- // Append any attribute nodes
- boolean attrsAdded = false;
- if (count > 0) {
- int attr = _currentAttributeNode;
- if (_lengthOrAttr[node] == DOM.NULL) {
- _lengthOrAttr[node] = attr;
- }
- for (int i = 0; i < count; i++) {
- if (!attributes.getQName(i).startsWith(XMLNS_PREFIX)) {
- attr = makeAttributeNode(node, attributes, i);
- _parent2[attr] = node;
- _nextSibling2[attr] = attr + 1;
- attrsAdded = true;
- }
- }
- // Did we append namespace nodes only?
- if (!attrsAdded && last != -1) {
- _nextSibling2[last] = DOM.NULL;
- }
- else {
- _nextSibling2[attr] = DOM.NULL;
- }
- }
+ throws SAXException
+ {
- final int col = qname.lastIndexOf(':');
+ makeTextNode(false);
- // Assign an internal type to this element (may exist)
- if (uri != null && localName.length() > 0) {
- _type[node] = makeElementNode(uri, localName);
- }
- else {
- _type[node] = makeElementNode(qname, col);
- }
+ // Get node index and setup parent/child references
+ final int node = nextNode();
+ //linkChildren(node);
+ linkParent(node);
+
+ _lengthOrAttr[node] = DTM.NULL;
+
+ final int count = attributes.getLength();
+
+ // Append any namespace nodes
+ if (_nextNamespace != DTM.NULL)
+ {
+ _lengthOrAttr[node] = _nextNamespace;
+ while (_nextNamespace != DTM.NULL)
+ {
+ _parent2[_nextNamespace] = node;
+ int tail = _nextNamespace;
+ _nextNamespace = _nextSibling2[_nextNamespace];
+ // Chain last namespace node to following attribute node(s)
+ if ((_nextNamespace == DTM.NULL) && (count > 0))
+ _nextSibling2[tail] = _currentAttributeNode;
+ }
+ }
+
+ // Append any attribute nodes
+ if (count > 0)
+ {
+ int attr = _currentAttributeNode;
+ if (_lengthOrAttr[node] == DTM.NULL)
+ _lengthOrAttr[node] = attr;
+ for (int i = 0; i<count; i++)
+ {
+ attr = makeAttributeNode(node, attributes, i);
+ _parent2[attr] = node;
+ _nextSibling2[attr] = attr + 1;
+ }
+ _nextSibling2[attr] = DTM.NULL;
+ }
+
+ final int col = qname.lastIndexOf(':');
+
+ // Assign an internal type to this element (may exist)
+ if ((uri != null) && (localName.length() > 0))
+ //_type[node] =
+ makeElementNode(uri, localName);
+ else
+ //_type[node] =
+ makeElementNode(qname, col);
+
+ // Assign an internal type to the element's prefix (may exist)
+ // if (col > -1)
+ // {
+ // _prefix[node] = registerPrefix(qname.substring(0, col));
+ // }
+ }
- // Assign an internal type to the element's prefix (may exist)
- if (col > -1) {
- _prefix[node] = registerPrefix(qname.substring(0, col));
- }
- }
/**
* SAX2: Receive notification of the end of an element.
*/
- public void endElement(String uri, String localName,
- String qname) {
+
+ public void endElement(String namespaceURI, String localName,
+ String qname)
+ {
+
makeTextNode(false);
// Revert to strip/preserve-space setting from before this element
xmlSpaceRevert(_parentStack[_sp]);
- _previousSiblingStack[_sp--] = 0;
+ //_previousSiblingStack[_sp--] = 0;
}
/**
* SAX2: Receive notification of a processing instruction.
*/
public void processingInstruction(String target, String data)
- throws SAXException {
+ throws SAXException
+ {
makeTextNode(false);
final int node = nextNode();
- _type[node] = PROCESSING_INSTRUCTION;
- linkChildren(node);
+ //_type[node] =
+ //_types.put (new Integer(getExpandedTypeID(node)), new
Integer(DTM.PROCESSING_INSTRUCTION_NODE));
+ //linkChildren(node);
characters(target);
characters(" ");
characters(data);
@@ -3510,27 +3905,31 @@
* SAX2: Receive notification of ignorable whitespace in element
* content. Similar to characters(char[], int, int).
*/
- public void ignorableWhitespace(char[] ch, int start, int length) {
- if (_currentOffset + length > _text.length) {
- resizeTextArray(_text.length * 2);
- }
- System.arraycopy(ch, start, _text, _currentOffset, length);
- _currentOffset += length;
- makeTextNode(true);
- }
+ public void ignorableWhitespace(char[] ch, int start, int length)
+ {
+ if (_currentOffset + length > _text.length)
+ {
+ resizeTextArray(_text.length * 2);
+ }
+ System.arraycopy(ch, start, _text, _currentOffset, length);
+ _currentOffset += length;
+ makeTextNode(true);
+ }
/**
* SAX2: Receive an object for locating the origin of SAX document
* events.
*/
- public void setDocumentLocator(Locator locator) {
+ public void setDocumentLocator(Locator locator)
+ {
// Not handled
}
/**
* SAX2: Receive notification of a skipped entity.
*/
- public void skippedEntity(String name) {
+ public void skippedEntity(String name)
+ {
// Not handled
}
@@ -3538,58 +3937,68 @@
* SAX2: Begin the scope of a prefix-URI Namespace mapping.
*/
public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
+ throws SAXException
+ {
- // Get the stack associated with this namespace prefix
- Stack stack = (Stack)_nsPrefixes.get(prefix);
- if (stack == null) {
- stack = new Stack();
- stack.push(new Integer(_prefixCount++));
- _nsPrefixes.put(prefix, stack);
- }
-
- // Check if the URI already exists before pushing on stack
- Integer idx;
- if ((idx = (Integer)_nsIndex.get(uri)) == null) {
- _nsIndex.put(uri, idx = new Integer(_uriCount++));
- }
- stack.push(uri);
-
- if (!prefix.equals(EMPTYSTRING) || !uri.equals(EMPTYSTRING)) {
- makeTextNode(false);
- int attr = makeNamespaceNode(prefix, uri);
- if (_nextNamespace == DOM.NULL)
- _nextNamespace = attr;
- else
- _nextSibling2[attr-1] = attr;
- _nextSibling2[attr] = DOM.NULL;
- // _prefix2[attr] = idx.shortValue();
+ // Get the stack associated with this namespace prefix
+ Stack stack = (Stack)_nsPrefixes.get(prefix);
+ if (stack == null)
+ {
+ stack = new Stack();
+ stack.push(new Integer(_prefixCount++));
+ _nsPrefixes.put(prefix, stack);
+ }
+
+ // Check if the URI already exists before pushing on stack
+ Integer idx;
+ Integer eType = new Integer (getExpandedTypeID(uri,
(String)_prefixArray.get(uri), DTM.NAMESPACE_NODE));
+ if ((idx = (Integer)_nsIndex.get(eType)) == null)
+ {
+ _prefixArray.put(uri, prefix);
+ _nsIndex.put(eType, idx = new Integer(_uriCount++));
+ }
+ stack.push(uri);
+
+ if (!prefix.equals(EMPTYSTRING) || !uri.equals(EMPTYSTRING)) {
+ makeTextNode(false);
+ int attr = makeNamespaceNode(prefix, uri);
+ if (_nextNamespace == DTM.NULL)
+ _nextNamespace = attr;
+ else
+ _nextSibling2[attr-1] = attr;
+ _nextSibling2[attr] = DTM.NULL;
+ // _prefix2[attr] = idx.shortValue();
_prefix2[attr] = ((Integer) stack.elementAt(0)).shortValue();
}
- }
+ }
+
+ /**
+ * SAX2: End the scope of a prefix-URI Namespace mapping.
+ */
+ public void endPrefixMapping(String prefix)
+ {
+ // Get the stack associated with this namespace prefix
+ final Stack stack = (Stack)_nsPrefixes.get(prefix);
+ if ((stack != null) && (!stack.empty())) stack.pop();
+ }
- /**
- * SAX2: End the scope of a prefix-URI Namespace mapping.
- */
- public void endPrefixMapping(String prefix) {
- // Get the stack associated with this namespace prefix
- final Stack stack = (Stack)_nsPrefixes.get(prefix);
- if ((stack != null) && (!stack.empty())) stack.pop();
- }
/**
* SAX2: Report an XML comment anywhere in the document.
*/
- public void comment(char[] ch, int start, int length) {
- makeTextNode(false);
- if (_currentOffset + length > _text.length) {
- resizeTextArray(_text.length * 2);
- }
- System.arraycopy(ch, start, _text, _currentOffset, length);
- _currentOffset += length;
- final int node = makeTextNode(false);
- _type[node] = COMMENT;
- }
+ public void comment(char[] ch, int start, int length)
+ {
+ makeTextNode(false);
+ if (_currentOffset + length > _text.length)
+ {
+ resizeTextArray(_text.length * 2);
+ }
+ System.arraycopy(ch, start, _text, _currentOffset, length);
+ _currentOffset += length;
+ final int node = makeTextNode(false);
+ //_type[node] =
+ //_types.put(new Integer(getExpandedTypeID(node)), new
Integer(DTM.COMMENT_NODE));
+ }
/**
* SAX2: Ignored events
@@ -3605,9 +4014,10 @@
* Similar to the SAX2 method character(char[], int, int), but this
* method takes a string as its only parameter. The effect is the same.
*/
- private void characters(final String string) {
- final int length = string.length();
- if (_currentOffset + length > _text.length) {
+ private void characters(final String string)
+ {
+ final int length = string.length();
+ if (_currentOffset + length > _text.length) {
// GTM: resizeTextArray(_text.length * 2);
// bug fix 6189, contributed by Mirko Seifert
resizeTextArray(
@@ -3615,113 +4025,118 @@
}
string.getChars(0, length, _text, _currentOffset);
_currentOffset += length;
- }
+ }
- private void resizeArrays(final int newSize, int length) {
- if ((length < newSize) && (newSize == _currentNode))
- length = _currentNode;
-
- // Resize the '_type' array
- final short[] newType = new short[newSize];
- System.arraycopy(_type, 0, newType, 0, length);
- _type = newType;
-
- // Resize the '_parent' array
- final int[] newParent = new int[newSize];
- System.arraycopy(_parent, 0, newParent, 0, length);
- _parent = newParent;
-
- // Resize the '_nextSibling' array
- final int[] newNextSibling = new int[newSize];
- System.arraycopy(_nextSibling, 0, newNextSibling, 0, length);
- _nextSibling = newNextSibling;
-
- // Resize the '_offsetOrChild' array
- final int[] newOffsetOrChild = new int[newSize];
- System.arraycopy(_offsetOrChild, 0, newOffsetOrChild, 0,length);
- _offsetOrChild = newOffsetOrChild;
-
- // Resize the '_lengthOrAttr' array
- final int[] newLengthOrAttr = new int[newSize];
- System.arraycopy(_lengthOrAttr, 0, newLengthOrAttr, 0, length);
- _lengthOrAttr = newLengthOrAttr;
-
- // Resize the '_whitespace' array (a BitArray instance)
- _whitespace.resize(newSize);
-
- // Resize the '_dontEscape' array (a BitArray instance)
- if (_dontEscape != null) {
- _dontEscape.resize(newSize);
- }
-
- // Resize the '_prefix' array
- final short[] newPrefix = new short[newSize];
- System.arraycopy(_prefix, 0, newPrefix, 0, length);
- _prefix = newPrefix;
- }
-
- private void resizeArrays2(final int newSize, final int length) {
- if (newSize > length) {
- // Resize the '_type2' array (attribute types)
- final short[] newType = new short[newSize];
- System.arraycopy(_type2, 0, newType, 0, length);
- _type2 = newType;
-
- // Resize the '_parent2' array (attribute parent elements)
- final int[] newParent = new int[newSize];
- System.arraycopy(_parent2, 0, newParent, 0, length);
- _parent2 = newParent;
-
- // Resize the '_nextSibling2' array (you get the idea...)
- final int[] newNextSibling = new int[newSize];
- System.arraycopy(_nextSibling2, 0, newNextSibling, 0, length);
- _nextSibling2 = newNextSibling;
-
- // Resize the '_offset' array (attribute value start)
- final int[] newOffset = new int[newSize];
- System.arraycopy(_offset, 0, newOffset, 0, length);
- _offset = newOffset;
-
- // Resize the 'length' array (attribute value length)
- final int[] newLength = new int[newSize];
- System.arraycopy(_length, 0, newLength, 0, length);
- _length = newLength;
-
- // Resize the '_prefix2' array
- final short[] newPrefix = new short[newSize];
- System.arraycopy(_prefix2, 0, newPrefix, 0, length);
- _prefix2 = newPrefix;
- }
- }
+ private void resizeArrays(final int newSize, int length)
+ {
+ if ((length < newSize) && (newSize == _currentNode))
+ length = _currentNode;
+
+ // Resize the '_type' array
+ // final short[] newType = new short[newSize];
+ // System.arraycopy(_type, 0, newType, 0, length);
+ // _type = newType;
+
+ // Resize the '_parent' array
+ // final int[] newParent = new int[newSize];
+ //System.arraycopy(_parent, 0, newParent, 0, length);
+ // _parent = newParent;
+
+ // Resize the '_nextSibling' array
+ // final int[] newNextSibling = new int[newSize];
+ // System.arraycopy(_nextSibling, 0, newNextSibling, 0, length);
+ // _nextSibling = newNextSibling;
+
+ // Resize the '_offsetOrChild' array
+ final int[] newOffsetOrChild = new int[newSize];
+ System.arraycopy(_offsetOrChild, 0, newOffsetOrChild, 0,length);
+ _offsetOrChild = newOffsetOrChild;
+
+ // Resize the '_lengthOrAttr' array
+ final int[] newLengthOrAttr = new int[newSize];
+ System.arraycopy(_lengthOrAttr, 0, newLengthOrAttr, 0, length);
+ _lengthOrAttr = newLengthOrAttr;
+
+ // Resize the '_whitespace' array (a BitArray instance)
+ _whitespace.resize(newSize);
+
+ // Resize the '_prefix' array
+ // final short[] newPrefix = new short[newSize];
+ // System.arraycopy(_prefix, 0, newPrefix, 0, length);
+ // _prefix = newPrefix;
+ }
+
+ private void resizeArrays2(final int newSize, final int length)
+ {
+ if (newSize > length)
+ {
+ // Resize the '_type2' array (attribute types)
+ final short[] newType = new short[newSize];
+ System.arraycopy(_type2, 0, newType, 0, length);
+ _type2 = newType;
+
+ // Resize the '_parent2' array (attribute parent elements)
+ final int[] newParent = new int[newSize];
+ System.arraycopy(_parent2, 0, newParent, 0, length);
+ _parent2 = newParent;
+
+ // Resize the '_nextSibling2' array (you get the idea...)
+ final int[] newNextSibling = new int[newSize];
+ System.arraycopy(_nextSibling2, 0, newNextSibling, 0, length);
+ _nextSibling2 = newNextSibling;
+
+ // Resize the '_offset' array (attribute value start)
+ final int[] newOffset = new int[newSize];
+ System.arraycopy(_offset, 0, newOffset, 0, length);
+ _offset = newOffset;
+
+ // Resize the 'length' array (attribute value length)
+ final int[] newLength = new int[newSize];
+ System.arraycopy(_length, 0, newLength, 0, length);
+ _length = newLength;
+
+ // Resize the '_prefix2' array
+ final short[] newPrefix = new short[newSize];
+ System.arraycopy(_prefix2, 0, newPrefix, 0, length);
+ _prefix2 = newPrefix;
+ }
+ }
+
+ private void shiftAttributes(final int shift)
+ {
+ int i = 0;
+ int next = 0;
+ final int limit = _currentAttributeNode;
+ int lastParent = -1;
+
+ for (i = 0; i < limit; i++)
+ {
+ if (_parent2[i] != lastParent)
+ {
+ lastParent = _parent2[i];
+ _lengthOrAttr[lastParent] = i + shift;
+ }
+ next = _nextSibling2[i];
+ _nextSibling2[i] = next != 0 ? next + shift : 0;
+ }
+ }
- private void shiftAttributes(final int shift) {
- int i = 0;
- int next = 0;
- final int limit = _currentAttributeNode;
- int lastParent = -1;
-
- for (i = 0; i < limit; i++) {
- if (_parent2[i] != lastParent) {
- lastParent = _parent2[i];
- _lengthOrAttr[lastParent] = i + shift;
- }
- next = _nextSibling2[i];
- _nextSibling2[i] = next != 0 ? next + shift : 0;
- }
- }
- private void appendAttributes() {
- final int len = _currentAttributeNode;
- if (len > 0) {
- final int dst = _currentNode;
- System.arraycopy(_type2, 0, _type, dst, len);
- System.arraycopy(_prefix2, 0, _prefix, dst, len);
- System.arraycopy(_parent2, 0, _parent, dst, len);
- System.arraycopy(_nextSibling2, 0, _nextSibling, dst, len);
- System.arraycopy(_offset, 0, _offsetOrChild, dst, len);
- System.arraycopy(_length, 0, _lengthOrAttr, dst, len);
- }
- }
+ private void appendAttributes()
+ {
+ final int len = _currentAttributeNode;
+ if (len > 0)
+ {
+ final int dst = _currentNode;
+ //System.arraycopy(_type2, 0, _type, dst, len);
+ // System.arraycopy(_prefix2, 0, _prefix, dst, len);
+ //System.arraycopy(_parent2, 0, _parent, dst, len);
+ // System.arraycopy(_nextSibling2, 0, _nextSibling, dst, len);
+ System.arraycopy(_offset, 0, _offsetOrChild, dst, len);
+ System.arraycopy(_length, 0, _lengthOrAttr, dst, len);
+ }
+ }
+
public boolean setEscaping(boolean value) {
final boolean temp = _escaping;
@@ -3730,4 +4145,5 @@
}
} // end of DOMBuilder
+
}
1.7.10.1 +32 -9
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DTDMonitor.java
Index: DTDMonitor.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DTDMonitor.java,v
retrieving revision 1.7
retrieving revision 1.7.10.1
diff -u -r1.7 -r1.7.10.1
--- DTDMonitor.java 17 Dec 2001 15:11:21 -0000 1.7
+++ DTDMonitor.java 17 Apr 2002 18:13:44 -0000 1.7.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DTDMonitor.java,v 1.7 2001/12/17 15:11:21 morten Exp $
+ * @(#)$Id: DTDMonitor.java,v 1.7.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -76,6 +76,9 @@
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
import org.apache.xalan.xsltc.runtime.Hashtable;
+import org.apache.xml.dtm.ref.DTMDefaultBase;
+import org.apache.xml.dtm.DTMAxisIterator;
+
final public class DTDMonitor implements DTDHandler, DeclHandler {
private final static String EMPTYSTRING = "";
@@ -207,7 +210,7 @@
* buildIdIndex creates the index (##id) that Key Class uses.
* The index contains the node index (int) and the id value (String).
*/
- public final void buildIdIndex(DOMImpl dom, int mask,
+ public final void buildIdIndex(DOM dom, int mask,
AbstractTranslet translet) {
// These variables are put up here for speed
@@ -228,26 +231,44 @@
if (elements.nextElement() instanceof String) {
Hashtable newAttributes = new Hashtable();
elements = _idAttributes.keys();
+ if (dom instanceof DOMImpl)
+ {
while (elements.hasMoreElements()) {
String element = (String)elements.nextElement();
String attribute = (String)_idAttributes.get(element);
- int elemType = dom.getGeneralizedType(element);
- int attrType = dom.getGeneralizedType(attribute);
+ int elemType, attrType;
+
+ elemType = ((DOMImpl)dom).getGeneralizedType(element);
+ attrType = ((DOMImpl)dom).getGeneralizedType(attribute);
+
newAttributes.put(new Integer(elemType), new Integer(attrType));
}
+ }
+ else
+ {
+ while (elements.hasMoreElements()) {
+ String element = (String)elements.nextElement();
+ String attribute = (String)_idAttributes.get(element);
+ int elemType, attrType;
+ elemType = ((SAXImpl)dom).getGeneralizedType(element);
+ attrType = ((SAXImpl)dom).getGeneralizedType(attribute);
+ newAttributes.put(new Integer(elemType), new
Integer(attrType));
+ }
+ }
_idAttributes = newAttributes;
}
// Get all nodes in the DOM
- final NodeIterator iter = dom.getAxisIterator(Axis.DESCENDANT);
- iter.setStartNode(DOM.ROOTNODE);
+ final DTMAxisIterator iter = dom.getAxisIterator(Axis.DESCENDANT);
+ iter.setStartNode(dom.getDocument()); //.ROOTNODE);
Integer E = new Integer(typeCache = 0);
Integer A = null;
- while ((node = iter.next()) != NodeIterator.END) {
+ while ((node = iter.next()) != DTMAxisIterator.END) {
// Get the node type of this node
- type = dom.getType(node);
+ //type = dom.getType(node);
+ type = ((DTMDefaultBase)dom).getExpandedTypeID(node);
if (type != typeCache) {
E = new Integer(typeCache = type);
A = (Integer)_idAttributes.get(E);
@@ -258,7 +279,9 @@
// Only store the attribute value if the element has this attr.
if ((attr = dom.getAttributeNode(A.intValue(), node)) != 0) {
final String value = dom.getNodeValue(attr);
- translet.buildKeyIndex(ID_INDEX_NAME, mask|node, value);
+ //translet.buildKeyIndex(ID_INDEX_NAME, mask|node, value);
+ translet.buildKeyIndex(ID_INDEX_NAME,
dom.getNodeIdent(node), value);
+ translet.setKeyIndexDom(ID_INDEX_NAME, dom);
}
}
}
1.6.10.1 +17 -9
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DocumentCache.java
Index: DocumentCache.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DocumentCache.java,v
retrieving revision 1.6
retrieving revision 1.6.10.1
diff -u -r1.6 -r1.6.10.1
--- DocumentCache.java 20 Jul 2001 18:52:09 -0000 1.6
+++ DocumentCache.java 17 Apr 2002 18:13:44 -0000 1.6.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DocumentCache.java,v 1.6 2001/07/20 18:52:09 amiro Exp $
+ * @(#)$Id: DocumentCache.java,v 1.6.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -78,6 +78,7 @@
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
+import org.xml.sax.InputSource;
import org.apache.xalan.xsltc.DOM;
import org.apache.xalan.xsltc.DOMCache;
@@ -87,6 +88,10 @@
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
import org.apache.xalan.xsltc.runtime.Constants;
+import org.apache.xml.dtm.DTMManager;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.sax.SAXSource;
+
public final class DocumentCache implements DOMCache {
private int _size;
@@ -113,7 +118,7 @@
private long _buildTime;
// DOM and DTD handler references
- private DOMImpl _dom = null;
+ private SAXImpl _dom = null;
private DTDMonitor _dtdMonitor = null;
/**
@@ -135,15 +140,18 @@
*/
public void loadDocument(String uri) {
- _dom = new DOMImpl();
+ DTMManager dtmManager = XSLTCDTMManager.newInstance(
+
org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+ //_dom = new DOMImpl();
_dtdMonitor = new DTDMonitor();
try {
final long stamp = System.currentTimeMillis();
+ _dtdMonitor.handleDTD(_reader);
+ //_reader.setContentHandler(_dom.getBuilder());
+ _dom = (SAXImpl)dtmManager.getDTM(new SAXSource(_reader, new
InputSource(uri)), false, null, true, true);
- _reader.setContentHandler(_dom.getBuilder());
- _dtdMonitor.handleDTD(_reader);
- _reader.parse(uri);
+ //_reader.parse(uri);
_dom.setDocumentURI(uri);
// The build time can be used for statistics for a better
@@ -160,7 +168,7 @@
}
}
- public DOMImpl getDocument() { return(_dom); }
+ public DOM getDocument() { return(_dom); }
public DTDMonitor getDTDMonitor() { return(_dtdMonitor); }
@@ -283,7 +291,7 @@
* Returns a document either by finding it in the cache or
* downloading it and putting it in the cache.
*/
- public final DOMImpl retrieveDocument(String uri, int mask, Translet
trs) {
+ public final DOM retrieveDocument(String uri, int mask, Translet trs) {
CachedDocument doc;
// Try to get the document from the cache first
@@ -314,7 +322,7 @@
}
// Get the references to the actual DOM and DTD handler
- final DOMImpl dom = doc.getDocument();
+ final DOM dom = doc.getDocument();
final DTDMonitor dtd = doc.getDTDMonitor();
// The dom reference may be null if the URL pointed to a
1.8.10.1 +11 -7
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DupFilterIterator.java
Index: DupFilterIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DupFilterIterator.java,v
retrieving revision 1.8
retrieving revision 1.8.10.1
diff -u -r1.8 -r1.8.10.1
--- DupFilterIterator.java 26 Sep 2001 13:26:25 -0000 1.8
+++ DupFilterIterator.java 17 Apr 2002 18:13:44 -0000 1.8.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DupFilterIterator.java,v 1.8 2001/09/26 13:26:25 morten Exp $
+ * @(#)$Id: DupFilterIterator.java,v 1.8.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -66,11 +66,15 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.TransletException;
-public final class DupFilterIterator extends NodeIteratorBase {
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMDefaultBase;
+
+public final class DupFilterIterator extends DTMAxisIteratorBase {
private final static int INIT_DATA_SIZE = 16;
- private final NodeIterator _source; // the source iterator
+ private final DTMAxisIterator _source; // the source iterator
private int[] _data = null; // cached nodes from the source
private int _last = 0; // the number of nodes in this
iterator
private int _current = 0;
@@ -83,14 +87,14 @@
* returned by id() and key() iterators.
* @param source The iterator this iterator will get its nodes from
*/
- public DupFilterIterator(NodeIterator source) {
+ public DupFilterIterator(DTMAxisIterator source) {
// Save a reference to the source iterator
_source = source;
// Cache contents of id() or key() index right away. Necessary for
// union expressions containing multiple calls to the same index, and
// correct as well since start-node is irrelevant for id()/key() exrp.
- if (source instanceof KeyIndex) setStartNode(DOM.ROOTNODE);
+ if (source instanceof KeyIndex) setStartNode(DTMDefaultBase.ROOTNODE);
}
/**
@@ -106,7 +110,7 @@
* @param node The start node
* @return A reference to this node iterator
*/
- public NodeIterator setStartNode(int node) {
+ public DTMAxisIterator setStartNode(int node) {
int i, j; // loop variables declared first for speed - don't move!!!
@@ -185,7 +189,7 @@
_current = _markedNode;
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
_current = 0;
return(this);
}
1.4.10.1 +16 -9
xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilterIterator.java
Index: FilterIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilterIterator.java,v
retrieving revision 1.4
retrieving revision 1.4.10.1
diff -u -r1.4 -r1.4.10.1
--- FilterIterator.java 4 Dec 2001 10:30:07 -0000 1.4
+++ FilterIterator.java 17 Apr 2002 18:13:44 -0000 1.4.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: FilterIterator.java,v 1.4 2001/12/04 10:30:07 morten Exp $
+ * @(#)$Id: FilterIterator.java,v 1.4.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -66,12 +66,17 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
-public final class FilterIterator extends NodeIteratorBase {
- private NodeIterator _source;
- private final Filter _filter;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+import org.apache.xml.dtm.DTMFilter;
+
+public final class FilterIterator extends DTMAxisIteratorBase {
+ private DTMAxisIterator _source;
+ private final DTMFilter _filter;
private final boolean _isReverse;
- public FilterIterator(NodeIterator source, Filter filter) {
+ public FilterIterator(DTMAxisIterator source, DTMFilter filter) {
_source = source;
_filter = filter;
_isReverse = source.isReverse();
@@ -81,12 +86,14 @@
return _isReverse;
}
+
public void setRestartable(boolean isRestartable) {
_isRestartable = isRestartable;
_source.setRestartable(isRestartable);
}
- public NodeIterator cloneIterator() {
+ public DTMAxisIterator cloneIterator() {
+
try {
final FilterIterator clone = (FilterIterator)super.clone();
clone.setRestartable(false);
@@ -100,7 +107,7 @@
}
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
_source.reset();
return resetPosition();
}
@@ -108,14 +115,14 @@
public int next() {
int node;
while ((node = _source.next()) != END) {
- if (_filter.test(node)) {
+ if (_filter.acceptNode(node, DTMFilter.SHOW_ALL) ==
DTMIterator.FILTER_ACCEPT) {
return returnNode(node);
}
}
return END;
}
- public NodeIterator setStartNode(int node) {
+ public DTMAxisIterator setStartNode(int node) {
if (_isRestartable) {
_source.setStartNode(_startNode = node);
return resetPosition();
1.5.10.1 +32 -6
xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilteredStepIterator.java
Index: FilteredStepIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilteredStepIterator.java,v
retrieving revision 1.5
retrieving revision 1.5.10.1
diff -u -r1.5 -r1.5.10.1
--- FilteredStepIterator.java 4 Dec 2001 10:30:07 -0000 1.5
+++ FilteredStepIterator.java 17 Apr 2002 18:13:44 -0000 1.5.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: FilteredStepIterator.java,v 1.5 2001/12/04 10:30:07 morten Exp $
+ * @(#)$Id: FilteredStepIterator.java,v 1.5.10.1 2002/04/17 18:13:44 mmidy
Exp $
*
* The Apache Software License, Version 1.1
*
@@ -67,25 +67,32 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
-public final class FilteredStepIterator extends StepIterator {
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+public final class FilteredStepIterator extends StepIterator {
+ //private DTMAxisIterator _source;
+ // private DTMAxisIterator _iterator;
private Filter _filter;
+
- public FilteredStepIterator(NodeIterator source,
- NodeIterator iterator,
+ public FilteredStepIterator(DTMAxisIterator source,
+ DTMAxisIterator iterator,
Filter filter) {
+ //_source = source;
+ //_iterator = iterator;
super(source, iterator);
_filter = filter;
}
- public NodeIterator cloneIterator() {
+ public DTMAxisIterator cloneIterator() {
try {
final FilteredStepIterator clone =
(FilteredStepIterator)super.clone();
clone._source = _source.cloneIterator();
clone._iterator = _iterator.cloneIterator();
clone._filter = _filter;
- clone.setRestartable(false);
+ clone._isRestartable = false;
return clone.reset();
}
catch (CloneNotSupportedException e) {
@@ -94,6 +101,25 @@
return null;
}
}
+
+
+ public DTMAxisIterator setStartNode(int node) {
+ if (_isRestartable) {
+ // iterator is not a clone
+ _source.setStartNode(_startNode = node);
+ _iterator.setStartNode(_source.next());
+ return resetPosition();
+ }
+ return this;
+ }
+
+
+ public DTMAxisIterator reset() {
+ _source.reset();
+ _iterator.setStartNode(_source.next());
+ return resetPosition();
+ }
+
public int next() {
int node;
1.7.10.1 +27 -9
xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java
Index: KeyIndex.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java,v
retrieving revision 1.7
retrieving revision 1.7.10.1
diff -u -r1.7 -r1.7.10.1
--- KeyIndex.java 4 Dec 2001 10:30:07 -0000 1.7
+++ KeyIndex.java 17 Apr 2002 18:13:44 -0000 1.7.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: KeyIndex.java,v 1.7 2001/12/04 10:30:07 morten Exp $
+ * @(#)$Id: KeyIndex.java,v 1.7.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -69,7 +69,10 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.runtime.Hashtable;
-public class KeyIndex implements NodeIterator {
+
+import org.apache.xml.dtm.DTMAxisIterator;
+
+public class KeyIndex implements DTMAxisIterator {
private Hashtable _index = new Hashtable();
private BitArray _nodes = null;
@@ -79,6 +82,7 @@
private int _start = 0;
private int _arraySize = 0;
private int _node = -1;
+ private DOM _dom;
/**
* Creates an index for a key defined by xsl:key
@@ -167,7 +171,7 @@
if (_nodes == null) return(END);
if ((_node = _nodes.getNextBit(++_node)) == END) return(END);
_pos++;
- return(_node | _nodes.getMask());
+ return _dom.getNodeHandle(_node | _nodes.getMask());
}
public int containsID(int node, Object value) {
@@ -197,7 +201,7 @@
/**
* Resets the iterator to the last start node.
*/
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
_pos = _start;
_node = _start - 1;
return(this);
@@ -240,17 +244,26 @@
* Set start to END should 'close' the iterator,
* i.e. subsequent call to next() should return END.
*/
- public NodeIterator setStartNode(int start) {
+ public DTMAxisIterator setStartNode(int start) {
if (start == END) {
_nodes = null;
}
else if (_nodes != null) {
// Node count starts with 1, while bit arrays count from 0. Must
// subtract one from 'start' to initialize bit array correctly.
- _start = _nodes.getBitNumber(start-1);
- _node = _start - 1;
+ _start = _nodes.getBitNumber(start);
+ _node = _start;
}
- return((NodeIterator)this);
+ return((DTMAxisIterator)this);
+ }
+
+ /**
+ * Get start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ */
+ public int getStartNode()
+ {
+ return _start;
}
/**
@@ -263,7 +276,7 @@
/**
* Returns a deep copy of this iterator.
*/
- public NodeIterator cloneIterator() {
+ public DTMAxisIterator cloneIterator() {
KeyIndex other = new KeyIndex(_arraySize);
other._index = _index;
@@ -273,6 +286,11 @@
other._node = _node;
return(other);
+ }
+
+ public void setDom(DOM dom)
+ {
+ _dom = dom;
}
}
1.11.10.1 +34 -18
xml-xalan/java/src/org/apache/xalan/xsltc/dom/LoadDocument.java
Index: LoadDocument.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/LoadDocument.java,v
retrieving revision 1.11
retrieving revision 1.11.10.1
diff -u -r1.11 -r1.11.10.1
--- LoadDocument.java 31 Oct 2001 07:29:39 -0000 1.11
+++ LoadDocument.java 17 Apr 2002 18:13:44 -0000 1.11.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: LoadDocument.java,v 1.11 2001/10/31 07:29:39 morten Exp $
+ * @(#)$Id: LoadDocument.java,v 1.11.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -68,9 +68,12 @@
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.sax.SAXSource;
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
+import org.xml.sax.InputSource;
import org.apache.xalan.xsltc.DOM;
import org.apache.xalan.xsltc.DOMCache;
@@ -79,6 +82,11 @@
import org.apache.xalan.xsltc.TransletException;
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMDefaultBase;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMManager;
+
public final class LoadDocument {
private static final String NAMESPACE_FEATURE =
@@ -88,7 +96,7 @@
* Returns an iterator containing a set of nodes from an XML document
* loaded by the document() function.
*/
- public static NodeIterator document(String uri, String base,
+ public static DTMAxisIterator document(String uri, String base,
AbstractTranslet translet, DOM dom)
throws Exception {
@@ -97,7 +105,7 @@
// Return an empty iterator if the URI is clearly invalid
// (to prevent some unncessary MalformedURL exceptions).
if ((uri == null) || (uri.equals("")))
- return(new SingletonIterator(DOM.NULL,true));
+ return(new SingletonIterator(DTM.NULL,true));
// Prepend URI base to URI (from context)
if ((base != null) && (!base.equals(""))) {
@@ -118,19 +126,21 @@
// Check if this DOM has already been added to the multiplexer
int mask = multiplexer.getDocumentMask(uri);
if (mask != -1) {
- return new SingletonIterator(DOM.ROOTNODE | mask, true);
+ DOM newDom =
((DOMAdapter)multiplexer.getDOMAdapter(uri)).getDOMImpl();
+ return new
SingletonIterator(((SAXImpl)newDom).getDocument()/*DTMDefaultBase.ROOTNODE |
mask*/, true);
}
// Check if we can get the DOM from a DOMCache
DOMCache cache = translet.getDOMCache();
- DOMImpl newdom;
+ DOM newdom;
mask = multiplexer.nextMask(); // peek
if (cache != null) {
newdom = cache.retrieveDocument(uri, mask, translet);
}
- else {
+ else
+ {
// Parse the input document and construct DOM object
// Create a SAX parser and get the XMLReader object it uses
final SAXParserFactory factory = SAXParserFactory.newInstance();
@@ -143,15 +153,21 @@
final SAXParser parser = factory.newSAXParser();
final XMLReader reader = parser.getXMLReader();
- // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
- newdom = new DOMImpl();
- reader.setContentHandler(newdom.getBuilder());
- // Create a DTD monitor and pass it to the XMLReader object
+ // Create a DTD monitor and pass it to the XMLReader object
DTDMonitor dtdMonitor = new DTDMonitor();
dtdMonitor.handleDTD(reader);
- newdom.setDocumentURI(uri);
- reader.parse(uri);
+ // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
+ DTMManager dtmManager =
((DTMDefaultBase)((DOMAdapter)multiplexer.getMain()).getDOMImpl()).m_mgr;
+ //DTMManager dtmManager = XSLTCDTMManager.newInstance(
+ //
org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+ newdom = (SAXImpl)dtmManager.getDTM(new SAXSource(reader, new
InputSource(uri)), false, null, true, true);
+ //newdom = new DOMImpl();
+ // reader.setContentHandler(((SAXImpl)newdom).getBuilder());
+
+
+ ((SAXImpl)newdom).setDocumentURI(uri);
+ //reader.parse(uri);
// Set size of key/id indices
translet.setIndexSize(newdom.getSize());
@@ -166,10 +182,10 @@
mask = multiplexer.addDOMAdapter(domAdapter);
// Create index for any key elements
- translet.buildKeys((DOM)newdom, null, null, DOM.ROOTNODE | mask);
+ translet.buildKeys((DOM)newdom, null, null,
((SAXImpl)newdom).getDocument()/*DTMDefaultBase.ROOTNODE | mask*/);
// Return a singleton iterator containing the root node
- return new SingletonIterator(DOM.ROOTNODE | mask, true);
+ return new
SingletonIterator(((SAXImpl)newdom).getDocument()/*DTMDefaultBase.ROOTNODE |
mask*/, true);
}
/**
@@ -178,7 +194,7 @@
* iterator containing the requested nodes. Builds a union-iterator if
* several documents are requested.
*/
- public static NodeIterator document(Object arg,String xmlURI,String
xslURI,
+ public static DTMAxisIterator document(Object arg,String xmlURI,String
xslURI,
AbstractTranslet translet, DOM dom)
throws TransletException {
try {
@@ -218,12 +234,12 @@
}
// Otherwise we must create a union iterator, add the nodes from
// all the DOMs to this iterator, and return the union in the end.
- else if (arg instanceof NodeIterator) {
+ else if (arg instanceof DTMAxisIterator) {
UnionIterator union = new UnionIterator(dom);
- NodeIterator iterator = (NodeIterator)arg;
+ DTMAxisIterator iterator = (DTMAxisIterator)arg;
int node;
- while ((node = iterator.next()) != DOM.NULL) {
+ while ((node = iterator.next()) != DTM.NULL) {
String uri = dom.getNodeValue(node);
// Get the URI from this node if no xml URI base is set
if ((xmlURI == null) || xmlURI.equals("")) {
1.6.10.1 +12 -7
xml-xalan/java/src/org/apache/xalan/xsltc/dom/MatchingIterator.java
Index: MatchingIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MatchingIterator.java,v
retrieving revision 1.6
retrieving revision 1.6.10.1
diff -u -r1.6 -r1.6.10.1
--- MatchingIterator.java 4 Dec 2001 10:30:07 -0000 1.6
+++ MatchingIterator.java 17 Apr 2002 18:13:44 -0000 1.6.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: MatchingIterator.java,v 1.6 2001/12/04 10:30:07 morten Exp $
+ * @(#)$Id: MatchingIterator.java,v 1.6.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -66,22 +66,27 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
-public final class MatchingIterator extends NodeIteratorBase {
- private NodeIterator _source;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+
+public final class MatchingIterator extends DTMAxisIteratorBase {
+ private DTMAxisIterator _source;
private final int _match;
private int _matchPos, _matchLast = -1;
- public MatchingIterator(int match, NodeIterator source) {
+ public MatchingIterator(int match, DTMAxisIterator source) {
_source = source;
_match = match;
}
+
public void setRestartable(boolean isRestartable) {
_isRestartable = isRestartable;
_source.setRestartable(isRestartable);
}
- public NodeIterator cloneIterator() {
+ public DTMAxisIterator cloneIterator() {
+
try {
final MatchingIterator clone = (MatchingIterator)super.clone();
clone._source = _source.cloneIterator();
@@ -95,7 +100,7 @@
}
}
- public NodeIterator setStartNode(int node) {
+ public DTMAxisIterator setStartNode(int node) {
if (_isRestartable) {
// iterator is not a clone
_source.setStartNode(node);
@@ -109,7 +114,7 @@
return this;
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
_source.reset();
return this;
}
1.16.10.1 +159 -58
xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java
Index: MultiDOM.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java,v
retrieving revision 1.16
retrieving revision 1.16.10.1
diff -u -r1.16 -r1.16.10.1
--- MultiDOM.java 4 Dec 2001 10:30:07 -0000 1.16
+++ MultiDOM.java 17 Apr 2002 18:13:44 -0000 1.16.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: MultiDOM.java,v 1.16 2001/12/04 10:30:07 morten Exp $
+ * @(#)$Id: MultiDOM.java,v 1.16.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -75,6 +75,13 @@
import org.apache.xalan.xsltc.runtime.Hashtable;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+import org.apache.xml.dtm.ref.DTMDefaultBase;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMManager;
+import org.apache.xml.dtm.DTMIterator;
+
public final class MultiDOM implements DOM {
private static final int NO_TYPE = DOM.FIRST_TYPE - 2;
private static final int INITIAL_SIZE = 4;
@@ -87,12 +94,12 @@
private Hashtable _documents = new Hashtable();
- private final class AxisIterator implements NodeIterator {
+ private final class AxisIterator extends DTMAxisIteratorBase {
// constitutive data
private final int _axis;
private final int _type;
// implementation mechanism
- private NodeIterator _source;
+ private DTMAxisIterator _source;
private int _mask;
public AxisIterator(final int axis, final int type) {
@@ -102,20 +109,26 @@
public int next() {
if (_source == null) return(END);
- if (_mask == 0) return _source.next();
- final int node = _source.next();
- return node != END ? (node | _mask) : END;
+ /*if (_mask == 0)*/ return _source.next();
+ /* final int node = _source.next();
+ return node != END ? (node | _mask) : END;*/
}
+
public void setRestartable(boolean flag) {
_source.setRestartable(flag);
}
- public NodeIterator setStartNode(final int node) {
- _mask = node & SET;
- int dom = node >>> 24;
+
+ public DTMAxisIterator setStartNode(final int node) {
+ if (node == DTM.NULL) return this;
+
+ int nodeid = getNodeIdent(node);
+ _mask = nodeid & SET;
+ int dom = getDTMId(node); //nodeid >>> 24;
+
// consider caching these
- if ((_type == NO_TYPE) || (_type == DOM.ELEMENT)) {
+ if ((_type == NO_TYPE) || (_type == DTM.ELEMENT_NODE)) {
_source = _adapters[dom].getAxisIterator(_axis);
}
else if (_axis == Axis.CHILD) {
@@ -128,7 +141,7 @@
return this;
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
if (_source != null) _source.reset();
return this;
}
@@ -156,7 +169,7 @@
_source.gotoMark();
}
- public NodeIterator cloneIterator() {
+ public DTMAxisIterator cloneIterator() {
final AxisIterator clone = new AxisIterator(_axis, _type);
clone._source = _source.cloneIterator();
clone._mask = _mask;
@@ -170,15 +183,15 @@
* This is a specialised iterator for predicates comparing node or
* attribute values to variable or parameter values.
*/
- private final class NodeValueIterator extends NodeIteratorBase {
+ private final class NodeValueIterator extends DTMAxisIteratorBase {
- private NodeIterator _source;
+ private DTMAxisIterator _source;
private String _value;
private boolean _op;
private final boolean _isReverse;
private int _returnType = RETURN_PARENT;
- public NodeValueIterator(NodeIterator source, int returnType,
+ public NodeValueIterator(DTMAxisIterator source, int returnType,
String value, boolean op) {
_source = source;
_returnType = returnType;
@@ -191,7 +204,7 @@
return _isReverse;
}
- public NodeIterator cloneIterator() {
+ public DTMAxisIterator cloneIterator() {
try {
NodeValueIterator clone = (NodeValueIterator)super.clone();
clone._source = _source.cloneIterator();
@@ -205,12 +218,13 @@
}
}
+
public void setRestartable(boolean isRestartable) {
_isRestartable = isRestartable;
_source.setRestartable(isRestartable);
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
_source.reset();
return resetPosition();
}
@@ -230,7 +244,7 @@
return END;
}
- public NodeIterator setStartNode(int node) {
+ public DTMAxisIterator setStartNode(int node) {
if (_isRestartable) {
_source.setStartNode(_startNode = node);
return resetPosition();
@@ -252,6 +266,7 @@
_free = 1;
_adapters = new DOM[INITIAL_SIZE];
_adapters[0] = main;
+ addDOMAdapter(main);
}
public int nextMask() {
@@ -265,7 +280,10 @@
public int addDOMAdapter(DOM dom) {
// Add the DOM adapter to the array of DOMs
- final int domNo = _free++;
+ DTMManager dtmManager =
((DTMDefaultBase)((DOMAdapter)dom).getDOMImpl()).m_mgr;
+ final int domNo =
dtmManager.getDTMIdentity((DTM)((DOMAdapter)dom).getDOMImpl()) >>>
DTMManager.IDENT_DTM_NODE_BITS;
+
+ //final int domNo = _free++;
if (domNo == _size) {
final DOMAdapter[] newArray = new DOMAdapter[_size *= 2];
System.arraycopy(_adapters, 0, newArray, 0, domNo);
@@ -287,9 +305,22 @@
else
return((domIdx.intValue() << 24));
}
+
+ public DOM getDOMAdapter(String uri) {
+ Integer domIdx = (Integer)_documents.get(uri);
+ if (domIdx == null)
+ return(null);
+ else
+ return(_adapters[domIdx.intValue()]);
+ }
+
+ public int getDocument()
+ {
+ return _adapters[0].getDocument();
+ }
/** returns singleton iterator containg the document root */
- public NodeIterator getIterator() {
+ public DTMAxisIterator getIterator() {
// main source document @ 0
return _adapters[0].getIterator();
}
@@ -302,100 +333,123 @@
return _adapters[0].getTreeString();
}
- public NodeIterator getChildren(final int node) {
- return (node & SET) == 0
+ public DTMAxisIterator getChildren(final int node) {
+ return _adapters[getDTMId(node)].getChildren(node);
+ /*(node & SET) == 0
? _adapters[0].getChildren(node)
- : getAxisIterator(Axis.CHILD).setStartNode(node);
+ : getAxisIterator(Axis.CHILD).setStartNode(node);*/
}
- public NodeIterator getTypedChildren(final int type) {
+ public DTMAxisIterator getTypedChildren(final int type) {
return new AxisIterator(Axis.CHILD, type);
}
- public NodeIterator getAxisIterator(final int axis) {
+ public DTMAxisIterator getAxisIterator(final int axis) {
return new AxisIterator(axis, NO_TYPE);
}
- public NodeIterator getTypedAxisIterator(final int axis, final int type)
{
+ public DTMAxisIterator getTypedAxisIterator(final int axis, final int
type) {
return new AxisIterator(axis, type);
}
- public NodeIterator getNthDescendant(int node, int n, boolean
includeself) {
- return _adapters[node>>>24].getNthDescendant(node & CLR,n,includeself);
+ public DTMAxisIterator getNthDescendant(int node, int n, boolean
includeself) {
+ return _adapters[getDTMId(node)].getNthDescendant(node &
CLR,n,includeself);
}
- public NodeIterator getNodeValueIterator(NodeIterator iterator, int type,
+ public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iterator,
int type,
String value, boolean op) {
return(new NodeValueIterator(iterator, type, value, op));
}
- public NodeIterator getNamespaceAxisIterator(final int axis, final int
ns) {
- NodeIterator iterator = _adapters[0].getNamespaceAxisIterator(axis,ns);
+ public DTMAxisIterator getNamespaceAxisIterator(final int axis, final
int ns) {
+ DTMAxisIterator iterator =
_adapters[0].getNamespaceAxisIterator(axis,ns);
return(iterator);
}
- public NodeIterator orderNodes(NodeIterator source, int node) {
- return _adapters[node>>>24].orderNodes(source, node & CLR);
+ public DTMAxisIterator orderNodes(DTMAxisIterator source, int node) {
+ return _adapters[getDTMId(node)].orderNodes(source, node & CLR);
}
public int getType(final int node) {
- return _adapters[node>>>24].getType(node & CLR);
+ return _adapters[getDTMId(node)].getType(node & CLR);
}
public int getNamespaceType(final int node) {
- return _adapters[node>>>24].getNamespaceType(node & CLR);
+ return _adapters[getDTMId(node)].getNamespaceType(node & CLR);
}
+ public int getNSType(int node)
+ {
+ return _adapters[getDTMId(node)].getNSType(node & CLR);
+ }
+
public int getParent(final int node) {
- return _adapters[node>>>24].getParent(node & CLR) | node&SET;
+ if (node == DTM.NULL)
+ return DTM.NULL;
+ return _adapters[getDTMId(node)].getParent(node & CLR) | node&SET;
}
public int getTypedPosition(int type, int node) {
- return _adapters[node>>>24].getTypedPosition(type, node&CLR);
+ return _adapters[getDTMId(node)].getTypedPosition(type, node&CLR);
}
public int getTypedLast(int type, int node) {
- return _adapters[node>>>24].getTypedLast(type, node&CLR);
+ return _adapters[getDTMId(node)].getTypedLast(type, node&CLR);
}
public int getAttributeNode(final int type, final int el) {
- return _adapters[el>>>24].getAttributeNode(type, el&CLR) | el&SET;
+ if (el == DTM.NULL)
+ return DTM.NULL;
+ return _adapters[getDTMId(el)].getAttributeNode(type, el&CLR) | el&SET;
}
public String getNodeName(final int node) {
- return _adapters[node>>>24].getNodeName(node & CLR);
+ if (node == DTM.NULL)
+ return "";
+ return _adapters[getDTMId(node)].getNodeName(node & CLR);
}
public String getNamespaceName(final int node) {
- return _adapters[node>>>24].getNamespaceName(node & CLR);
+ if (node == DTM.NULL)
+ return "";
+ return _adapters[getDTMId(node)].getNamespaceName(node & CLR);
}
public String getNodeValue(final int node) {
- return _adapters[node>>>24].getNodeValue(node & CLR);
+ if (node == DTM.NULL)
+ return "";
+ return _adapters[getDTMId(node)].getNodeValue(node & CLR);
}
public void copy(final int node, TransletOutputHandler handler)
throws TransletException {
- _adapters[node>>>24].copy(node & CLR, handler);
+ if (node != DTM.NULL)
+ _adapters[getDTMId(node)].copy(node & CLR, handler);
}
- public void copy(NodeIterator nodes, TransletOutputHandler handler)
+ public void copy(DTMAxisIterator nodes, TransletOutputHandler handler)
throws TransletException {
int node;
- while ((node = nodes.next()) != DOM.NULL) {
- _adapters[node>>>24].copy(node & CLR, handler);
+ while ((node = nodes.next()) != DTM.NULL) {
+ _adapters[getDTMId(node)].copy(node & CLR, handler);
}
}
public String shallowCopy(final int node, TransletOutputHandler handler)
throws TransletException {
- return _adapters[node>>>24].shallowCopy(node & CLR, handler);
+ if (node == DTM.NULL)
+ return "";
+ return _adapters[getDTMId(node)].shallowCopy(node & CLR, handler);
}
public boolean lessThan(final int node1, final int node2) {
- final int dom1 = node1>>>24;
- final int dom2 = node2>>>24;
+ if (node1 == DTM.NULL) return true;
+ if (node2 == DTM.NULL) return false;
+ // int nodeid1 = getNodeIdent(node1);
+ //int nodeid2 = getNodeIdent(node2);
+ final int dom1 = getDTMId(node1);
+ final int dom2 = getDTMId(node2);
return dom1 == dom2
? _adapters[dom1].lessThan(node1 & CLR, node2 & CLR)
: dom1 < dom2;
@@ -403,7 +457,7 @@
public void characters(final int textNode, TransletOutputHandler handler)
throws TransletException {
- _adapters[textNode>>>24].characters(textNode & CLR, handler);
+ _adapters[getDTMId(textNode)].characters(textNode & CLR, handler);
}
public void setFilter(StripFilter filter) {
@@ -413,25 +467,29 @@
}
public Node makeNode(int index) {
- return _adapters[index>>>24].makeNode(index & CLR);
+ if (index == DTM.NULL)
+ return null;
+ return _adapters[getDTMId(index)].makeNode(index & CLR);
}
- public Node makeNode(NodeIterator iter) {
+ public Node makeNode(DTMAxisIterator iter) {
// TODO: gather nodes from all DOMs ?
return _adapters[0].makeNode(iter);
}
public NodeList makeNodeList(int index) {
- return _adapters[index>>>24].makeNodeList(index & CLR);
+ if (index == DTM.NULL)
+ return null;
+ return _adapters[getDTMId(index)].makeNodeList(index & CLR);
}
- public NodeList makeNodeList(NodeIterator iter) {
+ public NodeList makeNodeList(DTMIterator iter) {
// TODO: gather nodes from all DOMs ?
return _adapters[0].makeNodeList(iter);
}
public String getLanguage(int node) {
- return _adapters[node>>>24].getLanguage(node & CLR);
+ return _adapters[getDTMId(node)].getLanguage(node & CLR);
}
public int getSize() {
@@ -442,15 +500,58 @@
}
public String getDocumentURI(int node) {
- return _adapters[node>>>24].getDocumentURI(0);
+ if (node == DTM.NULL)
+ node = DOM.NULL;
+ return _adapters[getDTMId(node)].getDocumentURI(0);
}
public boolean isElement(final int node) {
- return(_adapters[node>>>24].isElement(node & CLR));
+ if (node == DTM.NULL)
+ return false;
+ return(_adapters[getDTMId(node)].isElement(node & CLR));
}
public boolean isAttribute(final int node) {
- return(_adapters[node>>>24].isAttribute(node & CLR));
+ if (node == DTM.NULL)
+ return false;
+// getNodeIdent(node)>>>24
+ return(_adapters[getDTMId(node)].isAttribute(node & CLR));
+ }
+
+ public int getDTMId(int nodeHandle)
+ {
+ DTMManager dtmManager =
((DTMDefaultBase)((DOMAdapter)_adapters[0]).getDOMImpl()).m_mgr;
+ int id = dtmManager.getDTMIdentity(dtmManager.getDTM(nodeHandle)) >>>
DTMManager.IDENT_DTM_NODE_BITS;
+ return (id == -1 ? 0 : id);
+ }
+
+ public int getNodeIdent(int nodeHandle)
+ {
+ int id = getDTMId(nodeHandle);
+ return (_adapters[id].getNodeIdent(nodeHandle) | id<<24);
+ }
+
+ public int getNodeHandle(int nodeId)
+ {
+ return _adapters[nodeId>>>24].getNodeHandle(nodeId & CLR);
+ }
+
+ public DOM getResultTreeFrag()
+ {
+ return _adapters[0].getResultTreeFrag();
+ }
+
+ public DOM getMain()
+ {
+ return _adapters[0];
+ }
+
+ /**
+ * Returns a DOMBuilder class wrapped in a SAX adapter.
+ */
+ public TransletOutputHandler getOutputDomBuilder()
+ {
+ return _adapters[0].getOutputDomBuilder();
}
}
1.1.14.1 +7 -5
xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultipleNodeCounter.java
Index: MultipleNodeCounter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultipleNodeCounter.java,v
retrieving revision 1.1
retrieving revision 1.1.14.1
diff -u -r1.1 -r1.1.14.1
--- MultipleNodeCounter.java 17 Apr 2001 18:52:33 -0000 1.1
+++ MultipleNodeCounter.java 17 Apr 2002 18:13:44 -0000 1.1.14.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: MultipleNodeCounter.java,v 1.1 2001/04/17 18:52:33 sboag Exp $
+ * @(#)$Id: MultipleNodeCounter.java,v 1.1.14.1 2002/04/17 18:13:44 mmidy
Exp $
*
* The Apache Software License, Version 1.1
*
@@ -68,11 +68,13 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.util.IntegerArray;
+import org.apache.xml.dtm.DTMAxisIterator;
+
public abstract class MultipleNodeCounter extends NodeCounter {
- private NodeIterator _precSiblings = null;
+ private DTMAxisIterator _precSiblings = null;
public MultipleNodeCounter(Translet translet,
- DOM document, NodeIterator iterator) {
+ DOM document, DTMAxisIterator iterator) {
super(translet, document, iterator);
}
@@ -129,14 +131,14 @@
public static NodeCounter getDefaultNodeCounter(Translet translet,
DOM document,
- NodeIterator iterator) {
+ DTMAxisIterator iterator) {
return new DefaultMultipleNodeCounter(translet, document, iterator);
}
static class DefaultMultipleNodeCounter extends MultipleNodeCounter {
public DefaultMultipleNodeCounter(Translet translet,
DOM document,
- NodeIterator iterator) {
+ DTMAxisIterator iterator) {
super(translet, document, iterator);
}
}
1.6.10.1 +7 -4
xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeCounter.java
Index: NodeCounter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeCounter.java,v
retrieving revision 1.6
retrieving revision 1.6.10.1
diff -u -r1.6 -r1.6.10.1
--- NodeCounter.java 5 Nov 2001 11:26:01 -0000 1.6
+++ NodeCounter.java 17 Apr 2002 18:13:44 -0000 1.6.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NodeCounter.java,v 1.6 2001/11/05 11:26:01 morten Exp $
+ * @(#)$Id: NodeCounter.java,v 1.6.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -70,15 +70,18 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.dom.Axis;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.DTM;
+
public abstract class NodeCounter implements Axis {
- public static final int END = DOM.NULL;
+ public static final int END = DTM.NULL;
protected int _node = END;
protected int _nodeType = DOM.FIRST_TYPE - 1;
protected int _value = Integer.MIN_VALUE;
public final DOM _document;
- public final NodeIterator _iterator;
+ public final DTMAxisIterator _iterator;
public final Translet _translet;
protected String _format;
@@ -104,7 +107,7 @@
{"", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"};
protected NodeCounter(Translet translet,
- DOM document, NodeIterator iterator) {
+ DOM document, DTMAxisIterator iterator) {
_translet = translet;
_document = document;
_iterator = iterator;
1.9.10.1 +26 -16
xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java
Index: NthIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java,v
retrieving revision 1.9
retrieving revision 1.9.10.1
diff -u -r1.9 -r1.9.10.1
--- NthIterator.java 4 Dec 2001 10:30:07 -0000 1.9
+++ NthIterator.java 17 Apr 2002 18:13:44 -0000 1.9.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NthIterator.java,v 1.9 2001/12/04 10:30:07 morten Exp $
+ * @(#)$Id: NthIterator.java,v 1.9.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -67,13 +67,18 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
-public final class NthIterator extends NodeIteratorBase {
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+
+public final class NthIterator extends DTMAxisIteratorBase {
// ...[N]
- private NodeIterator _source;
+
+ private final DTMAxisIterator _source;
+
private final int _position;
private boolean _ready;
- public NthIterator(NodeIterator source, int n) {
+ public NthIterator(DTMAxisIterator source, int n) {
_source = source;
_position = n;
}
@@ -89,24 +94,26 @@
// skip N-1 nodes
final int pos = _position;
for (int n = pos - 1; n-- > 0;) {
- if (_source.next() == NodeIterator.END) {
- return NodeIterator.END;
+ if (_source.next() == DTMAxisIterator.END) {
+ return DTMAxisIterator.END;
}
}
return _source.next();
}
- return NodeIterator.END;
+ return DTMAxisIterator.END;
}
- public NodeIterator setStartNode(final int node) {
- if (_isRestartable) {
- _source.setStartNode(node);
- _ready = true;
- }
+
+ public DTMAxisIterator setStartNode(final int node) {
+ if (_isRestartable) {
+ _source.setStartNode(node);
+ _ready = true;
+ }
+
return this;
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
_source.reset();
_ready = true;
return this;
@@ -131,9 +138,12 @@
public void gotoMark() {
_source.gotoMark();
}
-
- public NodeIterator cloneIterator() {
- NodeIterator clone = _source.cloneIterator();
+
+ public DTMAxisIterator cloneIterator() {
+ //!! not clear when cloning is performed
+ // and what's the desired state of the new clone
+ //return new NthIterator(_source.cloneIterator(), _position);
+ DTMAxisIterator clone = _source.cloneIterator();
NthIterator other = new NthIterator(clone, _position);
other.setRestartable(false);
return other.reset();
1.3.10.1 +9 -6
xml-xalan/java/src/org/apache/xalan/xsltc/dom/ReverseIterator.java
Index: ReverseIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/ReverseIterator.java,v
retrieving revision 1.3
retrieving revision 1.3.10.1
diff -u -r1.3 -r1.3.10.1
--- ReverseIterator.java 17 Sep 2001 08:20:55 -0000 1.3
+++ ReverseIterator.java 17 Apr 2002 18:13:44 -0000 1.3.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ReverseIterator.java,v 1.3 2001/09/17 08:20:55 morten Exp $
+ * @(#)$Id: ReverseIterator.java,v 1.3.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -65,16 +65,19 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.TransletException;
-public final class ReverseIterator extends NodeIteratorBase {
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+
+public final class ReverseIterator extends DTMAxisIteratorBase {
private final static int INIT_DATA_SIZE = 16;
- private final NodeIterator _source;
+ private final DTMAxisIterator _source;
private int[] _data = null;
private int _last = 0;
private int _current = 0;
private int _start = -1;
- public ReverseIterator(NodeIterator source) {
+ public ReverseIterator(DTMAxisIterator source) {
_source = source;
}
@@ -82,7 +85,7 @@
return _current > 0 ? _data[--_current] : END;
}
- public NodeIterator setStartNode(int node) {
+ public DTMAxisIterator setStartNode(int node) {
if ((_data == null) || (node != _start)) {
_start = node;
_source.setStartNode(node);
@@ -102,7 +105,7 @@
return this;
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
_current = _startNode;
return this;
}
1.2.10.1 +7 -5
xml-xalan/java/src/org/apache/xalan/xsltc/dom/SingleNodeCounter.java
Index: SingleNodeCounter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SingleNodeCounter.java,v
retrieving revision 1.2
retrieving revision 1.2.10.1
diff -u -r1.2 -r1.2.10.1
--- SingleNodeCounter.java 2 Nov 2001 11:31:28 -0000 1.2
+++ SingleNodeCounter.java 17 Apr 2002 18:13:44 -0000 1.2.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: SingleNodeCounter.java,v 1.2 2001/11/02 11:31:28 morten Exp $
+ * @(#)$Id: SingleNodeCounter.java,v 1.2.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -67,13 +67,15 @@
import org.apache.xalan.xsltc.DOM;
import org.apache.xalan.xsltc.NodeIterator;
+import org.apache.xml.dtm.DTMAxisIterator;
+
public abstract class SingleNodeCounter extends NodeCounter {
static private final int[] EmptyArray = new int[] { };
- NodeIterator _countSiblings = null;
+ DTMAxisIterator _countSiblings = null;
public SingleNodeCounter(Translet translet,
DOM document,
- NodeIterator iterator) {
+ DTMAxisIterator iterator) {
super(translet, document, iterator);
}
@@ -120,13 +122,13 @@
public static NodeCounter getDefaultNodeCounter(Translet translet,
DOM document,
- NodeIterator iterator) {
+ DTMAxisIterator iterator) {
return new DefaultSingleNodeCounter(translet, document, iterator);
}
static class DefaultSingleNodeCounter extends SingleNodeCounter {
public DefaultSingleNodeCounter(Translet translet,
- DOM document, NodeIterator iterator) {
+ DOM document, DTMAxisIterator iterator)
{
super(translet, document, iterator);
}
1.2.12.1 +8 -5
xml-xalan/java/src/org/apache/xalan/xsltc/dom/SingletonIterator.java
Index: SingletonIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SingletonIterator.java,v
retrieving revision 1.2
retrieving revision 1.2.12.1
diff -u -r1.2 -r1.2.12.1
--- SingletonIterator.java 13 Jun 2001 12:06:25 -0000 1.2
+++ SingletonIterator.java 17 Apr 2002 18:13:44 -0000 1.2.12.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: SingletonIterator.java,v 1.2 2001/06/13 12:06:25 morten Exp $
+ * @(#)$Id: SingletonIterator.java,v 1.2.12.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -65,7 +65,10 @@
import org.apache.xalan.xsltc.NodeIterator;
-public class SingletonIterator extends NodeIteratorBase {
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+
+public class SingletonIterator extends DTMAxisIteratorBase {
private int _node;
private final boolean _isConstant;
@@ -86,7 +89,7 @@
* Override the value of <tt>_node</tt> only when this
* object was constructed using the empty constructor.
*/
- public NodeIterator setStartNode(int node) {
+ public DTMAxisIterator setStartNode(int node) {
if (_isConstant) {
_node = _startNode;
return resetPosition();
@@ -99,7 +102,7 @@
return this;
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
if (_isConstant) {
_node = _startNode;
return resetPosition();
@@ -115,7 +118,7 @@
public int next() {
final int result = _node;
- _node = NodeIterator.END;
+ _node = DTMAxisIterator.END;
return returnNode(result);
}
1.2.2.1 +11 -6
xml-xalan/java/src/org/apache/xalan/xsltc/dom/SortingIterator.java
Index: SortingIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SortingIterator.java,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1
--- SortingIterator.java 4 Mar 2002 14:41:00 -0000 1.2
+++ SortingIterator.java 17 Apr 2002 18:13:44 -0000 1.2.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: SortingIterator.java,v 1.2 2002/03/04 14:41:00 tmiller Exp $
+ * @(#)$Id: SortingIterator.java,v 1.2.2.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -68,15 +68,20 @@
import org.apache.xalan.xsltc.TransletException;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
-public final class SortingIterator extends NodeIteratorBase {
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+
+public final class SortingIterator extends DTMAxisIteratorBase {
private final static int INIT_DATA_SIZE = 16;
- private NodeIterator _source;
+
+ private DTMAxisIterator _source;
private NodeSortRecordFactory _factory;
+
private NodeSortRecord[] _data;
private int _free = 0;
private int _current; // index in _nodes of the next node to try
- public SortingIterator(NodeIterator source,
+ public SortingIterator(DTMAxisIterator source,
NodeSortRecordFactory factory) {
_source = source;
_factory = factory;
@@ -86,7 +91,7 @@
return _current < _free ? _data[_current++].getNode() : END;
}
- public NodeIterator setStartNode(int node) {
+ public DTMAxisIterator setStartNode(int node) {
try {
_source.setStartNode(_startNode = node);
_data = new NodeSortRecord[INIT_DATA_SIZE];
@@ -130,7 +135,7 @@
* iterator and then sharing the factory and the array of
* <code>NodeSortRecords</code>.
*/
- public NodeIterator cloneIterator() {
+ public DTMAxisIterator cloneIterator() {
try {
final SortingIterator clone = (SortingIterator) super.clone();
clone._source = _source.cloneIterator();
1.11.10.1 +22 -10
xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java
Index: StepIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java,v
retrieving revision 1.11
retrieving revision 1.11.10.1
diff -u -r1.11 -r1.11.10.1
--- StepIterator.java 4 Dec 2001 10:30:07 -0000 1.11
+++ StepIterator.java 17 Apr 2002 18:13:44 -0000 1.11.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: StepIterator.java,v 1.11 2001/12/04 10:30:07 morten Exp $
+ * @(#)$Id: StepIterator.java,v 1.11.10.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -68,28 +68,40 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
-public class StepIterator extends NodeIteratorBase {
- protected NodeIterator _source;
- protected NodeIterator _iterator;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+
+public class StepIterator extends DTMAxisIteratorBase {
+
private int _pos = -1;
+ protected DTMAxisIterator _source;
+ protected DTMAxisIterator _iterator;
- public StepIterator(NodeIterator source, NodeIterator iterator) {
+ public StepIterator(DTMAxisIterator source, DTMAxisIterator iterator) {
_source = source;
_iterator = iterator;
}
+
public void setRestartable(boolean isRestartable) {
_isRestartable = isRestartable;
_source.setRestartable(isRestartable);
_iterator.setRestartable(true); // must _always_ be restartable
}
- public NodeIterator cloneIterator() {
+ public DTMAxisIterator cloneIterator() {
+ _isRestartable = false;
try {
final StepIterator clone = (StepIterator)super.clone();
clone._source = _source.cloneIterator();
clone._iterator = _iterator.cloneIterator();
+
+ // Special case -> _iterator must be restartable
+ // if (clone._iterator instanceof DTMAxisIteratorBase) {
+ // ((DTMAxisIteratorBase)(clone._iterator))._isRestartable = true;
+ // }
+
clone.setRestartable(false);
return clone.reset();
}
@@ -100,7 +112,7 @@
}
}
- public NodeIterator setStartNode(int node) {
+ public DTMAxisIterator setStartNode(int node) {
if (_isRestartable) {
// Set start node for left-hand iterator...
_source.setStartNode(_startNode = node);
@@ -115,7 +127,7 @@
return this;
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
_source.reset();
// Special case for //* path - see ParentLocationPath
if (_includeSelf)
@@ -145,12 +157,12 @@
public void setMark() {
_source.setMark();
_iterator.setMark();
- _pos = _position;
+ //_pos = _position;
}
public void gotoMark() {
_source.gotoMark();
_iterator.gotoMark();
- _position = _pos;
+ //_position = _pos;
}
}
1.11.2.1 +13 -8
xml-xalan/java/src/org/apache/xalan/xsltc/dom/UnionIterator.java
Index: UnionIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/UnionIterator.java,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- UnionIterator.java 11 Mar 2002 22:29:56 -0000 1.11
+++ UnionIterator.java 17 Apr 2002 18:13:44 -0000 1.11.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: UnionIterator.java,v 1.11 2002/03/11 22:29:56 amiro Exp $
+ * @(#)$Id: UnionIterator.java,v 1.11.2.1 2002/04/17 18:13:44 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -67,13 +67,16 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+
/**
* UnionIterator takes a set of NodeIterators and produces
* a merged NodeSet in document order with duplicates removed
* The individual iterators are supposed to generate nodes
* in document order
*/
-public final class UnionIterator extends NodeIteratorBase {
+public final class UnionIterator extends DTMAxisIteratorBase {
/** wrapper for NodeIterators to support iterator
comparison on the value of their next() method
*/
@@ -81,9 +84,9 @@
private final static class LookAheadIterator {
public int node, markedNode;
- public final NodeIterator iterator;
+ public final DTMAxisIterator iterator;
- public LookAheadIterator(NodeIterator iterator) {
+ public LookAheadIterator(DTMAxisIterator iterator) {
this.iterator = iterator;
}
@@ -119,7 +122,9 @@
_dom = dom;
}
- public NodeIterator cloneIterator() {
+
+ public DTMAxisIterator cloneIterator() {
+ _isRestartable = false;
final LookAheadIterator[] heapCopy =
new LookAheadIterator[_heap.length];
try {
@@ -136,7 +141,7 @@
}
}
- public UnionIterator addIterator(NodeIterator iterator) {
+ public UnionIterator addIterator(DTMAxisIterator iterator) {
if (_free == _size) {
LookAheadIterator[] newArray = new LookAheadIterator[_size *= 2];
System.arraycopy(_heap, 0, newArray, 0, _free);
@@ -175,7 +180,7 @@
return END;
}
- public NodeIterator setStartNode(int node) {
+ public DTMAxisIterator setStartNode(int node) {
if (_isRestartable) {
_startNode = node;
for (int i = 0; i < _free; i++) {
@@ -224,7 +229,7 @@
}
}
- public NodeIterator reset() {
+ public DTMAxisIterator reset() {
super.reset();
for (int i = 0; i < _free; i++) {
_heap[i].iterator.reset();
No revision
No revision
1.1.2.1 +4217 -0
xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java
1.1.2.1 +666 -0
xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/XSLTCDTMManager.java
No revision
No revision
1.33.2.1 +23 -4
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
Index: AbstractTranslet.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
retrieving revision 1.33
retrieving revision 1.33.2.1
diff -u -r1.33 -r1.33.2.1
--- AbstractTranslet.java 13 Mar 2002 16:27:30 -0000 1.33
+++ AbstractTranslet.java 17 Apr 2002 18:13:46 -0000 1.33.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AbstractTranslet.java,v 1.33 2002/03/13 16:27:30 tmiller Exp $
+ * @(#)$Id: AbstractTranslet.java,v 1.33.2.1 2002/04/17 18:13:46 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -74,10 +74,14 @@
import org.apache.xalan.xsltc.*;
import org.apache.xalan.xsltc.dom.DOMAdapter;
import org.apache.xalan.xsltc.dom.DOMImpl;
+import org.apache.xalan.xsltc.dom.SAXImpl;
import org.apache.xalan.xsltc.dom.KeyIndex;
import org.apache.xalan.xsltc.dom.DTDMonitor;
import org.apache.xalan.xsltc.util.IntegerArray;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMNodeIterator;
+
public abstract class AbstractTranslet implements Translet {
// These attributes are extracted from the xsl:output element. They also
@@ -112,7 +116,9 @@
throws TransletException {
if (dom instanceof DOMImpl)
return new DOMAdapter((DOMImpl)dom, namesArray, namespaceArray);
- BasisLibrary.runTimeError(BasisLibrary.DOM_ADAPTER_INIT_ERR);
+ else if (dom instanceof SAXImpl)
+ return new DOMAdapter((SAXImpl)dom, namesArray, namespaceArray);
+ //BasisLibrary.runTimeError(BasisLibrary.DOM_ADAPTER_INIT_ERR);
return null;
}
@@ -455,9 +461,19 @@
* This method builds key indexes - it is overridden in the compiled
* translet in cases where the <xsl:key> element is used
*/
- public void buildKeys(DOM document, NodeIterator iterator,
+ public void buildKeys(DOM document, DTMAxisIterator iterator,
TransletOutputHandler handler,
int root) throws TransletException {
+
+ }
+
+ /**
+ * This method builds key indexes - it is overridden in the compiled
+ * translet in cases where the <xsl:key> element is used
+ */
+ public void setKeyIndexDom(String name, DOM document) {
+ getKeyIndex(name).setDom(document);
+
}
/************************************************************************
@@ -523,7 +539,7 @@
/**
* Main transform() method - this is overridden by the compiled translet
*/
- public abstract void transform(DOM document, NodeIterator iterator,
+ public abstract void transform(DOM document, DTMAxisIterator iterator,
TransletOutputHandler handler)
throws TransletException;
@@ -542,8 +558,11 @@
public final void characters(final String string,
TransletOutputHandler handler)
throws TransletException {
+ if (string != null)
+ {
final int length = string.length();
handler.characters(string.toCharArray(), 0, length);
+ }
}
/**
1.35.2.1 +51 -47
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
Index: BasisLibrary.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
retrieving revision 1.35
retrieving revision 1.35.2.1
diff -u -r1.35 -r1.35.2.1
--- BasisLibrary.java 2 Apr 2002 19:18:46 -0000 1.35
+++ BasisLibrary.java 17 Apr 2002 18:13:47 -0000 1.35.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: BasisLibrary.java,v 1.35 2002/04/02 19:18:46 tmiller Exp $
+ * @(#)$Id: BasisLibrary.java,v 1.35.2.1 2002/04/17 18:13:47 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -78,9 +78,12 @@
import org.apache.xalan.xsltc.*;
import org.apache.xalan.xsltc.DOM;
+import org.apache.xalan.xsltc.dom.DOMAdapter;
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.dom.SingletonIterator;
+import org.apache.xml.dtm.DTMAxisIterator;
+
/**
* Standard XSLT functions. All standard functions expect the current node
* and the DOM as their last two arguments.
@@ -92,7 +95,7 @@
/**
* Standard function count(node-set)
*/
- public static int countF(NodeIterator iterator) {
+ public static int countF(DTMAxisIterator iterator) {
return(iterator.getLast());
}
@@ -100,11 +103,11 @@
* XSLT Standard function sum(node-set).
* stringToDouble is inlined
*/
- public static double sumF(NodeIterator iterator, DOM dom) {
+ public static double sumF(DTMAxisIterator iterator, DOM dom) {
try {
double result = 0.0;
int node;
- while ((node = iterator.next()) != NodeIterator.END) {
+ while ((node = iterator.next()) != DTMAxisIterator.END) {
result += Double.parseDouble(dom.getNodeValue(node));
}
return result;
@@ -125,8 +128,8 @@
* XSLT Standard function string(value)
*/
public static String stringF(Object obj, DOM dom) {
- if (obj instanceof NodeIterator) {
- return dom.getNodeValue(((NodeIterator)obj).reset().next());
+ if (obj instanceof DTMAxisIterator) {
+ return dom.getNodeValue(((DTMAxisIterator)obj).reset().next());
}
else if (obj instanceof Node) {
return dom.getNodeValue(((Node)obj).node);
@@ -143,8 +146,8 @@
* XSLT Standard function string(value)
*/
public static String stringF(Object obj, int node, DOM dom) {
- if (obj instanceof NodeIterator) {
- return dom.getNodeValue(((NodeIterator)obj).reset().next());
+ if (obj instanceof DTMAxisIterator) {
+ return dom.getNodeValue(((DTMAxisIterator)obj).reset().next());
}
else if (obj instanceof Node) {
return dom.getNodeValue(((Node)obj).node);
@@ -196,8 +199,8 @@
else if (obj instanceof String) {
return stringToReal((String) obj);
}
- else if (obj instanceof NodeIterator) {
- NodeIterator iter = (NodeIterator) obj;
+ else if (obj instanceof DTMAxisIterator) {
+ DTMAxisIterator iter = (DTMAxisIterator) obj;
return stringToReal(dom.getNodeValue(iter.reset().next()));
}
else if (obj instanceof Node) {
@@ -230,9 +233,9 @@
else if (obj instanceof String) {
return !((String) obj).equals(EMPTYSTRING);
}
- else if (obj instanceof NodeIterator) {
- NodeIterator iter = (NodeIterator) obj;
- return iter.reset().next() != NodeIterator.END;
+ else if (obj instanceof DTMAxisIterator) {
+ DTMAxisIterator iter = (DTMAxisIterator) obj;
+ return iter.reset().next() != DTMAxisIterator.END;
}
else if (obj instanceof Node) {
return true;
@@ -416,7 +419,7 @@
/**
* XSLT Standard function namespace-uri(node-set).
*/
- public static String namespace_uriF(NodeIterator iter, DOM dom) {
+ public static String namespace_uriF(DTMAxisIterator iter, DOM dom) {
return namespace_uriF(iter.next(), dom);
}
@@ -483,17 +486,17 @@
/**
* Utility function: node-set/node-set compare.
*/
- public static boolean compare(NodeIterator left, NodeIterator right,
+ public static boolean compare(DTMAxisIterator left, DTMAxisIterator
right,
int op, int node, DOM dom) {
int lnode;
left.reset();
- while ((lnode = left.next()) != NodeIterator.END) {
+ while ((lnode = left.next()) != DTMAxisIterator.END) {
final String lvalue = dom.getNodeValue(lnode);
int rnode;
right.reset();
- while ((rnode = right.next()) != NodeIterator.END) {
+ while ((rnode = right.next()) != DTMAxisIterator.END) {
if (compareStrings(lvalue, dom.getNodeValue(rnode), op, dom)) {
return true;
}
@@ -505,12 +508,12 @@
/**
* Utility function: node/node-set compare.
*/
- public static boolean compare(int node, NodeIterator nodeSet,
+ public static boolean compare(int node, DTMAxisIterator nodeSet,
int op, DOM dom) {
final String lvalue = dom.getNodeValue(node);
int rnode;
//nodeSet.reset();
- while ((rnode = nodeSet.next()) != NodeIterator.END) {
+ while ((rnode = nodeSet.next()) != DTMAxisIterator.END) {
if (compareStrings(lvalue, dom.getNodeValue(rnode), op, dom)) {
return true;
}
@@ -518,7 +521,7 @@
return false;
}
- public static boolean compare(int node, NodeIterator iterator,
+ public static boolean compare(int node, DTMAxisIterator iterator,
int op, int dummy, DOM dom) {
//iterator.reset();
@@ -533,31 +536,31 @@
* Values is the obvious for attributes, but what about elements?
*/
value = dom.getNodeValue(node);
- while ((rnode = iterator.next()) != NodeIterator.END)
+ while ((rnode = iterator.next()) != DTMAxisIterator.END)
if (value.equals(dom.getNodeValue(rnode))) return true;
// if (rnode == node) return true; It just ain't that easy!!!
break;
case NE:
value = dom.getNodeValue(node);
- while ((rnode = iterator.next()) != NodeIterator.END)
+ while ((rnode = iterator.next()) != DTMAxisIterator.END)
if (!value.equals(dom.getNodeValue(rnode))) return true;
// if (rnode != node) return true;
break;
case LT:
// Assume we're comparing document order here
- while ((rnode = iterator.next()) != NodeIterator.END)
+ while ((rnode = iterator.next()) != DTMAxisIterator.END)
if (rnode > node) return true;
break;
case GT:
// Assume we're comparing document order here
- while ((rnode = iterator.next()) != NodeIterator.END)
+ while ((rnode = iterator.next()) != DTMAxisIterator.END)
if (rnode < node) return true;
break;
}
return(false);
}
- public static boolean compare(NodeIterator left, final double rnumber,
+ public static boolean compare(DTMAxisIterator left, final double rnumber,
final int op, final int node, DOM dom) {
return(compare(left,rnumber,op,dom));
}
@@ -565,49 +568,49 @@
/**
* Utility function: node-set/number compare.
*/
- public static boolean compare(NodeIterator left, final double rnumber,
+ public static boolean compare(DTMAxisIterator left, final double rnumber,
final int op, DOM dom) {
int node;
//left.reset();
switch (op) {
case EQ:
- while ((node = left.next()) != NodeIterator.END) {
+ while ((node = left.next()) != DTMAxisIterator.END) {
if (numberF(dom.getNodeValue(node), dom) == rnumber)
return true;
}
break;
case NE:
- while ((node = left.next()) != NodeIterator.END) {
+ while ((node = left.next()) != DTMAxisIterator.END) {
if (numberF(dom.getNodeValue(node), dom) != rnumber)
return true;
}
break;
case GT:
- while ((node = left.next()) != NodeIterator.END) {
+ while ((node = left.next()) != DTMAxisIterator.END) {
if (numberF(dom.getNodeValue(node), dom) > rnumber)
return true;
}
break;
case LT:
- while ((node = left.next()) != NodeIterator.END) {
+ while ((node = left.next()) != DTMAxisIterator.END) {
if (numberF(dom.getNodeValue(node), dom) < rnumber)
return true;
}
break;
case GE:
- while ((node = left.next()) != NodeIterator.END) {
+ while ((node = left.next()) != DTMAxisIterator.END) {
if (numberF(dom.getNodeValue(node), dom) >= rnumber)
return true;
}
break;
case LE:
- while ((node = left.next()) != NodeIterator.END) {
+ while ((node = left.next()) != DTMAxisIterator.END) {
if (numberF(dom.getNodeValue(node), dom) <= rnumber)
return true;
}
@@ -623,11 +626,11 @@
/**
* Utility function: node-set/string comparison.
*/
- public static boolean compare(NodeIterator left, final String rstring,
+ public static boolean compare(DTMAxisIterator left, final String rstring,
int op, DOM dom) {
int node;
//left.reset();
- while ((node = left.next()) != NodeIterator.END) {
+ while ((node = left.next()) != DTMAxisIterator.END) {
if (compareStrings(dom.getNodeValue(node), rstring, op, dom)) {
return true;
}
@@ -635,7 +638,7 @@
return false;
}
- public static boolean compare(NodeIterator left, final String rstring,
+ public static boolean compare(DTMAxisIterator left, final String rstring,
int op, int node, DOM dom) {
if (compareStrings(dom.getNodeValue(node), rstring, op, dom)) {
@@ -710,7 +713,7 @@
}
if (hasSimpleType(left) ||
- left instanceof DOM && right instanceof NodeIterator) {
+ left instanceof DOM && right instanceof DTMAxisIterator) {
// swap operands
final Object temp = right; right = left; left = temp;
}
@@ -742,10 +745,10 @@
// Next, node-set/t for t in {real, string, node-set, result-tree}
- NodeIterator iter = ((NodeIterator)left).reset();
+ DTMAxisIterator iter = ((DTMAxisIterator)left).reset();
- if (right instanceof NodeIterator) {
- result = compare(iter, (NodeIterator)right, op, node, dom);
+ if (right instanceof DTMAxisIterator) {
+ result = compare(iter, (DTMAxisIterator)right, op, node, dom);
}
else if (right instanceof String) {
//result = compare(iter, (String)right, op, node, dom);
@@ -757,7 +760,7 @@
}
else if (right instanceof Boolean) {
boolean temp = ((Boolean)right).booleanValue();
- result = (iter.reset().next() != NodeIterator.END) == temp;
+ result = (iter.reset().next() != DTMAxisIterator.END) == temp;
}
else if (right instanceof DOM) {
result = compare(iter, ((DOM)right).getStringValue(),
@@ -890,15 +893,15 @@
* Utility function: used to convert references to node-sets. If the
* obj is an instanceof Node then create a singleton iterator.
*/
- public static NodeIterator referenceToNodeSet(Object obj) {
+ public static DTMAxisIterator referenceToNodeSet(Object obj) {
try {
// Convert var/param -> node
if (obj instanceof Node) {
return(new SingletonIterator(((Node)obj).node));
}
// Convert var/param -> node-set
- else if (obj instanceof NodeIterator) {
- return(((NodeIterator)obj).cloneIterator());
+ else if (obj instanceof DTMAxisIterator) {
+ return(((DTMAxisIterator)obj).cloneIterator());
}
// Convert var/param -> result-tree fragment
else if (obj instanceof DOM) {
@@ -921,7 +924,7 @@
* Utility function: used with nth position filters to convert a sequence
* of nodes to just one single node (the one at position n).
*/
- public static NodeIterator getSingleNode(NodeIterator iterator) {
+ public static DTMAxisIterator getSingleNode(DTMAxisIterator iterator) {
int node = iterator.next();
return(new SingletonIterator(node));
}
@@ -936,15 +939,16 @@
int node,
DOM dom) {
try {
- if (obj instanceof NodeIterator) {
- NodeIterator iter = (NodeIterator) obj;
+ if (obj instanceof DTMAxisIterator)
+ {
+ DTMAxisIterator iter = (DTMAxisIterator) obj;
dom.copy(iter.reset(), handler);
}
else if (obj instanceof Node) {
dom.copy(((Node) obj).node, handler);
}
else if (obj instanceof DOM) {
- ((DOM)obj).copy(1, handler);
+
((DOM)obj).copy(((org.apache.xml.dtm.ref.DTMDefaultBase)((DOMAdapter)obj).getDOMImpl()).getDocument(),
handler);
}
else {
String string = obj.toString(); // or call stringF()
1.3.2.1 +8 -6
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/Constants.java
Index: Constants.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/Constants.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- Constants.java 2 Apr 2002 19:01:38 -0000 1.3
+++ Constants.java 17 Apr 2002 18:13:47 -0000 1.3.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Constants.java,v 1.3 2002/04/02 19:01:38 santiagopg Exp $
+ * @(#)$Id: Constants.java,v 1.3.2.1 2002/04/17 18:13:47 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -65,6 +65,8 @@
import org.apache.xalan.xsltc.DOM;
+import org.apache.xml.dtm.DTM;
+
/**
* This class defines constants used by both the compiler and the
* runtime system.
@@ -73,11 +75,11 @@
final static int ANY = -1;
final static int ATTRIBUTE = -2;
- final static int ROOT = DOM.ROOT;
- final static int TEXT = DOM.TEXT;
- final static int ELEMENT = DOM.ELEMENT;
- final static int COMMENT = DOM.COMMENT;
- final static int PROCESSING_INSTRUCTION = DOM.PROCESSING_INSTRUCTION;
+ final static int ROOT = DTM.ROOT_NODE;
+ final static int TEXT = DTM.TEXT_NODE;
+ final static int ELEMENT = DTM.ELEMENT_NODE;
+ final static int COMMENT = DTM.COMMENT_NODE;
+ final static int PROCESSING_INSTRUCTION =
DTM.PROCESSING_INSTRUCTION_NODE;
public static String XSLT_URI = "http://www.w3.org/1999/XSL/Transform";
public static final String NAMESPACE_FEATURE =
1.13.10.1 +74 -12
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/DefaultRun.java
Index: DefaultRun.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/DefaultRun.java,v
retrieving revision 1.13
retrieving revision 1.13.10.1
diff -u -r1.13 -r1.13.10.1
--- DefaultRun.java 12 Oct 2001 19:04:55 -0000 1.13
+++ DefaultRun.java 17 Apr 2002 18:13:47 -0000 1.13.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DefaultRun.java,v 1.13 2001/10/12 19:04:55 tmiller Exp $
+ * @(#)$Id: DefaultRun.java,v 1.13.10.1 2002/04/17 18:13:47 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -78,6 +78,7 @@
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
import org.xml.sax.ext.LexicalHandler;
import org.apache.xalan.xsltc.*;
@@ -85,6 +86,15 @@
import org.apache.xalan.xsltc.dom.Axis;
import org.apache.xalan.xsltc.dom.DTDMonitor;
import org.apache.xalan.xsltc.runtime.Constants;
+import org.apache.xalan.xsltc.dom.SAXImpl;
+import org.apache.xalan.xsltc.dom.XSLTCDTMManager;
+
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.sax.SAXSource;
+
+import org.apache.xml.dtm.DTMManager;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.DTM;
final public class DefaultRun {
@@ -138,25 +148,62 @@
final SAXParser parser = factory.newSAXParser();
final XMLReader reader = parser.getXMLReader();
- // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
- final DOMImpl dom = new DOMImpl();
- reader.setContentHandler(dom.getBuilder());
- // Create a DTD monitor and pass it to the XMLReader object
+ // Create a DTD monitor and pass it to the XMLReader object
final DTDMonitor dtdMonitor = new DTDMonitor();
dtdMonitor.handleDTD(reader);
+ // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
+ DTMManager dtmManager = XSLTCDTMManager.newInstance(
+ org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+ String uri;
+ if (_uri)
+ uri = _fileName;
+ else
+ uri = new File(_fileName).toURL().toExternalForm();
+ DTM dtm = dtmManager.getDTM(new SAXSource(reader, new
InputSource(uri)), false, null, true, true);
+ final DOMImpl dom;
+ final SAXImpl sax;
+ if (dtm instanceof DOMImpl)
+ {
+ dom = (DOMImpl)dtm;
+ sax = null;
+ //reader.setContentHandler(dom.getBuilder());
+ dom.setDocumentURI(uri);
+ }
+ else
+ {
+ sax = (SAXImpl)dtm;
+ dom = null;
+ //reader.setContentHandler(sax.getBuilder());
+ sax.setDocumentURI(uri);
+ }
+
+ //final DOMImpl dom = new DOMImpl();
+ //reader.setContentHandler(dom.getBuilder());
+
+
_translet = (AbstractTranslet)translet;
- dom.setDocumentURI(_fileName);
- if (_uri)
- reader.parse(_fileName);
- else {
- reader.parse(new File(_fileName).toURL().toExternalForm());
- }
+ //dom.setDocumentURI(_fileName);
+ // if (_uri)
+ // reader.parse(_fileName);
+ // else {
+ // reader.parse(new File(_fileName).toURL().toExternalForm());
+ // }
+ if (dtm instanceof DOMImpl)
+ {
// Set size of key/id indices
_translet.setIndexSize(dom.getSize());
// If there are any elements with ID attributes, build an index
dtdMonitor.buildIdIndex(dom, 0, _translet);
+ }
+ else
+ {
+ // Set size of key/id indices
+ _translet.setIndexSize(sax.getSize());
+ // If there are any elements with ID attributes, build an index
+ dtdMonitor.buildIdIndex(sax, 0, _translet);
+ }
_translet.setDTDMonitor(dtdMonitor);
@@ -175,14 +222,29 @@
TextOutput textOutput =
new TextOutput((ContentHandler)saxHandler,
(LexicalHandler)saxHandler, encoding);
+ if (dtm instanceof DOMImpl)
+ {
translet.transform(dom, textOutput);
+ }
+ else
+ {
+ translet.transform(sax, textOutput);
+ }
if (_debug) {
TransletOutputBase handler = new TransletOutputBase();
long start = System.currentTimeMillis();
- final int nTimes = 100;
+ final int nTimes = 1;
+ if (dtm instanceof DOMImpl)
+ {
for (int i = 0; i < nTimes; i++)
translet.transform(dom, dom.getIterator(), handler);
+ }
+ else
+ {
+ for (int i = 0; i < nTimes; i++)
+ translet.transform(sax, sax.getIterator(), handler);
+ }
long end = System.currentTimeMillis();
System.out.println("total " + (end - start) + " msec for "
+ nTimes + " transformations");
1.10.2.1 +5 -1
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/SAXAdapter.java
Index: SAXAdapter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/SAXAdapter.java,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- SAXAdapter.java 27 Mar 2002 21:06:54 -0000 1.10
+++ SAXAdapter.java 17 Apr 2002 18:13:47 -0000 1.10.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: SAXAdapter.java,v 1.10 2002/03/27 21:06:54 tmiller Exp $
+ * @(#)$Id: SAXAdapter.java,v 1.10.2.1 2002/04/17 18:13:47 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -83,7 +83,11 @@
private void maybeEmitStartElement() throws SAXException {
if (_openElementName != null) {
+
+ // _saxHandler.startElement(null, _openElementName,
_openElementName, _attributes);
+
_domBuilder.startElement(null, null, _openElementName, _attributes);
+
_openElementName = null;
}
}
No revision
No revision
1.6.10.1 +12 -3
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerHandlerImpl.java
Index: TransformerHandlerImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerHandlerImpl.java,v
retrieving revision 1.6
retrieving revision 1.6.10.1
diff -u -r1.6 -r1.6.10.1
--- TransformerHandlerImpl.java 30 Oct 2001 14:57:54 -0000 1.6
+++ TransformerHandlerImpl.java 17 Apr 2002 18:13:47 -0000 1.6.10.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TransformerHandlerImpl.java,v 1.6 2001/10/30 14:57:54 morten Exp
$
+ * @(#)$Id: TransformerHandlerImpl.java,v 1.6.10.1 2002/04/17 18:13:47 mmidy
Exp $
*
* The Apache Software License, Version 1.1
*
@@ -66,10 +66,15 @@
import javax.xml.transform.*;
import javax.xml.transform.sax.*;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.xml.dtm.DTMManager;
import org.apache.xalan.xsltc.Translet;
import org.apache.xalan.xsltc.dom.DOMImpl;
+import org.apache.xalan.xsltc.dom.SAXImpl;
import org.apache.xalan.xsltc.dom.DTDMonitor;
+import org.apache.xalan.xsltc.dom.XSLTCDTMManager;
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
@@ -81,7 +86,7 @@
private TransformerImpl _transformer;
private AbstractTranslet _translet = null;
private String _systemId;
- private DOMImpl _dom = null;
+ private SAXImpl _dom = null;
private ContentHandler _handler = null;
private DTDMonitor _dtd = null;
private Result _result = null;
@@ -173,10 +178,14 @@
}
// Create an internal DOM (not W3C) and get SAX2 input handler
- _dom = new DOMImpl();
+ DTMManager dtmManager = XSLTCDTMManager.newInstance(
+
org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+ _dom = (SAXImpl)dtmManager.getDTM(new StreamSource(_systemId) , false,
null, true, true);
+ //_dom = new DOMImpl();
_handler = _dom.getBuilder();
// Proxy call
+ // wondering if I need this. I think it would get called during DTM
build...
_handler.startDocument();
}
1.37.2.1 +71 -41
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java
Index: TransformerImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java,v
retrieving revision 1.37
retrieving revision 1.37.2.1
diff -u -r1.37 -r1.37.2.1
--- TransformerImpl.java 8 Apr 2002 16:20:35 -0000 1.37
+++ TransformerImpl.java 17 Apr 2002 18:13:47 -0000 1.37.2.1
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TransformerImpl.java,v 1.37 2002/04/08 16:20:35 santiagopg Exp $
+ * @(#)$Id: TransformerImpl.java,v 1.37.2.1 2002/04/17 18:13:47 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -102,11 +102,14 @@
import org.apache.xalan.xsltc.Translet;
import org.apache.xalan.xsltc.TransletException;
import org.apache.xalan.xsltc.DOMCache;
+import org.apache.xalan.xsltc.DOM;
import org.apache.xalan.xsltc.dom.*;
import org.apache.xalan.xsltc.runtime.*;
import org.apache.xalan.xsltc.compiler.*;
import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
+import org.apache.xml.dtm.DTMManager;
+
import java.util.Properties;
public final class TransformerImpl extends Transformer
@@ -126,8 +129,8 @@
private final static String YES_STRING = "yes";
private final static String XML_STRING = "xml";
- // Pre-set DOMImpl to use as input (used only with
TransformerHandlerImpl)
- private DOMImpl _dom = null;
+ // Pre-set DOM to use as input (used only with TransformerHandlerImpl)
+ private DOM _dom = null;
private final static String LEXICAL_HANDLER_PROPERTY =
"http://xml.org/sax/properties/lexical-handler";
@@ -327,10 +330,12 @@
// Common, final handling of all input sources, only used if the
// other contents of the Result object could not be used
if (systemId != null) {
- if ((new File(systemId)).exists()) systemId = "file:"+systemId;
- final URL url = new URL(systemId);
- final URLConnection connection = url.openConnection();
- final OutputStream ostream = connection.getOutputStream();
+ File f;
+ if ((f = new File(systemId)).exists()) systemId =
"file:///"+f.getAbsolutePath();
+ //final URL url = new URL(systemId);
+ //final URLConnection connection = url.openConnection();
+ //final OutputStream ostream = connection.getOutputStream();
+ final OutputStream ostream = new java.io.FileOutputStream(f);
return(new DefaultSAXOutputHandler(ostream, _encoding));
}
else {
@@ -358,24 +363,24 @@
/**
* Set the internal DOMImpl that will be used for the next transformation
*/
- protected void setDOM(DOMImpl dom) {
+ protected void setDOM(DOM dom) {
_dom = dom;
}
/**
* Builds an internal DOM from a TrAX Source object
*/
- private DOMImpl getDOM(Source source, int mask)
+ private DOM getDOM(Source source, int mask)
throws TransformerException {
try {
// Use the pre-defined DOM if present
if (_dom != null) {
- DOMImpl dom = _dom;
+ DOM dom = _dom;
_dom = null; // use only once, so reset to 'null'
return(dom);
}
- DOMImpl dom = null;
+ DOM dom = null;
DTDMonitor dtd = null;
// Handle SAXSource input
@@ -392,8 +397,12 @@
// Create a new internal DOM and set up its builder to trap
// all content/lexical events
- dom = new DOMImpl();
- final DOMBuilder builder = dom.getBuilder();
+ DTMManager dtmManager = XSLTCDTMManager.newInstance(
+ org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+
+ dom = (SAXImpl)dtmManager.getDTM(sax, false, null, true, true);
+ //dom = new DOMImpl();
+/* final DOMBuilder builder = ((SAXImpl)dom).getBuilder();
try {
reader.setProperty(LEXICAL_HANDLER_PROPERTY, builder);
}
@@ -403,8 +412,8 @@
reader.setContentHandler(builder);
// Parse the input and build the internal DOM
- reader.parse(input);
- dom.setDocumentURI(systemId);
+ reader.parse(input); */
+ ((SAXImpl)dom).setDocumentURI(systemId);
}
// Handle DOMSource input
else if (source instanceof DOMSource) {
@@ -426,22 +435,28 @@
// Create a new internal DOM and set up its builder to trap
// all content/lexical events
- dom = new DOMImpl();
- final DOMBuilder builder = dom.getBuilder();
- dom2sax.setContentHandler(builder);
-
- // Parse the input and build the internal DOM
+ DTMManager dtmManager = XSLTCDTMManager.newInstance(
+ org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+
+ dom = (DOMImpl)dtmManager.getDTM(domsrc, false, null, true, true);
+ //dom = new DOMImpl();
+ final DOMBuilder builder = ((DOMImpl)dom).getBuilder();
if (!isComplete) {
builder.startDocument();
}
- dom2sax.parse(input); // need this parameter?
if (!isComplete) {
builder.endDocument();
}
- dom.setDocumentURI(systemId);
+/* dom2sax.setContentHandler(builder);
+
+ // Parse the input and build the internal DOM
+
+ dom2sax.parse(input); // need this parameter? */
+ ((DOMImpl)dom).setDocumentURI(systemId);
}
// Handle StreamSource input
- else if (source instanceof StreamSource) {
+ else if (source instanceof StreamSource)
+ {
// Get all info from the input StreamSource object
final StreamSource stream = (StreamSource)source;
final InputStream streamInput = stream.getInputStream();
@@ -466,8 +481,23 @@
// Create a new internal DOM and set up its builder to trap
// all content/lexical events
- dom = new DOMImpl();
- final DOMBuilder builder = dom.getBuilder();
+ DTMManager dtmManager = XSLTCDTMManager.newInstance(
+ org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+
+ InputSource input;
+ if (streamInput != null)
+ input = new InputSource(streamInput);
+ else if (streamReader != null)
+ input = new InputSource(streamReader);
+ else if (systemId != null)
+ input = new InputSource(systemId);
+ else {
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_SOURCE_ERR);
+ throw new TransformerException(err.toString());
+ }
+ dom = (SAXImpl)dtmManager.getDTM(new SAXSource(reader, input), false,
null, true, true);
+ //dom = new DOMImpl();
+/* final DOMBuilder builder = ((SAXImpl)dom).getBuilder();
try {
reader.setProperty(LEXICAL_HANDLER_PROPERTY, builder);
}
@@ -489,8 +519,8 @@
}
// Parse the input and build the internal DOM
- reader.parse(input);
- dom.setDocumentURI(systemId);
+ reader.parse(input); */
+ ((SAXImpl)dom).setDocumentURI(systemId);
}
// Handle XSLTC-internal Source input
else if (source instanceof XSLTCSource) {
@@ -510,18 +540,18 @@
_translet.setDTDMonitor(dtd);
return dom;
}
- catch (FileNotFoundException e) {
- if (_errorListener != null) postErrorToListener(e.getMessage());
- throw new TransformerException(e);
- }
- catch (MalformedURLException e) {
- if (_errorListener != null) postErrorToListener(e.getMessage());
- throw new TransformerException(e);
- }
- catch (UnknownHostException e) {
- if (_errorListener != null) postErrorToListener(e.getMessage());
- throw new TransformerException(e);
- }
+ //catch (FileNotFoundException e) {
+// if (_errorListener != null) postErrorToListener(e.getMessage());
+// throw new TransformerException(e);
+// }
+ //catch (MalformedURLException e) {
+// if (_errorListener != null) postErrorToListener(e.getMessage());
+// throw new TransformerException(e);
+// }
+// catch (UnknownHostException e) {
+// if (_errorListener != null) postErrorToListener(e.getMessage());
+// throw new TransformerException(e);
+// }
catch (Exception e) {
if (_errorListener != null) postErrorToListener(e.getMessage());
throw new TransformerException(e);
@@ -535,7 +565,7 @@
throws TransformerException {
try {
// Build an iternal DOMImpl from the TrAX Source
- DOMImpl dom = getDOM(src, 0);
+ DOM dom = getDOM(src, 0);
// Pass output properties to the translet
setOutputProperties(_translet, _properties);
@@ -915,7 +945,7 @@
* @param mask Contains a document ID (passed from the translet)
* @param translet A reference to the translet requesting the document
*/
- public DOMImpl retrieveDocument(String uri, int mask, Translet translet)
{
+ public DOM retrieveDocument(String uri, int mask, Translet translet) {
try {
return(getDOM(_uriResolver.resolve(uri, ""), mask));
}
1.3.10.1 +38 -14
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.3
retrieving revision 1.3.10.1
diff -u -r1.3 -r1.3.10.1
--- XSLTCSource.java 30 Oct 2001 14:57:54 -0000 1.3
+++ XSLTCSource.java 17 Apr 2002 18:13:47 -0000 1.3.10.1
@@ -1,6 +1,6 @@
/*
- * @(#)$Id: XSLTCSource.java,v 1.3 2001/10/30 14:57:54 morten Exp $
+ * @(#)$Id: XSLTCSource.java,v 1.3.10.1 2002/04/17 18:13:47 mmidy Exp $
*
* The Apache Software License, Version 1.1
*
@@ -79,15 +79,17 @@
import javax.xml.transform.Source;
import org.apache.xalan.xsltc.*;
-import org.apache.xalan.xsltc.dom.DOMImpl;
-import org.apache.xalan.xsltc.dom.DOMBuilder;
-import org.apache.xalan.xsltc.dom.DTDMonitor;
+import org.apache.xalan.xsltc.dom.*;
import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
+import org.apache.xml.dtm.DTMManager;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.ref.DTMManagerDefault;
+
public final class XSLTCSource implements Source {
private String _systemId = null;
- private DOMImpl _dom = null;
+ private DOM _dom = null;
private DTDMonitor _dtd = null;
private final static String LEXICAL_HANDLER_PROPERTY =
@@ -98,17 +100,33 @@
* @param size The estimated node-count for this DOM. A good guess here
* speeds up the DOM build process.
*/
- public XSLTCSource(int size) {
- _dom = new DOMImpl(size);
- _dtd = new DTDMonitor();
+ public XSLTCSource(int size)
+ {
+ DTMManager dtmManager = XSLTCDTMManager.newInstance(
+
org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+ int dtmPos = ((DTMManagerDefault)dtmManager).getFirstFreeDTMID();
+ int documentID = dtmPos << DTMManager.IDENT_DTM_NODE_BITS;
+ _dom = (DOM)new SAXImpl(dtmManager, this, documentID, null,
dtmManager.getXMLStringFactory(), true, size);
+ ((DTMManagerDefault)dtmManager).addDTM((DTM)_dom, dtmPos);
+ //((XSLTCDTMManager)dtmManager).getDTM(this, false, null,
true, true, size);
+ //_dom = new DOMImpl(size);
+ _dtd = new DTDMonitor();
}
/**
* Create a new XSLTC-specific DOM source
*/
- public XSLTCSource() {
- _dom = new DOMImpl();
- _dtd = new DTDMonitor();
+ public XSLTCSource()
+ {
+ DTMManager dtmManager = XSLTCDTMManager.newInstance(
+
org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
+ int dtmPos = ((DTMManagerDefault)dtmManager).getFirstFreeDTMID();
+ int documentID = dtmPos << DTMManager.IDENT_DTM_NODE_BITS;
+ _dom = (DOM)new SAXImpl(dtmManager, this, documentID, null,
dtmManager.getXMLStringFactory(), true);
+ ((DTMManagerDefault)dtmManager).addDTM((DTM)_dom, dtmPos);
+ //(DOM)dtmManager.getDTM(this, false, null, true, true);
+ //_dom = new DOMImpl();
+ _dtd = new DTDMonitor();
}
/**
@@ -124,7 +142,8 @@
_systemId = "file:"+systemId;
else
_systemId = systemId;
- _dom.setDocumentURI(_systemId);
+
+ ((SAXImpl)_dom).setDocumentURI(_systemId);
}
/**
@@ -165,7 +184,12 @@
// build the index used for the id() function
_dtd.handleDTD(reader);
- DOMBuilder builder = _dom.getBuilder();
+ DOMBuilder builder;
+ // Can we assume we're dealing with SAX here and therefore use
SAXIMPL??
+ // if (_dom instanceof DOMImpl)
+ // builder = ((DOMImpl)_dom).getBuilder();
+ // else
+ builder = ((SAXImpl)_dom).getBuilder();
// Set the DOM builder up to receive content and lexical events
reader.setContentHandler(builder);
@@ -224,7 +248,7 @@
/**
* Returns the internal DOM that is encapsulated in this Source
*/
- protected DOMImpl getDOM() {
+ protected DOM getDOM() {
return(_dom);
}
No revision
No revision
1.7.2.1 +5 -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.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- DTM.java 10 Apr 2002 20:33:15 -0000 1.7
+++ DTM.java 17 Apr 2002 18:13:48 -0000 1.7.2.1
@@ -126,6 +126,11 @@
// eg. org.w3c.dom.Document.ELEMENT_NODE?
/**
+ * The node is a <code>Root</code>.
+ */
+ public static final short ROOT_NODE = 0;
+
+ /**
* The node is an <code>Element</code>.
*/
public static final short ELEMENT_NODE = 1;
1.4.12.1 +7 -1
xml-xalan/java/src/org/apache/xml/dtm/DTMAxisIterator.java
Index: DTMAxisIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTMAxisIterator.java,v
retrieving revision 1.4
retrieving revision 1.4.12.1
diff -u -r1.4 -r1.4.12.1
--- DTMAxisIterator.java 4 Aug 2001 20:54:20 -0000 1.4
+++ DTMAxisIterator.java 17 Apr 2002 18:13:48 -0000 1.4.12.1
@@ -70,7 +70,8 @@
*
* @return The next node handle in the iteration, or END.
*/
- public int next();
+ public int next();
+
/**
* Resets the iterator to the last start node.
@@ -129,4 +130,9 @@
* from its current position.
*/
public DTMAxisIterator cloneIterator();
+
+ /**
+ * Set if restartable.
+ */
+ public void setRestartable(boolean isRestartable);
}
1.9.12.1 +5 -2 xml-xalan/java/src/org/apache/xml/dtm/DTMManager.java
Index: DTMManager.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTMManager.java,v
retrieving revision 1.9
retrieving revision 1.9.12.1
diff -u -r1.9 -r1.9.12.1
--- DTMManager.java 23 Jan 2002 22:53:47 -0000 1.9
+++ DTMManager.java 17 Apr 2002 18:13:48 -0000 1.9.12.1
@@ -99,6 +99,10 @@
/** The default property name to load the manager. */
private static final String defaultPropName =
"org.apache.xml.dtm.DTMManager";
+
+ /** The default class name to use as the manager. */
+ private static String defaultClassName =
+ "org.apache.xml.dtm.ref.DTMManagerDefault";
/**
* Factory for creating XMLString objects.
@@ -176,8 +180,7 @@
throws DTMConfigurationException
{
- String classname = findFactory(defaultPropName,
-
"org.apache.xml.dtm.ref.DTMManagerDefault");
+ String classname = findFactory(defaultPropName, defaultClassName);
if (classname == null)
{
No revision
No revision
1.5.12.1 +7 -3
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java
Index: DTMAxisIteratorBase.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java,v
retrieving revision 1.5
retrieving revision 1.5.12.1
diff -u -r1.5 -r1.5.12.1
--- DTMAxisIteratorBase.java 7 Aug 2001 19:16:42 -0000 1.5
+++ DTMAxisIteratorBase.java 17 Apr 2002 18:13:48 -0000 1.5.12.1
@@ -73,7 +73,7 @@
/** The position of the current node within the iteration, as defined by
XPath.
* Note that this is _not_ the node's handle within the DTM!
*/
- private int _position = 0;
+ public int _position = 0;
/** The position of the marked node within the iteration;
* a saved itaration state that we may want to come back to.
@@ -95,7 +95,7 @@
* we are iterating over a stream that can not be re-scanned, or if
* the iterator was produced by cloning another iterator.)
*/
- protected boolean _isRestartable = true;
+ public boolean _isRestartable = true;
/**
* Get start to END should 'close' the iterator,
@@ -287,5 +287,9 @@
{
return -1;
}
-
+
+ public void setRestartable(boolean isRestartable) {
+ _isRestartable = isRestartable;
+ }
+
}
1.28.2.1 +49 -4
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
retrieving revision 1.28.2.1
diff -u -r1.28 -r1.28.2.1
--- DTMDefaultBase.java 10 Apr 2002 20:33:16 -0000 1.28
+++ DTMDefaultBase.java 17 Apr 2002 18:13:48 -0000 1.28.2.1
@@ -143,13 +143,16 @@
/**
* The DTM manager who "owns" this DTM.
*/
- protected DTMManager m_mgr;
+
+ public DTMManager m_mgr;
+
/**
* m_mgr cast to DTMManagerDefault, or null if it isn't an instance
* (Efficiency hook)
*/
protected DTMManagerDefault m_mgrDefault=null;
+
/** The document identity number(s). If we have overflowed the addressing
* range of the first that was assigned to us, we may add others. */
protected SuballocatedIntVector m_dtmIdent=new SuballocatedIntVector();
@@ -475,6 +478,8 @@
*/
protected int _exptype(int identity)
{
+ if (identity == DTM.NULL)
+ return NULL;
// Reorganized test and loop into single flow
// Tiny performance improvement, saves a few bytes of code, clearer.
// %OPT% Other internal getters could be treated simliarly
@@ -894,7 +899,7 @@
* @param nodeIdentity Internal offset to this node's records.
* @return NodeHandle (external representation of node)
* */
- final protected int makeNodeHandle(int nodeIdentity)
+ final public int makeNodeHandle(int nodeIdentity)
{
if(NULL==nodeIdentity) return NULL;
@@ -921,7 +926,7 @@
* @param NodeHandle (external representation of node)
* @return nodeIdentity Internal offset to this node's records.
* */
- final protected int makeNodeIdentity(int nodeHandle)
+ final public int makeNodeIdentity(int nodeHandle)
{
if(NULL==nodeHandle) return NULL;
@@ -1057,6 +1062,8 @@
*/
public int getNextSibling(int nodeHandle)
{
+ if (nodeHandle == DTM.NULL)
+ return DTM.NULL;
return makeNodeHandle(_nextsib(makeNodeIdentity(nodeHandle)));
}
@@ -1071,6 +1078,8 @@
*/
public int getPreviousSibling(int nodeHandle)
{
+ if (nodeHandle == DTM.NULL)
+ return DTM.NULL;
return makeNodeHandle(_prevsib(makeNodeIdentity(nodeHandle)));
}
@@ -1662,7 +1671,9 @@
*/
public short getNodeType(int nodeHandle)
{
- return
m_expandedNameTable.getType(_exptype(makeNodeIdentity(nodeHandle)));
+ if (nodeHandle == DTM.NULL)
+ return DTM.NULL;
+ return
m_expandedNameTable.getType(_exptype(makeNodeIdentity(nodeHandle)));
}
/**
@@ -1678,6 +1689,40 @@
// Apparently, the axis walker stuff requires levels to count from 1.
int identity = makeNodeIdentity(nodeHandle);
return (short) (_level(identity) + 1);
+ }
+
+ /**
+ * <meta name="usage" content="internal"/>
+ * Get the identity of this node in the tree
+ *
+ * @param nodeHandle The node handle.
+ * @return the node identity
+ */
+ public int getNodeIdent(int nodeHandle)
+ {
+ /*if (nodeHandle != DTM.NULL)
+ return nodeHandle & m_mask;
+ else
+ return DTM.NULL;*/
+
+ return makeNodeIdentity(nodeHandle);
+ }
+
+ /**
+ * <meta name="usage" content="internal"/>
+ * Get the handle of this node in the tree
+ *
+ * @param nodeId The node identity.
+ * @return the node handle
+ */
+ public int getNodeHandle(int nodeId)
+ {
+ /*if (nodeId != DTM.NULL)
+ return nodeId | m_dtmIdent;
+ else
+ return DTM.NULL;*/
+
+ return makeNodeHandle(nodeId);
}
// ============== Document query functions ==============
1.12.2.1 +167 -83
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.12
retrieving revision 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- DTMDefaultBaseIterators.java 10 Apr 2002 20:33:16 -0000 1.12
+++ DTMDefaultBaseIterators.java 17 Apr 2002 18:13:48 -0000 1.12.2.1
@@ -245,7 +245,7 @@
*
* Currently there isn't a lot here
*/
- private abstract class InternalAxisIteratorBase extends DTMAxisIteratorBase
+ public abstract class InternalAxisIteratorBase extends DTMAxisIteratorBase
{
// %REVIEW% We could opt to share _nodeType and setNodeType() as
@@ -282,12 +282,13 @@
{
_currentNode = _markedNode;
}
+
} // end of InternalAxisIteratorBase
/**
* Iterator that returns all immediate children of a given node
*/
- private final class ChildrenIterator extends InternalAxisIteratorBase
+ public final class ChildrenIterator extends InternalAxisIteratorBase
{
/**
@@ -302,9 +303,10 @@
*
* @return A DTMAxisIterator set to the start of the iteration.
*/
- public DTMAxisIterator setStartNode(final int node)
+ public DTMAxisIterator setStartNode(int node)
{
-
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
_startNode = node;
@@ -325,7 +327,7 @@
public int next()
{
- _currentNode = (NOTPROCESSED == _currentNode)
+ _currentNode = (_startNode == DTM.NULL) ? DTM.NULL :(NOTPROCESSED ==
_currentNode )
? getFirstChild(_startNode)
: getNextSibling(_currentNode);
@@ -338,7 +340,7 @@
* this delivers only a single node; if you want all the ancestors,
* see AncestorIterator.
*/
- private final class ParentIterator extends InternalAxisIteratorBase
+ public final class ParentIterator extends InternalAxisIteratorBase
{
/** The extended type ID that was requested. */
@@ -354,7 +356,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
-
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
_startNode = node;
@@ -412,7 +415,7 @@
* of a basic child iterator, but a specialised iterator is used
* for efficiency (both speed and size of translet).
*/
- private final class TypedChildrenIterator extends InternalAxisIteratorBase
+ public final class TypedChildrenIterator extends InternalAxisIteratorBase
{
/** The extended type ID that was requested. */
@@ -439,6 +442,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
@@ -459,12 +464,12 @@
public int next()
{
- for (int node = (NOTPROCESSED == _currentNode)
+ for (int node = (_startNode == DTM.NULL) ? DTM.NULL :(NOTPROCESSED ==
_currentNode)
? getFirstChild(_startNode)
: getNextSibling(_currentNode); node
!= END; node = getNextSibling(node))
{
- if (getExpandedTypeID(node) == _nodeType)
+ if (getExpandedTypeID(node) == _nodeType || getNodeType(node) ==
_nodeType)
{
_currentNode = node;
@@ -482,7 +487,7 @@
* filter on top of a basic child iterator, but a specialised
* iterator is used for efficiency (both speed and size of translet).
*/
- private final class NamespaceChildrenIterator
+ public final class NamespaceChildrenIterator
extends InternalAxisIteratorBase
{
@@ -510,7 +515,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
-
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
_startNode = node;
@@ -551,7 +557,7 @@
* Iterator that returns the namespace nodes as defined by the XPath data
model
* for a given node.
*/
- private class NamespaceIterator
+ public class NamespaceIterator
extends InternalAxisIteratorBase
{
@@ -574,7 +580,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
-
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
_startNode = node;
@@ -607,7 +614,7 @@
* Iterator that returns the namespace nodes as defined by the XPath data
model
* for a given node, filtered by extended type ID.
*/
- private class TypedNamespaceIterator extends NamespaceIterator
+ public class TypedNamespaceIterator extends NamespaceIterator
{
/** The extended type ID that was requested. */
@@ -632,10 +639,12 @@
*/
public int next()
{
+ int node;
- for (int node = super.next(); node != END; node = super.next())
+ for (node = _currentNode; node != END; node =
getNextNamespaceNode(_startNode, node, true))
{
- if (getExpandedTypeID(node) == _nodeType)
+ if (getExpandedTypeID(node) == _nodeType || getNodeType(node) ==
_nodeType
+ || getNamespaceType(node) == _nodeType)
{
_currentNode = node;
@@ -643,7 +652,7 @@
}
}
- return END;
+ return (_currentNode =END);
}
} // end of TypedNamespaceIterator
@@ -651,7 +660,7 @@
* Iterator that returns the the root node as defined by the XPath data
model
* for a given node.
*/
- private class RootIterator
+ public class RootIterator
extends InternalAxisIteratorBase
{
@@ -706,7 +715,7 @@
* Iterator that returns the namespace nodes as defined by the XPath data
model
* for a given node, filtered by extended type ID.
*/
- private class TypedRootIterator extends RootIterator
+ public class TypedRootIterator extends RootIterator
{
/** The extended type ID that was requested. */
@@ -730,16 +739,16 @@
*/
public int next()
{
+ if(_startNode == _currentNode)
+ return NULL;
- for (int node = super.next(); node != END; node = super.next())
- {
- if (getExpandedTypeID(node) == _nodeType)
- {
- _currentNode = node;
+ _currentNode = _startNode;
- return returnNode(node);
+ if (getExpandedTypeID(_startNode) == _nodeType ||
getNodeType(_startNode) == _nodeType)
+ {
+ return returnNode(_startNode);
}
- }
+
return END;
}
@@ -748,7 +757,7 @@
/**
* Iterator that returns attributes within a given namespace for a node.
*/
- private final class NamespaceAttributeIterator
+ public final class NamespaceAttributeIterator
extends InternalAxisIteratorBase
{
@@ -779,7 +788,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
-
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
_startNode = node;
@@ -811,7 +821,7 @@
/**
* Iterator that returns all siblings of a given node.
*/
- private class FollowingSiblingIterator extends InternalAxisIteratorBase
+ public class FollowingSiblingIterator extends InternalAxisIteratorBase
{
/**
@@ -824,7 +834,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
-
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
_currentNode = _startNode = node;
@@ -849,7 +860,7 @@
/**
* Iterator that returns all following siblings of a given node.
*/
- private final class TypedFollowingSiblingIterator
+ public final class TypedFollowingSiblingIterator
extends FollowingSiblingIterator
{
@@ -875,19 +886,17 @@
public int next()
{
- int node;
-
- while ((node = super.next()) != NULL
- && getExpandedTypeID(node) != _nodeType){}
+ while ((_currentNode = getNextSibling(_currentNode)) != NULL
+ && (getExpandedTypeID(_currentNode) != _nodeType &&
getNodeType(_currentNode) != _nodeType)){}
- return node;
+ return (_currentNode == NULL ? NULL : returnNode(_currentNode));
}
} // end of TypedFollowingSiblingIterator
/**
* Iterator that returns attribute nodes (of what nodes?)
*/
- private final class AttributeIterator extends InternalAxisIteratorBase
+ public final class AttributeIterator extends InternalAxisIteratorBase
{
// assumes caller will pass element nodes
@@ -902,7 +911,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
-
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
_startNode = node;
@@ -933,7 +943,7 @@
/**
* Iterator that returns attribute nodes of a given type
*/
- private final class TypedAttributeIterator extends InternalAxisIteratorBase
+ public final class TypedAttributeIterator extends InternalAxisIteratorBase
{
/** The extended type ID that was requested. */
@@ -962,6 +972,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
@@ -1003,7 +1015,7 @@
/**
* Iterator that returns preceding siblings of a given node
*/
- private class PrecedingSiblingIterator extends InternalAxisIteratorBase
+ public class PrecedingSiblingIterator extends InternalAxisIteratorBase
{
/**
@@ -1026,6 +1038,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
_startNode = node;
@@ -1034,8 +1048,8 @@
{
_currentNode = node;
return resetPosition();
- }
-
+ }
+
int type = m_expandedNameTable.getType(getExpandedTypeID(node));
if(ExpandedNameTable.ATTRIBUTE == type
|| ExpandedNameTable.NAMESPACE == type )
@@ -1084,7 +1098,7 @@
* Iterator that returns preceding siblings of a given type for
* a given node
*/
- private final class TypedPrecedingSiblingIterator
+ public final class TypedPrecedingSiblingIterator
extends PrecedingSiblingIterator
{
@@ -1111,11 +1125,22 @@
{
int node;
+ do{
+ if (_currentNode == _startNode)
+ {
+ node = NULL;
+ }
+ else
+ {
+ node = _currentNode;
+ _currentNode = getNextSibling(node);
- while ((node = super.next()) != NULL
- && getExpandedTypeID(node) != _nodeType){}
+ }
+ }
+ while (node != NULL
+ && (getExpandedTypeID(node) != _nodeType && getNodeType(node)
!= _nodeType));
- return node;
+ return (node == NULL ? NULL : returnNode(node));
}
} // end of PrecedingSiblingIterator
@@ -1124,7 +1149,7 @@
* This includes the node set {root+1, start-1}, but excludes
* all ancestors.
*/
- private class PrecedingIterator extends InternalAxisIteratorBase
+ public class PrecedingIterator extends InternalAxisIteratorBase
{
/** The max ancestors, but it can grow... */
@@ -1134,10 +1159,10 @@
* The stack of start node + ancestors up to ROOTNODE,
* which we must avoid.
*/
- private int[] _stack = new int[_maxAncestors];
+ protected int[] _stack = new int[_maxAncestors];
/** (not sure yet... -sb) */
- private int _sp, _oldsp;
+ protected int _sp, _oldsp;
/* _currentNode precedes candidates. This is the identity, not the
handle! */
@@ -1187,6 +1212,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
@@ -1195,9 +1222,14 @@
// iterator is not a clone
int parent, index;
+ if (_type(node) == DTM.ATTRIBUTE_NODE)
+ node = _parent(node);
+
_startNode = node;
_currentNode = ROOTNODE; // Remember it's the identity, not the
full handle.
_stack[index = 0] = node;
+
+
if (node > ROOTNODE)
{
@@ -1268,7 +1300,7 @@
* given node. This includes the node set {root+1, start-1}, but
* excludes all ancestors.
*/
- private final class TypedPrecedingIterator extends PrecedingIterator
+ public final class TypedPrecedingIterator extends PrecedingIterator
{
/** The extended type ID that was requested. */
@@ -1293,19 +1325,32 @@
public int next()
{
- int node;
-
- while ((node = super.next()) != NULL
- && getExpandedTypeID(node) != _nodeType){}
+ int node;
+
+ do{
+ node = _currentNode + 1;
+ if ((_sp >= 0) && (node < _stack[_sp]))
+ {
+ node = makeNodeHandle((_currentNode = node)); // | m_dtmIdent);
+ }
+ else
+ {
+ _currentNode = node; // skip ancestor
- return node;
+ node = (--_sp >= 0 ? makeNodeHandle(node)/*next()*/ : NULL);
+ }
+ }
+ while (node /*= super.next())*/ != NULL
+ && (getExpandedTypeID(node) != _nodeType && getNodeType(node)
!= _nodeType));
+
+ return (node == NULL ? NULL : returnNode(node));
}
} // end of TypedPrecedingIterator
/**
* Iterator that returns following nodes of for a given node.
*/
- private class FollowingIterator extends InternalAxisIteratorBase
+ public class FollowingIterator extends InternalAxisIteratorBase
{
DTMAxisTraverser m_traverser; // easier for now
@@ -1324,7 +1369,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
-
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
_startNode = node;
@@ -1362,7 +1408,7 @@
/**
* Iterator that returns following nodes of a given type for a given node.
*/
- private final class TypedFollowingIterator extends FollowingIterator
+ public final class TypedFollowingIterator extends FollowingIterator
{
/** The extended type ID that was requested. */
@@ -1388,11 +1434,17 @@
{
int node;
+
+ do{
+ node = _currentNode;
- while ((node = super.next()) != NULL
- && getExpandedTypeID(node) != _nodeType){}
+ _currentNode = m_traverser.next(_startNode, _currentNode);
- return returnNode(node);
+ }
+ while (node != NULL
+ && (getExpandedTypeID(node) != _nodeType && getNodeType(node)
!= _nodeType));
+
+ return (node == NULL ? NULL :returnNode(node));
}
} // end of TypedFollowingIterator
@@ -1400,7 +1452,7 @@
* Iterator that returns the ancestors of a given node in document
* order. (NOTE! This was changed from the XSLTC code!)
*/
- private class AncestorIterator extends InternalAxisIteratorBase
+ public class AncestorIterator extends InternalAxisIteratorBase
{
org.apache.xml.utils.NodeVector m_ancestors =
new org.apache.xml.utils.NodeVector();
@@ -1480,6 +1532,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
m_realStartNode = node;
if (_isRestartable)
@@ -1544,7 +1598,7 @@
/**
* Typed iterator that returns the ancestors of a given node.
*/
- private final class TypedAncestorIterator extends AncestorIterator
+ public final class TypedAncestorIterator extends AncestorIterator
{
/** The extended type ID that was requested. */
@@ -1570,14 +1624,21 @@
{
int node;
-
- while ((node = super.next()) != NULL)
+ do
{
- if (getExpandedTypeID(node) == _nodeType)
- return returnNode(node);
+ node = _currentNode;
+
+ int pos = m_ancestorsPos--;
+ if(pos < 0)
+ _currentNode = DTM.NULL;
+ else
+ _currentNode = m_ancestors.elementAt(pos);
}
-
- return (NULL);
+ while ((node != NULL)
+ && (getExpandedTypeID(node) != _nodeType && getNodeType(node) !=
_nodeType));
+
+ return (node == NULL ? NULL : returnNode(node));
+
}
/**
@@ -1606,7 +1667,7 @@
/**
* Iterator that returns the descendants of a given node.
*/
- private class DescendantIterator extends InternalAxisIteratorBase
+ public class DescendantIterator extends InternalAxisIteratorBase
{
/**
@@ -1619,7 +1680,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
-
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isRestartable)
{
node = makeNodeIdentity(node);
@@ -1663,6 +1725,9 @@
public int next()
{
+ if (_includeSelf && (_currentNode + 1) == _startNode)
+ return returnNode(makeNodeHandle(++_currentNode)); // |
m_dtmIdent);
+
while (true)
{
int node = ++_currentNode;
@@ -1671,7 +1736,7 @@
if (NULL == type ||!isDescendant(node))
return END;
- if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type)
+ if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type || TEXT_NODE ==
type)
continue;
return returnNode(makeNodeHandle(node)); // make handle.
@@ -1682,7 +1747,7 @@
/**
* Typed iterator that returns the descendants of a given node.
*/
- private final class TypedDescendantIterator extends DescendantIterator
+ public final class TypedDescendantIterator extends DescendantIterator
{
/** The extended type ID that was requested. */
@@ -1708,11 +1773,24 @@
{
int node;
+ do
+ {
+ node = ++_currentNode;
+ int type = _type(node);
+
+ if (NULL == type ||!isDescendant(node))
+ return END;
+
+ /* if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type)
+ continue;*/
+
+ node = makeNodeHandle(node); // | m_dtmIdent); // make handle.
+ }
- while ((node = super.next()) != NULL
- && getExpandedTypeID(node) != _nodeType){}
+ while (node != NULL
+ && (getExpandedTypeID(node) != _nodeType && getNodeType(node)
!= _nodeType));
- return node;
+ return (node == NULL ? NULL :returnNode(node));
}
} // end of TypedDescendantIterator
@@ -1720,7 +1798,7 @@
* Iterator that returns the descendants of a given node.
* I'm not exactly clear about this one... -sb
*/
- private class NthDescendantIterator extends DescendantIterator
+ public class NthDescendantIterator extends DescendantIterator
{
/** The current nth position. */
@@ -1776,7 +1854,7 @@
/**
* Class SingletonIterator.
*/
- private class SingletonIterator extends InternalAxisIteratorBase
+ public class SingletonIterator extends InternalAxisIteratorBase
{
/** (not sure yet what this is. -sb) (sc & sb remove final to compile
in JDK 1.1.8) */
@@ -1811,6 +1889,8 @@
*/
public SingletonIterator(int node, boolean constant)
{
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
_currentNode = _startNode = node;
_isConstant = constant;
}
@@ -1825,7 +1905,8 @@
*/
public DTMAxisIterator setStartNode(int node)
{
-
+ if (node == DTMDefaultBase.ROOTNODE)
+ node = getDocument();
if (_isConstant)
{
_currentNode = _startNode;
@@ -1893,7 +1974,7 @@
/**
* Iterator that returns a given node only if it is of a given type.
*/
- private final class TypedSingletonIterator extends SingletonIterator
+ public final class TypedSingletonIterator extends SingletonIterator
{
/** The extended type ID that was requested. */
@@ -1918,9 +1999,12 @@
public int next()
{
- final int result = super.next();
+ //final int result = super.next();
+ final int result = _currentNode;
+
+ _currentNode = END;
- return getExpandedTypeID(result) == _nodeType ? result : NULL;
+ return (getExpandedTypeID(result) == _nodeType || getNodeType(result)
== _nodeType) ? returnNode(result) : NULL;
}
} // end of TypedSingletonIterator
}
1.3.14.1 +1 -1
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNamedNodeMap.java
Index: DTMNamedNodeMap.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNamedNodeMap.java,v
retrieving revision 1.3
retrieving revision 1.3.14.1
diff -u -r1.3 -r1.3.14.1
--- DTMNamedNodeMap.java 15 Jun 2001 15:52:58 -0000 1.3
+++ DTMNamedNodeMap.java 17 Apr 2002 18:13:48 -0000 1.3.14.1
@@ -94,7 +94,7 @@
* @param dtm The DTM Reference, must be non-null.
* @param element The DTM element handle.
*/
- DTMNamedNodeMap(DTM dtm, int element)
+ public DTMNamedNodeMap(DTM dtm, int element)
{
this.dtm = dtm;
this.element = element;
1.5.12.1 +3 -0
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeList.java
Index: DTMNodeList.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeList.java,v
retrieving revision 1.5
retrieving revision 1.5.12.1
diff -u -r1.5 -r1.5.12.1
--- DTMNodeList.java 13 Nov 2001 22:09:42 -0000 1.5
+++ DTMNodeList.java 17 Apr 2002 18:13:48 -0000 1.5.12.1
@@ -105,6 +105,8 @@
* AGAINST THE DTMIterator.
* */
public DTMNodeList(DTMIterator dtmIterator)
+ {
+ if (dtmIterator != null)
{
int pos = dtmIterator.getCurrentPos();
try
@@ -116,6 +118,7 @@
dtm_iter.runTo(-1);
dtm_iter.setCurrentPos(pos);
}
+ }
/** Public constructor: Create a NodeList to support
* DTMNodeProxy.getChildren().
1.13.8.1 +1 -1
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeProxy.java
Index: DTMNodeProxy.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeProxy.java,v
retrieving revision 1.13
retrieving revision 1.13.8.1
diff -u -r1.13 -r1.13.8.1
--- DTMNodeProxy.java 8 Feb 2002 23:33:50 -0000 1.13
+++ DTMNodeProxy.java 17 Apr 2002 18:13:48 -0000 1.13.8.1
@@ -94,7 +94,7 @@
* @param dtm The DTM Reference, must be non-null.
* @param node The DTM node handle.
*/
- DTMNodeProxy(DTM dtm, int node)
+ public DTMNodeProxy(DTM dtm, int node)
{
this.dtm = dtm;
this.node = node;
1.4.2.1 +8 -3
xml-xalan/java/src/org/apache/xml/dtm/ref/ExpandedNameTable.java
Index: ExpandedNameTable.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/ExpandedNameTable.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- ExpandedNameTable.java 10 Apr 2002 20:33:16 -0000 1.4
+++ ExpandedNameTable.java 17 Apr 2002 18:13:48 -0000 1.4.2.1
@@ -221,7 +221,7 @@
* @param ExpandedNameID an ID that represents an expanded-name.
* @return The id of this local name.
*/
- public /*static*/ final int getLocalNameID(int ExpandedNameID)
+ public final int getLocalNameID(int ExpandedNameID)
{
//return (ExpandedNameID & MASK_LOCALNAME);
ExtendedType etype = (ExtendedType)m_extendedTypes.elementAt
(ExpandedNameID);
@@ -254,7 +254,7 @@
* @param ExpandedNameID an ID that represents an expanded-name.
* @return The id of this namespace.
*/
- public /*static*/ final int getNamespaceID(int ExpandedNameID)
+ public final int getNamespaceID(int ExpandedNameID)
{
//return (ExpandedNameID & MASK_NAMESPACE) >> BITS_PER_LOCALNAME;
ExtendedType etype = (ExtendedType)m_extendedTypes.elementAt
(ExpandedNameID);
@@ -272,11 +272,15 @@
*/
public final short getType(int ExpandedNameID)
{
- //return (short)(ExpandedNameID >> ROTAMOUNT_TYPE);
ExtendedType etype = (ExtendedType)m_extendedTypes.elementAt
(ExpandedNameID);
return (short)etype.nodetype;
}
+ public int getSize()
+ {
+ return m_nextType;
+ }
+
/**
* Private class representing an extended type object
@@ -293,6 +297,7 @@
this.namespace = namespace;
this.localName = localName;
}
+
}
}
No revision
No revision
1.28.2.1 +1 -0
xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
Index: DOM2DTM.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java,v
retrieving revision 1.28
retrieving revision 1.28.2.1
diff -u -r1.28 -r1.28.2.1
--- DOM2DTM.java 10 Apr 2002 20:33:16 -0000 1.28
+++ DOM2DTM.java 17 Apr 2002 18:13:49 -0000 1.28.2.1
@@ -1764,6 +1764,7 @@
{
return null;
}
+
}
No revision
No revision
1.28.2.1 +96 -38
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.28
retrieving revision 1.28.2.1
diff -u -r1.28 -r1.28.2.1
--- SAX2DTM.java 10 Apr 2002 20:33:16 -0000 1.28
+++ SAX2DTM.java 17 Apr 2002 18:13:49 -0000 1.28.2.1
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
@@ -227,6 +227,7 @@
*/
protected boolean m_useSourceLocationProperty = false;
+
/** Made protected for access by SAX2RTFDTM.
*/
protected StringVector m_sourceSystemId;
@@ -237,6 +238,7 @@
*/
protected IntVector m_sourceColumn;
+
/**
* Construct a SAX2DTM object ready to be constructed from SAX2
* ContentHandler events.
@@ -247,7 +249,7 @@
* @param whiteSpaceFilter The white space filter for this DTM, which may
* be null.
* @param xstringfactory XMLString factory for creating character content.
- * @param doIndexing true if the caller considers it worth it to use
+ * @param doIndexing true if the caller considers it worth it to use
* indexing schemes.
*/
public SAX2DTM(DTMManager mgr, Source source, int dtmIdentity,
@@ -256,8 +258,9 @@
boolean doIndexing)
{
- super(mgr, source, dtmIdentity, whiteSpaceFilter,
+ super(mgr, source, dtmIdentity, whiteSpaceFilter,
xstringfactory, doIndexing);
+
// %REVIEW% Initial size pushed way down to reduce weight of RTFs
// (I'm not entirely sure 0 would work, so I'm playing it safe for now.)
@@ -291,8 +294,8 @@
if (identity < m_size)
return m_dataOrQName.elementAt(identity);
- // Check to see if the information requested has been processed, and,
- // if not, advance the iterator until we the information has been
+ // Check to see if the information requested has been processed, and,
+ // if not, advance the iterator until we the information has been
// processed.
while (true)
{
@@ -469,14 +472,14 @@
*
* @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
+ * @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 void dispatchCharactersEvents(int nodeHandle, ContentHandler ch,
+ public void dispatchCharactersEvents(int nodeHandle, ContentHandler ch,
boolean normalize)
throws SAXException
{
@@ -489,7 +492,7 @@
int dataIndex = m_dataOrQName.elementAt(identity);
int offset = m_data.elementAt(dataIndex);
int length = m_data.elementAt(dataIndex + 1);
-
+
if(normalize)
m_chars.sendNormalizedSAXcharacters(ch, offset, length);
else
@@ -547,7 +550,7 @@
String str = m_valuesOrPrefixes.indexToString(dataIndex);
if(normalize)
- FastStringBuffer.sendNormalizedSAXcharacters(str.toCharArray(),
+ FastStringBuffer.sendNormalizedSAXcharacters(str.toCharArray(),
0, str.length(),
ch);
else
ch.characters(str.toCharArray(), 0, str.length());
@@ -739,7 +742,7 @@
*
* @return The number of that are currently in the tree.
*/
- protected int getNumberOfNodes()
+ public int getNumberOfNodes()
{
return m_size;
}
@@ -787,7 +790,7 @@
return false;
- // %TBD%
+ // %TBD%
}
if (gotMore != Boolean.TRUE)
@@ -878,7 +881,7 @@
m_prevsib.addElement(previousSibling);
m_parent.addElement(parentIndex);
m_exptype.addElement(expandedTypeID);
- m_dataOrQName.addElement(dataOrPrefix);
+ m_dataOrQName.addElement(dataOrPrefix);
if (m_useSourceLocationProperty && m_locator != null)
{
@@ -1035,13 +1038,13 @@
if (null != nname)
{
- // The draft says: "The XSLT processor may use the public
- // identifier to generate a URI for the entity instead of the URI
- // specified in the system identifier. If the XSLT processor does
- // not use the public identifier to generate the URI, it must use
- // the system identifier; if the system identifier is a relative
- // URI, it must be resolved into an absolute URI using the URI of
- // the resource containing the entity declaration as the base
+ // The draft says: "The XSLT processor may use the public
+ // identifier to generate a URI for the entity instead of the URI
+ // specified in the system identifier. If the XSLT processor does
+ // not use the public identifier to generate the URI, it must use
+ // the system identifier; if the system identifier is a relative
+ // URI, it must be resolved into an absolute URI using the URI of
+ // the resource containing the entity declaration as the base
// URI [RFC2396]."
// So I'm falling a bit short here.
url = (String) m_entities.elementAt(i + ENTITY_FIELD_SYSTEMID);
@@ -1075,7 +1078,7 @@
{
int identity = makeNodeIdentity(nodeHandle);
- int type = getNodeType(identity);
+ int type = getNodeType(nodeHandle);
if (DTM.ELEMENT_NODE == type)
{
@@ -1302,7 +1305,7 @@
*
* @return The prefix if there is one, or null.
*/
- private String getPrefix(String qname, String uri)
+ public String getPrefix(String qname, String uri)
{
String prefix;
@@ -1330,11 +1333,11 @@
prefix = qname.substring(indexOfNSSep + 1);
else
prefix = (indexOfNSSep > 0)
- ? qname.substring(0, indexOfNSSep) : null;
+ ? qname.substring(0, indexOfNSSep) : ""; //null;
}
else
{
- prefix = null; // ??
+ prefix = ""; //null; // ??
}
}
else if (null != qname)
@@ -1346,15 +1349,62 @@
else if (qname.startsWith("xmlns:"))
prefix = qname.substring(indexOfNSSep + 1);
else
- prefix = (indexOfNSSep > 0) ? qname.substring(0, indexOfNSSep) :
null;
+ prefix = (indexOfNSSep > 0) ? qname.substring(0, indexOfNSSep) : "";
//null;
}
else
{
- prefix = null;
+ prefix = ""; //null;
}
return prefix;
}
+
+ /**
+ * Get a prefix either from the uri mapping, or just make
+ * one up!
+ *
+ * @param uri The namespace URI, which may be null.
+ *
+ * @return The prefix if there is one, or null.
+ */
+ public int getIdForNamespace(String uri)
+ {
+
+ return m_valuesOrPrefixes.stringToIndex(uri);
+
+ }
+
+ /**
+ * Get a prefix either from the qname or from the uri mapping, or just make
+ * one up!
+ *
+ * @param qname The qualified name, which may be null.
+ * @param uri The namespace URI, which may be null.
+ *
+ * @return The prefix if there is one, or null.
+ */
+ public String getNamespaceURI(String prefix)
+ {
+
+ String uri = "";
+ int prefixIndex = m_contextIndexes.peek() - 1 ;
+
+ if(null == prefix)
+ prefix = "";
+
+ do
+ {
+ prefixIndex = m_prefixMappings.indexOf(prefix, ++prefixIndex);
+ } while ( (prefixIndex >= 0) && (prefixIndex & 0x01) == 0x01);
+
+ if (prefixIndex > -1)
+ {
+ uri = (String) m_prefixMappings.elementAt(prefixIndex + 1);
+ }
+
+
+ return uri;
+ }
/**
* Set an ID string to node association in the ID table.
@@ -1550,10 +1600,10 @@
int doc = addNode(DTM.DOCUMENT_NODE,
m_expandedNameTable.getExpandedTypeID(DTM.DOCUMENT_NODE),
DTM.NULL, DTM.NULL, 0, true);
-
+
m_parents.push(doc);
m_previous = DTM.NULL;
-
+
m_contextIndexes.push(m_prefixMappings.size()); // for the next element.
}
@@ -1678,7 +1728,7 @@
return false;
}
-
+
boolean m_pastFirstElement=false;
/**
@@ -1738,9 +1788,11 @@
int elemNode = addNode(DTM.ELEMENT_NODE, exName,
m_parents.peek(), m_previous, prefixIndex, true);
+
if(m_indexing)
indexNode(exName, elemNode);
+
m_parents.push(elemNode);
int startDecls = m_contextIndexes.peek();
@@ -1758,7 +1810,7 @@
prev, val, false);
m_pastFirstElement=true;
}
-
+
for (int i = startDecls; i < nDecls; i += 2)
{
prefix = (String) m_prefixMappings.elementAt(i);
@@ -1787,6 +1839,8 @@
prefix = getPrefix(attrQName, attrUri);
int nodeType;
+
+ String attrLocalName = attributes.getLocalName(i);
if ((null != attrQName)
&& (attrQName.equals("xmlns")
@@ -1795,6 +1849,7 @@
if (declAlreadyDeclared(prefix))
continue; // go to the next attribute.
+ attrLocalName = attrQName = prefix;
nodeType = DTM.NAMESPACE_NODE;
}
else
@@ -1804,18 +1859,18 @@
if (attributes.getType(i).equalsIgnoreCase("ID"))
setIDAttribute(valString, elemNode);
}
-
- // Bit of a hack... if somehow valString is null, stringToIndex will
+
+ // Bit of a hack... if somehow valString is null, stringToIndex will
// return -1, which will make things very unhappy.
if(null == valString)
valString = "";
int val = m_valuesOrPrefixes.stringToIndex(valString);
- String attrLocalName = attributes.getLocalName(i);
+ //String attrLocalName = attributes.getLocalName(i);
if (null != prefix)
{
-
+
prefixIndex = m_valuesOrPrefixes.stringToIndex(attrQName);
int dataIndex = m_data.size();
@@ -1954,6 +2009,7 @@
public void ignorableWhitespace(char ch[], int start, int length)
throws SAXException
{
+
// %OPT% We can probably take advantage of the fact that we know this
// is whitespace.
characters(ch, start, length);
@@ -2302,12 +2358,12 @@
int exName = m_expandedNameTable.getExpandedTypeID(DTM.COMMENT_NODE);
- // For now, treat comments as strings... I guess we should do a
+ // For now, treat comments as strings... I guess we should do a
// seperate FSB buffer instead.
int dataIndex = m_valuesOrPrefixes.stringToIndex(new String(ch, start,
length));
- m_previous = addNode(DTM.COMMENT_NODE, exName,
+ m_previous = addNode(DTM.COMMENT_NODE, exName,
m_parents.peek(), m_previous, dataIndex, false);
}
@@ -2336,8 +2392,10 @@
{
if (m_useSourceLocationProperty)
{
+
node = makeNodeIdentity(node);
+
return new NodeLocator(null,
m_sourceSystemId.elementAt(node),
m_sourceLine.elementAt(node),
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]