morten 01/08/27 02:07:22
Modified: java/src/org/apache/xalan/xsltc DOM.java
java/src/org/apache/xalan/xsltc/compiler
AbsoluteLocationPath.java AbsolutePathPattern.java
AncestorPattern.java ApplyTemplates.java
BooleanExpr.java CallTemplate.java CastExpr.java
Constants.java Copy.java CopyOf.java
DocumentCall.java FilterExpr.java
FilteredAbsoluteLocationPath.java ForEach.java
FunctionCall.java Key.java KeyCall.java
LastCall.java LocalNameCall.java Mode.java
NameCall.java NamespaceUriCall.java Number.java
Param.java ParameterRef.java
ParentLocationPath.java ParentPattern.java
PositionCall.java Predicate.java
RelationalExpr.java Sort.java Step.java
StepPattern.java Stylesheet.java
SyntaxTreeNode.java Template.java TestSeq.java
Text.java TransletOutput.java ValueOf.java
Variable.java VariableRef.java Whitespace.java
XSLTC.java
java/src/org/apache/xalan/xsltc/compiler/util
ClassGenerator.java ErrorMsg.java
MethodGenerator.java NodeSetType.java NodeType.java
ResultTreeType.java
java/src/org/apache/xalan/xsltc/dom Axis.java
DOMAdapter.java DOMImpl.java LoadDocument.java
MultiDOM.java
java/src/org/apache/xalan/xsltc/runtime
AbstractTranslet.java BasisLibrary.java
Log:
Changes all calls from the compiled translet code to the DOM to be calls
to the DOM interface (and not to a specific DOM class). I did this to make
it possible to plugi in any DOM implementation.
PR: n/a
Obtained from: n/a
Submitted by: [EMAIL PROTECTED]
Reviewed by: [EMAIL PROTECTED]
Revision Changes Path
1.3 +6 -1 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOM.java 2001/07/30 13:35:40 1.2
+++ DOM.java 2001/08/27 09:07:19 1.3
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOM.java,v 1.2 2001/07/30 13:35:40 morten Exp $
+ * @(#)$Id: DOM.java,v 1.3 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -120,4 +120,9 @@
public NodeList makeNodeList(NodeIterator iter);
public String getLanguage(int node);
public int getSize();
+ public String getDocumentURI(int node);
+ public int getTypedPosition(NodeIterator iterator, int type, int node);
+ public int getTypedLast(NodeIterator iterator, int type, int node);
+ public void setFilter(StripFilter filter);
+ public void setupMapping(String[] names, String[] namespaces);
}
1.4 +5 -6
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsoluteLocationPath.java
Index: AbsoluteLocationPath.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsoluteLocationPath.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbsoluteLocationPath.java 2001/06/17 12:23:26 1.3
+++ AbsoluteLocationPath.java 2001/08/27 09:07:19 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AbsoluteLocationPath.java,v 1.3 2001/06/17 12:23:26 curcuru Exp $
+ * @(#)$Id: AbsoluteLocationPath.java,v 1.4 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -127,12 +127,11 @@
il.append(new INVOKESPECIAL(initAI));
}
else {
- final String DOM_CLASS = classGen.getDOMClass();
+ final int gitr = cpg.addInterfaceMethodref(DOM_INTF,
+ "getIterator",
+ "()"+NODE_ITERATOR_SIG);
il.append(methodGen.loadDOM());
- il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- "getIterator",
- "()"
- +NODE_ITERATOR_SIG)));
+ il.append(new INVOKEINTERFACE(gitr, 1));
}
}
}
1.3 +8 -7
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbsolutePathPattern.java 2001/08/07 12:43:03 1.2
+++ AbsolutePathPattern.java 2001/08/27 09:07:19 1.3
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AbsolutePathPattern.java,v 1.2 2001/08/07 12:43:03 morten Exp $
+ * @(#)$Id: AbsolutePathPattern.java,v 1.3 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -105,7 +105,6 @@
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
if (_left != null) {
if (_left instanceof StepPattern) {
@@ -127,17 +126,19 @@
_trueList.append(_left._trueList);
_falseList.append(_left._falseList);
}
+ final int getParent = cpg.addInterfaceMethodref(DOM_INTF,
+ GET_PARENT,
+ GET_PARENT_SIG);
+ final int getType = cpg.addInterfaceMethodref(DOM_INTF,
+ "getType", "(I)I");
il.append(methodGen.loadDOM());
il.append(SWAP);
- il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- GET_PARENT,
- GET_PARENT_SIG)));
+ il.append(new INVOKEINTERFACE(getParent, 2));
if (_left instanceof AncestorPattern) {
il.append(methodGen.loadDOM());
il.append(SWAP);
}
- il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- "getType", "(I)I")));
+ il.append(new INVOKEINTERFACE(getType, 2));
il.append(new PUSH(cpg, DOM.ROOT));
_falseList.add(il.append(new IF_ICMPNE(null)));
}
1.3 +5 -6
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AncestorPattern.java 2001/07/10 17:45:02 1.2
+++ AncestorPattern.java 2001/08/27 09:07:19 1.3
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AncestorPattern.java,v 1.2 2001/07/10 17:45:02 morten Exp $
+ * @(#)$Id: AncestorPattern.java,v 1.3 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -114,7 +114,6 @@
InstructionHandle loop, eloop;
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
final LocalVariableGen local =
methodGen.addLocalVariable2("app",
Util.getJCRefType(NODE_SIG),
@@ -137,10 +136,10 @@
}
if (_left != null) {
- final int getParent = cpg.addMethodref(DOM_CLASS,
- GET_PARENT,
- GET_PARENT_SIG);
- loop = il.append(new INVOKEVIRTUAL(getParent));
+ final int getParent = cpg.addInterfaceMethodref(DOM_INTF,
+ GET_PARENT,
+ GET_PARENT_SIG);
+ loop = il.append(new INVOKEINTERFACE(getParent, 2));
il.append(DUP);
il.append(storeLocal);
1.6 +34 -19
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ApplyTemplates.java
Index: ApplyTemplates.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ApplyTemplates.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ApplyTemplates.java 2001/06/17 12:23:27 1.5
+++ ApplyTemplates.java 2001/08/27 09:07:19 1.6
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ApplyTemplates.java,v 1.5 2001/06/17 12:23:27 curcuru Exp $
+ * @(#)$Id: ApplyTemplates.java,v 1.6 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -78,6 +78,7 @@
final class ApplyTemplates extends Instruction {
private Expression _select;
+ private Type _type = null;
private QName _modeName;
private String _functionName;
@@ -116,17 +117,18 @@
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (_select != null) {
- Type tselect = _select.typeCheck(stable);
- if (tselect instanceof NodeType ||
- tselect instanceof ReferenceType) {
+ _type = _select.typeCheck(stable);
+ if (_type instanceof NodeType || _type instanceof ReferenceType) {
_select = new CastExpr(_select, Type.NodeSet);
- tselect = Type.NodeSet;
+ _type = Type.NodeSet;
}
- if (tselect instanceof NodeSetType) {
- typeCheckContents(stable); // with-params
+ if (_type instanceof NodeSetType||_type instanceof ResultTreeType) {
+ typeCheckContents(stable); // with-params
return Type.Void;
- }
- throw new TypeCheckError(this);
+ }
+ String msg = "Unsupported type for <xsl:apply-templates select='"+
+ _type+"'/>";
+ throw new TypeCheckError(new ErrorMsg(msg));
}
else {
typeCheckContents(stable); // with-params
@@ -165,23 +167,36 @@
translateContents(classGen, methodGen);
}
- // push arguments for final call to applyTemplates
il.append(classGen.loadTranslet());
- il.append(methodGen.loadDOM());
-
- // compute node iterator for applyTemplates
- if (sortObjects.size() > 0) {
- Sort.translateSortIterator(classGen, methodGen,
- _select, sortObjects);
+
+ // The 'select' expression is a result-tree
+ if ((_type != null) && (_type instanceof ResultTreeType)) {
+ // <xsl:sort> cannot be applied to a result tree - issue warning
+ if (sortObjects.size() > 0) {
+ ErrorMsg msg = new ErrorMsg(ErrorMsg.TREESORT_ERR);
+ getParser().reportError(WARNING, msg);
+ }
+ // Put the result tree (a DOM adapter) on the stack
+ _select.translate(classGen, methodGen);
+ // Get back the DOM and iterator (not just iterator!!!)
+ _type.translateTo(classGen, methodGen, Type.NodeSet);
}
else {
- if (_select == null) {
- Mode.compileGetChildren(classGen, methodGen, current);
+ il.append(methodGen.loadDOM());
+
+ // compute node iterator for applyTemplates
+ if (sortObjects.size() > 0) {
+ Sort.translateSortIterator(classGen, methodGen,
+ _select, sortObjects);
}
else {
- _select.translate(classGen, methodGen);
+ if (_select == null)
+ Mode.compileGetChildren(classGen, methodGen, current);
+ else
+ _select.translate(classGen, methodGen);
}
}
+
if (_select != null) {
_select.startResetIterator(classGen, methodGen);
}
1.2 +5 -1
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/BooleanExpr.java
Index: BooleanExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/BooleanExpr.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BooleanExpr.java 2001/04/17 18:51:21 1.1
+++ BooleanExpr.java 2001/08/27 09:07:19 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: BooleanExpr.java,v 1.1 2001/04/17 18:51:21 sboag Exp $
+ * @(#)$Id: BooleanExpr.java,v 1.2 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -85,6 +85,10 @@
public String toString() {
return _value ? "true()" : "false()";
+ }
+
+ public boolean getValue() {
+ return _value;
}
public boolean contextDependent() {
1.5 +2 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CallTemplate.java
Index: CallTemplate.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CallTemplate.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CallTemplate.java 2001/07/10 17:45:05 1.4
+++ CallTemplate.java 2001/08/27 09:07:19 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: CallTemplate.java,v 1.4 2001/07/10 17:45:05 morten Exp $
+ * @(#)$Id: CallTemplate.java,v 1.5 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -116,7 +116,6 @@
final Stylesheet stylesheet = classGen.getStylesheet();
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS_SIG = classGen.getDOMClassSig();
// Push a new parameter frame
if (stylesheet.hasLocalParams() || hasContents()) {
@@ -144,7 +143,7 @@
il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
methodName,
"("
- + DOM_CLASS_SIG
+ + DOM_INTF_SIG
+ NODE_ITERATOR_SIG
+ TRANSLET_OUTPUT_SIG
+ NODE_SIG
1.5 +4 -4
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java
Index: CastExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CastExpr.java 2001/07/10 17:45:06 1.4
+++ CastExpr.java 2001/08/27 09:07:19 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: CastExpr.java,v 1.4 2001/07/10 17:45:06 morten Exp $
+ * @(#)$Id: CastExpr.java,v 1.5 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -199,13 +199,13 @@
if (_typeTest) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
- final int idx = cpg.addMethodref(DOM_CLASS, "getType","(I)I");
+ final int idx = cpg.addInterfaceMethodref(DOM_INTF,
+ "getType", "(I)I");
il.append(new SIPUSH((short)((Step)_left).getNodeType()));
il.append(methodGen.loadDOM());
il.append(methodGen.loadContextNode());
- il.append(new INVOKEVIRTUAL(idx));
+ il.append(new INVOKEINTERFACE(idx, 2));
_falseList.add(il.append(new IF_ICMPNE(null)));
}
else {
1.12 +10 -1
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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Constants.java 2001/08/15 19:25:43 1.11
+++ Constants.java 2001/08/27 09:07:19 1.12
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Constants.java,v 1.11 2001/08/15 19:25:43 tmiller Exp $
+ * @(#)$Id: Constants.java,v 1.12 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -453,6 +453,15 @@
= "getVariable";
public static final String GET_VARIABLE_SIG
= "(I)" + OBJECT_SIG;
+
+ public static final String STRIP_SPACE
+ = "stripSpace";
+ public static final String STRIP_SPACE_INTF
+ = "org/apache/xalan/xsltc/StripFilter";
+ public static final String STRIP_SPACE_SIG
+ = "Lorg/apache/xalan/xsltc/StripFilter;";
+ public static final String STRIP_SPACE_PARAMS
+ = "(Lorg/apache/xalan/xsltc/DOM;II)Z";
public static final String GET_NODE_VALUE_ITERATOR
= "getNodeValueIterator";
1.6 +8 -9
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Copy.java
Index: Copy.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Copy.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Copy.java 2001/08/08 12:30:03 1.5
+++ Copy.java 2001/08/27 09:07:19 1.6
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Copy.java,v 1.5 2001/08/08 12:30:03 morten Exp $
+ * @(#)$Id: Copy.java,v 1.6 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -104,7 +104,6 @@
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
final LocalVariableGen name =
methodGen.addLocalVariable2("name",
@@ -119,13 +118,13 @@
il.append(methodGen.loadDOM());
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadHandler());
- final int shallowCopy = cpg.addMethodref(DOM_CLASS,
- "shallowCopy",
- "("
- + NODE_SIG
- + TRANSLET_OUTPUT_SIG
- + ")" + STRING_SIG);
- il.append(new INVOKEVIRTUAL(shallowCopy));
+ final int cpy = cpg.addInterfaceMethodref(DOM_INTF,
+ "shallowCopy",
+ "("
+ + NODE_SIG
+ + TRANSLET_OUTPUT_SIG
+ + ")" + STRING_SIG);
+ il.append(new INVOKEINTERFACE(cpy, 3));
il.append(DUP);
il.append(new ASTORE(name.getIndex()));
final BranchHandle ifBlock1 = il.append(new IFNULL(null));
1.7 +14 -45
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CopyOf.java 2001/08/03 15:23:21 1.6
+++ CopyOf.java 2001/08/27 09:07:19 1.7
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: CopyOf.java,v 1.6 2001/08/03 15:23:21 morten Exp $
+ * @(#)$Id: CopyOf.java,v 1.7 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -108,9 +108,14 @@
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
final Type tselect = _select.getType();
+ final String CPY1_SIG = "("+NODE_ITERATOR_SIG+TRANSLET_OUTPUT_SIG+")V";
+ final int cpy1 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY1_SIG);
+
+ final String CPY2_SIG = "("+NODE_SIG+TRANSLET_OUTPUT_SIG+")V";
+ final int cpy2 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY2_SIG);
+
if (tselect instanceof NodeSetType) {
il.append(methodGen.loadDOM());
@@ -120,56 +125,20 @@
// call copy from the DOM 'library'
il.append(methodGen.loadHandler());
- final int copy = cpg.addMethodref(DOM_CLASS,
- "copy",
- "("
- + NODE_ITERATOR_SIG
- + TRANSLET_OUTPUT_SIG
- + ")V");
- il.append(new INVOKEVIRTUAL(copy));
+ il.append(new INVOKEINTERFACE(cpy1, 3));
}
else if (tselect instanceof NodeType) {
il.append(methodGen.loadDOM());
_select.translate(classGen, methodGen);
il.append(methodGen.loadHandler());
- final int copy = cpg.addMethodref(DOM_CLASS,
- "copy",
- "("
- + NODE_SIG
- + TRANSLET_OUTPUT_SIG
- + ")V");
- il.append(new INVOKEVIRTUAL(copy));
+ il.append(new INVOKEINTERFACE(cpy2, 3));
}
else if (tselect instanceof ResultTreeType) {
- if (tselect.implementedAsMethod()) {
- final ResultTreeType type = (ResultTreeType) tselect;
- final String DOM_CLASS_SIG = classGen.getDOMClassSig();
- final int index = cpg.addMethodref(classGen.getClassName(),
- type.getMethodName(),
- "("
- + DOM_CLASS_SIG
- + TRANSLET_OUTPUT_SIG
- + ")V");
- il.append(classGen.loadTranslet());
- il.append(methodGen.loadDOM());
- il.append(methodGen.loadHandler());
- il.append(new INVOKEVIRTUAL(index));
- }
- else {
- _select.translate(classGen, methodGen);
- // We want the whole result tree here, not just from the
- // current node and onwards!!!!!!!
- //il.append(methodGen.loadCurrentNode());
- il.append(ICONST_1);
- il.append(methodGen.loadHandler());
- final int copy = cpg.addMethodref(DOM_CLASS,
- "copy",
- "("
- + NODE_SIG
- + TRANSLET_OUTPUT_SIG
- + ")V");
- il.append(new INVOKEVIRTUAL(copy));
- }
+ _select.translate(classGen, methodGen);
+ // We want the whole tree, so we start with the root node
+ il.append(ICONST_1);
+ il.append(methodGen.loadHandler());
+ il.append(new INVOKEINTERFACE(cpy2, 3));
}
else if (tselect instanceof ReferenceType) {
_select.translate(classGen, methodGen);
1.8 +7 -9
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DocumentCall.java 2001/08/07 14:46:23 1.7
+++ DocumentCall.java 2001/08/27 09:07:19 1.8
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DocumentCall.java,v 1.7 2001/08/07 14:46:23 morten Exp $
+ * @(#)$Id: DocumentCall.java,v 1.8 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -140,21 +140,19 @@
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
final int domField = cpg.addFieldref(classGen.getClassName(),
DOM_FIELD,
- classGen.getDOMClassSig());
-
+ DOM_INTF_SIG);
final String docParamList =
- "("+OBJECT_SIG+STRING_SIG+TRANSLET_SIG+MULTI_DOM_SIG+")"+
+ "("+OBJECT_SIG+STRING_SIG+TRANSLET_SIG+DOM_INTF_SIG+")"+
NODE_ITERATOR_SIG;
final int docIdx = cpg.addMethodref(LOAD_DOCUMENT_CLASS,
"document", docParamList);
- final int uriIdx = cpg.addMethodref(DOM_CLASS,
- "getNodeURI",
- "(I)"+STRING_SIG);
+ final int uriIdx = cpg.addInterfaceMethodref(DOM_INTF,
+ "getDocumentURI",
+ "(I)"+STRING_SIG);
final int nextIdx = cpg.addInterfaceMethodref(NODE_ITERATOR,
NEXT, NEXT_SIG);
@@ -173,7 +171,7 @@
else {
il.append(methodGen.loadContextNode());
}
- il.append(new INVOKEVIRTUAL(uriIdx));
+ il.append(new INVOKEINTERFACE(uriIdx, 2));
// Feck the rest of the parameters on the stack
il.append(classGen.loadTranslet());
1.4 +1 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterExpr.java
Index: FilterExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterExpr.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FilterExpr.java 2001/06/17 12:23:28 1.3
+++ FilterExpr.java 2001/08/27 09:07:19 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: FilterExpr.java,v 1.3 2001/06/17 12:23:28 curcuru Exp $
+ * @(#)$Id: FilterExpr.java,v 1.4 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -148,7 +148,6 @@
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
if (_predicates.size() == 0) {
translate(classGen, methodGen);
1.2 +5 -6
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilteredAbsoluteLocationPath.java
Index: FilteredAbsoluteLocationPath.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilteredAbsoluteLocationPath.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FilteredAbsoluteLocationPath.java 2001/08/15 19:24:40 1.1
+++ FilteredAbsoluteLocationPath.java 2001/08/27 09:07:19 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: FilteredAbsoluteLocationPath.java,v 1.1 2001/08/15 19:24:40
tmiller Exp $
+ * @(#)$Id: FilteredAbsoluteLocationPath.java,v 1.2 2001/08/27 09:07:19
morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -126,12 +126,11 @@
il.append(new INVOKESPECIAL(initDFI));
}
else {
- final String DOM_CLASS = classGen.getDOMClass();
+ final int git = cpg.addInterfaceMethodref(DOM_INTF,
+ "getIterator",
+ "()"+NODE_ITERATOR_SIG);
il.append(methodGen.loadDOM());
- il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- "getIterator",
- "()"
- +NODE_ITERATOR_SIG)));
+ il.append(new INVOKEINTERFACE(git, 1));
}
}
}
1.9 +44 -17
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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ForEach.java 2001/08/07 10:38:44 1.8
+++ ForEach.java 2001/08/27 09:07:19 1.9
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ForEach.java,v 1.8 2001/08/07 10:38:44 morten Exp $
+ * @(#)$Id: ForEach.java,v 1.9 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -79,7 +79,7 @@
final class ForEach extends Instruction {
private Expression _select;
- private Type _tselect;
+ private Type _type;
public void display(int indent) {
indent(indent);
@@ -102,18 +102,19 @@
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
- _tselect = _select.typeCheck(stable);
+ _type = _select.typeCheck(stable);
- if (_tselect instanceof ReferenceType || _tselect instanceof NodeType) {
+ if (_type instanceof ReferenceType || _type instanceof NodeType) {
_select = new CastExpr(_select, Type.NodeSet);
typeCheckContents(stable);
return Type.Void;
}
- else if (_tselect instanceof NodeSetType) {
+ if (_type instanceof NodeSetType||_type instanceof ResultTreeType) {
typeCheckContents(stable);
return Type.Void;
- }
- throw new TypeCheckError(this);
+ }
+ String msg = "Unsupported type for <xsl:for-each select='"+_type+"'/>";
+ throw new TypeCheckError(new ErrorMsg(msg));
}
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
@@ -133,22 +134,43 @@
sortObjects.addElement(child);
}
}
+
+ if ((_type != null) && (_type instanceof ResultTreeType)) {
+ // Store existing DOM on stack - must be restored when loop is done
+ il.append(methodGen.loadDOM());
+
+ // <xsl:sort> cannot be applied to a result tree - issue warning
+ if (sortObjects.size() > 0) {
+ ErrorMsg msg = new ErrorMsg(ErrorMsg.TREESORT_ERR);
+ getParser().reportError(WARNING, msg);
+ }
- // Compile node iterator
- if (sortObjects.size() > 0) {
- Sort.translateSortIterator(classGen, methodGen,
- _select, sortObjects);
+ // Put the result tree on the stack (DOM)
+ _select.translate(classGen, methodGen);
+ // Get an iterator for the whole DOM - excluding the root node
+ _type.translateTo(classGen, methodGen, Type.NodeSet);
+ // Store the result tree as the default DOM
+ il.append(SWAP);
+ il.append(methodGen.storeDOM());
}
else {
- _select.translate(classGen, methodGen);
- if (_select instanceof Step) {
- ((Step)_select).orderIterator(classGen, methodGen);
+ // Compile node iterator
+ if (sortObjects.size() > 0) {
+ Sort.translateSortIterator(classGen, methodGen,
+ _select, sortObjects);
}
- }
- if (!(_tselect instanceof ReferenceType)) {
- _select.startResetIterator(classGen, methodGen);
+ else {
+ _select.translate(classGen, methodGen);
+ if (_select instanceof Step) {
+ ((Step)_select).orderIterator(classGen, methodGen);
+ }
+ }
+ if (!(_type instanceof ReferenceType)) {
+ _select.startResetIterator(classGen, methodGen);
+ }
}
+
// Overwrite current iterator
il.append(methodGen.storeIterator());
@@ -165,6 +187,11 @@
il.append(DUP);
il.append(methodGen.storeCurrentNode());
il.append(new IFNE(loop));
+
+ // Restore current DOM (if result tree was used instead for this loop)
+ if ((_type != null) && (_type instanceof ResultTreeType)) {
+ il.append(methodGen.storeDOM());
+ }
// Restore current node and current iterator from the stack
il.append(methodGen.storeIterator());
1.8 +86 -60
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java
Index: FunctionCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FunctionCall.java 2001/07/10 17:45:13 1.7
+++ FunctionCall.java 2001/08/27 09:07:19 1.8
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: FunctionCall.java,v 1.7 2001/07/10 17:45:13 morten Exp $
+ * @(#)$Id: FunctionCall.java,v 1.8 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -74,10 +74,11 @@
import org.apache.xalan.xsltc.compiler.util.*;
class FunctionCall extends Expression {
- private final static Vector EmptyArgs = new Vector(0);
- private final static String ExtPrefix = TRANSLET_URI + "/java";
+
+ private final static Vector _emptyArgs = new Vector(0);
+ private final static String _javaExtPrefix = TRANSLET_URI + "/java";
- private final QName _fname;
+ private QName _fname;
private final Vector _arguments;
private String _className;
@@ -88,10 +89,10 @@
private boolean unresolvedExternal;
// Legal conversions between internal and Java types.
- private static final MultiHashtable InternalToJava = new
MultiHashtable();
+ private static final MultiHashtable _internal2Java = new
MultiHashtable();
// Legal conversions between Java and internal types.
- private static final Hashtable JavaToInternal = new Hashtable();
+ private static final Hashtable _java2Internal = new Hashtable();
/**
* Defines 2 conversion tables:
@@ -106,53 +107,54 @@
final Class nodeListClass = Class.forName("org.w3c.dom.NodeList");
// Possible conversions between internal and Java types
- InternalToJava.put(Type.Boolean, Boolean.TYPE);
-
- InternalToJava.put(Type.Int, Character.TYPE);
- InternalToJava.put(Type.Int, Byte.TYPE);
- InternalToJava.put(Type.Int, Short.TYPE);
- InternalToJava.put(Type.Int, Integer.TYPE);
- InternalToJava.put(Type.Int, Long.TYPE);
- InternalToJava.put(Type.Int, Float.TYPE);
- InternalToJava.put(Type.Int, Double.TYPE);
-
- InternalToJava.put(Type.Real, Character.TYPE);
- InternalToJava.put(Type.Real, Byte.TYPE);
- InternalToJava.put(Type.Real, Short.TYPE);
- InternalToJava.put(Type.Real, Integer.TYPE);
- InternalToJava.put(Type.Real, Long.TYPE);
- InternalToJava.put(Type.Real, Float.TYPE);
- InternalToJava.put(Type.Real, Double.TYPE);
-
- InternalToJava.put(Type.String, stringClass);
+ _internal2Java.put(Type.Boolean, Boolean.TYPE);
- InternalToJava.put(Type.Node, nodeClass);
- InternalToJava.put(Type.Node, nodeListClass);
+ _internal2Java.put(Type.Int, Character.TYPE);
+ _internal2Java.put(Type.Int, Byte.TYPE);
+ _internal2Java.put(Type.Int, Short.TYPE);
+ _internal2Java.put(Type.Int, Integer.TYPE);
+ _internal2Java.put(Type.Int, Long.TYPE);
+ _internal2Java.put(Type.Int, Float.TYPE);
+ _internal2Java.put(Type.Int, Double.TYPE);
+
+ _internal2Java.put(Type.Real, Character.TYPE);
+ _internal2Java.put(Type.Real, Byte.TYPE);
+ _internal2Java.put(Type.Real, Short.TYPE);
+ _internal2Java.put(Type.Real, Integer.TYPE);
+ _internal2Java.put(Type.Real, Long.TYPE);
+ _internal2Java.put(Type.Real, Float.TYPE);
+ _internal2Java.put(Type.Real, Double.TYPE);
+
+ _internal2Java.put(Type.String, stringClass);
+
+ _internal2Java.put(Type.Node, nodeClass);
+ _internal2Java.put(Type.Node, nodeListClass);
+
+ _internal2Java.put(Type.NodeSet, Integer.TYPE);
+ _internal2Java.put(Type.NodeSet, nodeClass);
+ _internal2Java.put(Type.NodeSet, nodeListClass);
- InternalToJava.put(Type.NodeSet, nodeClass);
- InternalToJava.put(Type.NodeSet, nodeListClass);
+ _internal2Java.put(Type.ResultTree, nodeClass);
+ _internal2Java.put(Type.ResultTree, nodeListClass);
- InternalToJava.put(Type.ResultTree, nodeClass);
- InternalToJava.put(Type.ResultTree, nodeListClass);
-
// Possible conversions between Java and internal types
- JavaToInternal.put(Boolean.TYPE, Type.Boolean);
+ _java2Internal.put(Boolean.TYPE, Type.Boolean);
- JavaToInternal.put(Character.TYPE, Type.Real);
- JavaToInternal.put(Byte.TYPE, Type.Real);
- JavaToInternal.put(Short.TYPE, Type.Real);
- JavaToInternal.put(Integer.TYPE, Type.Real);
- JavaToInternal.put(Long.TYPE, Type.Real);
- JavaToInternal.put(Float.TYPE, Type.Real);
- JavaToInternal.put(Double.TYPE, Type.Real);
+ _java2Internal.put(Character.TYPE, Type.Real);
+ _java2Internal.put(Byte.TYPE, Type.Real);
+ _java2Internal.put(Short.TYPE, Type.Real);
+ _java2Internal.put(Integer.TYPE, Type.Real);
+ _java2Internal.put(Long.TYPE, Type.Real);
+ _java2Internal.put(Float.TYPE, Type.Real);
+ _java2Internal.put(Double.TYPE, Type.Real);
- JavaToInternal.put(stringClass, Type.String);
+ _java2Internal.put(stringClass, Type.String);
// Conversions from org.w3c.dom.Node/NodeList are not supported
}
catch (ClassNotFoundException e) {
System.err.println(e);
- System.exit(1);
+ //System.exit(1);
}
}
@@ -162,7 +164,7 @@
}
public FunctionCall(QName fname) {
- this(fname, EmptyArgs);
+ this(fname, _emptyArgs);
}
public String getName() {
@@ -186,7 +188,9 @@
* type checking is different for standard and external (Java) functions.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
+
final String namespace = _fname.getNamespace();
+ final String local = _fname.getLocalPart();
// XPath functions have no namespace
if (isStandard()) {
@@ -194,11 +198,16 @@
}
// Handle extension functions (they all have a namespace)
else {
- final int len = ExtPrefix.length();
- if (namespace.length() >= len &&
- namespace.substring(0, len).equals(ExtPrefix)) {
+ final int len = _javaExtPrefix.length();
+ if (namespace.equals(_javaExtPrefix)) {
+ final int pos = local.indexOf('.');
+ _className = local.substring(0, pos);
+ _fname = new QName(namespace, null, local.substring(pos+1));
+ }
+ else if (namespace.length() >= len &&
+ namespace.substring(0, len).equals(_javaExtPrefix)) {
_className = namespace.substring(len + 1);
- }
+ }
else {
/*
* Warn user if external function could not be resolved.
@@ -261,7 +270,7 @@
*/
public Type typeCheckExternal(SymbolTable stable) throws TypeCheckError {
final Vector methods = findMethods();
-
+
if (methods == null) {
// Method not found in this class
throw new TypeCheckError(ErrorMsg.METUNDEF_ERR,
@@ -272,30 +281,47 @@
final int nArgs = _arguments.size();
final Vector argsType = typeCheckArgs(stable);
+ // Try all methods with the same name as this function
for (int j, i = 0; i < nMethods; i++) {
+
+ // Check if all paramteters to this method can be converted
final Method method = (Method)methods.elementAt(i);
final Class[] paramTypes = method.getParameterTypes();
- // Can all arg types be converted ?
for (j = 0; j < nArgs; j++) {
- if (!InternalToJava.maps((Type)argsType.elementAt(j),
- paramTypes[j])) {
- break;
- }
+ // Convert from internal (translet) type to external (Java) type
+ final Type intType = (Type)argsType.elementAt(j);
+ final Class extType = paramTypes[j];
+ if (!_internal2Java.maps(intType, extType)) break;
}
if (j == nArgs) {
- final Class retType = method.getReturnType();
- _type = retType.getName().equals("void")
- ? Type.Void
- : (Type)JavaToInternal.get(retType);
-
- // Return type legal ?
+ // Check if the return type can be converted
+ final Class extType = method.getReturnType();
+ if (extType.getName().equals("void"))
+ _type = Type.Void;
+ else
+ _type = (Type)_java2Internal.get(extType);
+ // Use this method if all parameters & return type match
if (_type != null) {
_chosenMethod = method;
return _type;
}
}
}
+
+ StringBuffer buf = new StringBuffer("Attempted to call method ");
+ buf.append(_className);
+ buf.append('.');
+ buf.append(_fname.getLocalPart());
+ buf.append('(');
+ for (int a=0; a<nArgs; a++) {
+ final Type intType = (Type)argsType.elementAt(a);
+ buf.append(intType.toString());
+ if (a < (nArgs-1)) buf.append(", ");
+ }
+ buf.append(");");
+ getParser().reportError(Constants.WARNING,new ErrorMsg(buf.toString()));
+
throw new TypeCheckError(ErrorMsg.CANNOTCV_ERR,
_fname.getLocalPart(),
_className);
@@ -453,7 +479,7 @@
Vector result = null;
final String namespace = _fname.getNamespace();
- if (namespace.startsWith(ExtPrefix)) {
+ if (namespace.startsWith(_javaExtPrefix)) {
final int nArgs = _arguments.size();
try {
final Class clazz = Class.forName(_className);
1.8 +9 -9
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Key.java 2001/08/17 13:17:44 1.7
+++ Key.java 2001/08/27 09:07:19 1.8
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Key.java,v 1.7 2001/08/17 13:17:44 morten Exp $
+ * @(#)$Id: Key.java,v 1.8 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -164,9 +164,9 @@
final InstructionList il = methodGen.getInstructionList();
// DOM.getNodeValue(nodeIndex) => String
- final int getNodeValue = cpg.addMethodref(classGen.getDOMClass(),
- "getNodeValue",
- "(I)"+STRING_SIG);
+ final int getNodeValue = cpg.addInterfaceMethodref(DOM_INTF,
+ "getNodeValue",
+ "(I)"+STRING_SIG);
// 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
@@ -199,7 +199,7 @@
// Now get the node value and feck it on the parameter stack
il.append(methodGen.loadDOM());
il.append(methodGen.loadCurrentNode());
- il.append(new INVOKEVIRTUAL(getNodeValue));
+ 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));
@@ -234,9 +234,9 @@
"("+STRING_SIG+"I"+OBJECT_SIG+")V");
// DOM.getAxisIterator(root) => NodeIterator
- final int git = cpg.addMethodref(classGen.getDOMClass(),
- "getAxisIterator",
- "(I)"+NODE_ITERATOR_SIG);
+ final int git = cpg.addInterfaceMethodref(DOM_INTF,
+ "getAxisIterator",
+ "(I)"+NODE_ITERATOR_SIG);
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadIterator());
@@ -244,7 +244,7 @@
// Get an iterator for all nodes in the DOM
il.append(methodGen.loadDOM());
il.append(new PUSH(cpg,Axis.DESCENDANT));
- il.append(new INVOKEVIRTUAL(git));
+ il.append(new INVOKEINTERFACE(git, 2));
// Reset the iterator to start with the root node
il.append(methodGen.loadCurrentNode());
1.6 +5 -5
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- KeyCall.java 2001/08/17 13:17:44 1.5
+++ KeyCall.java 2001/08/27 09:07:19 1.6
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: KeyCall.java,v 1.5 2001/08/17 13:17:44 morten Exp $
+ * @(#)$Id: KeyCall.java,v 1.6 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -181,9 +181,9 @@
final InstructionList il = methodGen.getInstructionList();
// Returns the string value for a node in the DOM
- final int getNodeValue = cpg.addMethodref(classGen.getDOMClass(),
- "getNodeValue",
- "(I)Ljava/lang/String;");
+ final int getNodeValue = cpg.addInterfaceMethodref(DOM_INTF,
+ "getNodeValue",
+ "(I)"+STRING_SIG);
// Returns the KeyIndex object of a given name
final int getKeyIndex = cpg.addMethodref(TRANSLET_CLASS,
@@ -264,7 +264,7 @@
il.append(DUP);
il.append(methodGen.loadDOM());
il.append(methodGen.loadCurrentNode());
- il.append(new INVOKEVIRTUAL(getNodeValue));
+ il.append(new INVOKEINTERFACE(getNodeValue, 2));
if (_name == null)
il.append(new INVOKEVIRTUAL(lookupId));
else
1.2 +11 -10
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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LastCall.java 2001/04/17 18:51:34 1.1
+++ LastCall.java 2001/08/27 09:07:19 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: LastCall.java,v 1.1 2001/04/17 18:51:34 sboag Exp $
+ * @(#)$Id: LastCall.java,v 1.2 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -86,7 +86,6 @@
final InstructionList il = methodGen.getInstructionList();
final ConstantPoolGen cpg = classGen.getConstantPool();
- final String DOM_CLASS = classGen.getDOMClass();
boolean lastChild = false;
@@ -118,9 +117,9 @@
final int last = cpg.addInterfaceMethodref(NODE_ITERATOR,
"getLast",
"()I");
- final int children = cpg.addMethodref(DOM_CLASS,
- "getTypedAxisIterator",
- "(II)"+NODE_ITERATOR_SIG);
+ final int git = cpg.addInterfaceMethodref(DOM_INTF,
+ "getTypedAxisIterator",
+ "(II)"+NODE_ITERATOR_SIG);
final int start = cpg.addInterfaceMethodref(NODE_ITERATOR,
"setStartNode",
"(I)"+
@@ -129,7 +128,7 @@
il.append(methodGen.loadDOM());
il.append(new PUSH(cpg, Axis.CHILD));
il.append(new PUSH(cpg, DOM.ELEMENT));
- il.append(new INVOKEVIRTUAL(children));
+ il.append(new INVOKEINTERFACE(git, 3));
il.append(methodGen.loadCurrentNode());
il.append(new INVOKEINTERFACE(start, 2));
}
@@ -140,14 +139,16 @@
}
else {
// public int getTypedPosition(NodeIterator iterator, int type) {
- final int last = cpg.addMethodref(DOM_CLASS,
- "getTypedLast",
- "("+NODE_ITERATOR_SIG+"II)I");
+ final int last = cpg.addInterfaceMethodref(DOM_INTF,
+ "getTypedLast",
+ "("+
+ NODE_ITERATOR_SIG+
+ "II)I");
il.append(methodGen.loadDOM());
il.append(methodGen.loadIterator());
il.append(new PUSH(cpg, _type));
il.append(methodGen.loadCurrentNode());
- il.append(new INVOKEVIRTUAL(last));
+ il.append(new INVOKEINTERFACE(last, 4));
}
}
1.2 +5 -5
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LocalNameCall.java
Index: LocalNameCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LocalNameCall.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LocalNameCall.java 2001/04/17 18:51:35 1.1
+++ LocalNameCall.java 2001/08/27 09:07:19 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: LocalNameCall.java,v 1.1 2001/04/17 18:51:35 sboag Exp $
+ * @(#)$Id: LocalNameCall.java,v 1.2 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -94,16 +94,16 @@
final InstructionList il = methodGen.getInstructionList();
// Returns the name of a node in the DOM
- final int getNodeName = cpg.addMethodref(classGen.getDOMClass(),
- "getNodeName",
- "(I)Ljava/lang/String;");
+ final int getNodeName = cpg.addInterfaceMethodref(DOM_INTF,
+ "getNodeName",
+ "(I)"+STRING_SIG);
final int getLocalName = cpg.addMethodref(BASIS_LIBRARY_CLASS,
"getLocalName",
"(Ljava/lang/String;)"+
"Ljava/lang/String;");
super.translate(classGen, methodGen);
- il.append(new INVOKEVIRTUAL(getNodeName));
+ il.append(new INVOKEINTERFACE(getNodeName, 2));
il.append(new INVOKESTATIC(getLocalName));
}
}
1.5 +32 -31
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Mode.java 2001/08/16 12:17:15 1.4
+++ Mode.java 2001/08/27 09:07:19 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Mode.java,v 1.4 2001/08/16 12:17:15 morten Exp $
+ * @(#)$Id: Mode.java,v 1.5 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -314,8 +314,6 @@
ClassGenerator classGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = new InstructionList();
- final String DOM_CLASS_SIG = classGen.getDOMClassSig();
-
String methodName = template.getName().toString();
methodName = methodName.replace('.', '$');
methodName = methodName.replace('-', '$');
@@ -324,7 +322,7 @@
new NamedMethodGenerator(ACC_PUBLIC,
de.fub.bytecode.generic.Type.VOID,
new de.fub.bytecode.generic.Type[] {
- Util.getJCRefType(DOM_CLASS_SIG),
+ Util.getJCRefType(DOM_INTF_SIG),
Util.getJCRefType(NODE_ITERATOR_SIG),
Util.getJCRefType(TRANSLET_OUTPUT_SIG),
de.fub.bytecode.generic.Type.INT
@@ -404,12 +402,12 @@
int node) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
+ final int git = cpg.addInterfaceMethodref(DOM_INTF,
+ GET_CHILDREN,
+ GET_CHILDREN_SIG);
il.append(methodGen.loadDOM());
il.append(new ILOAD(node));
- il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- GET_CHILDREN,
- GET_CHILDREN_SIG)));
+ il.append(new INVOKEINTERFACE(git, 2));
}
/**
@@ -420,11 +418,10 @@
InstructionHandle next) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = new InstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
final String applyTemplatesSig = classGen.getApplyTemplatesSig();
- final int getChildren = cpg.addMethodref(DOM_CLASS,
- GET_CHILDREN,
- GET_CHILDREN_SIG);
+ final int git = cpg.addInterfaceMethodref(DOM_INTF,
+ GET_CHILDREN,
+ GET_CHILDREN_SIG);
final int applyTemplates = cpg.addMethodref(getClassName(),
functionName(),
applyTemplatesSig);
@@ -433,7 +430,7 @@
il.append(methodGen.loadDOM());
il.append(new ILOAD(_currentIndex));
- il.append(new INVOKEVIRTUAL(getChildren));
+ il.append(new INVOKEINTERFACE(git, 2));
il.append(methodGen.loadHandler());
il.append(new INVOKEVIRTUAL(applyTemplates));
il.append(new GOTO_W(next));
@@ -449,13 +446,14 @@
InstructionHandle next) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = new InstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
+
+ final int chars = cpg.addInterfaceMethodref(DOM_INTF,
+ CHARACTERS,
+ CHARACTERS_SIG);
il.append(methodGen.loadDOM());
il.append(new ILOAD(_currentIndex));
il.append(methodGen.loadHandler());
- il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- CHARACTERS,
- CHARACTERS_SIG)));
+ il.append(new INVOKEINTERFACE(chars, 3));
il.append(new GOTO_W(next));
return il;
}
@@ -468,7 +466,6 @@
InstructionHandle defaultTarget) {
final XSLTC xsltc = classGen.getParser().getXSLTC();
final ConstantPoolGen cpg = classGen.getConstantPool();
- final String DOM_CLASS = classGen.getDOMClass();
// Append switch() statement - namespace test dispatch loop
final Vector namespaces = xsltc.getNamespaceIndex();
@@ -511,11 +508,12 @@
if (!compiled) return(null);
// Append first code in applyTemplates() - get type of current node
+ final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
+ "getNamespaceType",
+ "(I)I");
il.append(methodGen.loadDOM());
il.append(new ILOAD(_currentIndex));
- il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- "getNamespaceType",
- "(I)I")));
+ il.append(new INVOKEINTERFACE(getNS, 2));
il.append(new SWITCH(types, targets, defaultTarget));
return(il);
}
@@ -551,12 +549,11 @@
final XSLTC xsltc = classGen.getParser().getXSLTC();
final ConstantPoolGen cpg = classGen.getConstantPool();
final Vector names = xsltc.getNamesIndex();
- final String DOM_CLASS = classGen.getDOMClass();
// (*) Create the applyTemplates() method
final de.fub.bytecode.generic.Type[] argTypes =
new de.fub.bytecode.generic.Type[3];
- argTypes[0] = Util.getJCRefType(classGen.getDOMClassSig());
+ argTypes[0] = Util.getJCRefType(DOM_INTF_SIG);
argTypes[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
argTypes[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
@@ -651,13 +648,16 @@
// (*) If there is a match on node() we need to replace ihElem
// and ihText (default behaviour for elements & text).
if (_nodeTestSeq != null) {
- double nodePrio = -0.5;// _nodeTestSeq.getPriority();
+ double nodePrio = -0.5; //_nodeTestSeq.getPriority();
int nodePos = _nodeTestSeq.getPosition();
- if ((elemTest == null) ||
- (elemTest.getPriority() == Double.NaN) ||
- (elemTest.getPriority() < nodePrio) ||
- ((elemTest.getPriority() == nodePrio) &&
- (elemTest.getPosition() < nodePos))) {
+ double elemPrio = (0 - Double.MAX_VALUE);
+ int elemPos = Integer.MIN_VALUE;
+ if (elemTest != null) {
+ elemPrio = elemTest.getPriority();
+ elemPos = elemTest.getPosition();
+ }
+ if ((elemPrio == Double.NaN) || (elemPrio < nodePrio) ||
+ ((elemPrio == nodePrio) && (elemPos < nodePos))) {
ihElem = _nodeTestSeq.compile(classGen, methodGen, ihLoop);
ihText = ihElem;
}
@@ -757,10 +757,11 @@
if (ilKey != null) body.insert(ilKey);
// Append first code in applyTemplates() - get type of current node
+ final int getType = cpg.addInterfaceMethodref(DOM_INTF,
+ "getType", "(I)I");
body.append(methodGen.loadDOM());
body.append(new ILOAD(_currentIndex));
- body.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- "getType", "(I)I")));
+ body.append(new INVOKEINTERFACE(getType, 2));
// Append switch() statement - main dispatch loop in applyTemplates()
InstructionHandle disp = body.append(new SWITCH(types, targets,
ihLoop));
1.2 +5 -5
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NameCall.java
Index: NameCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NameCall.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NameCall.java 2001/04/17 18:51:37 1.1
+++ NameCall.java 2001/08/27 09:07:19 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NameCall.java,v 1.1 2001/04/17 18:51:37 sboag Exp $
+ * @(#)$Id: NameCall.java,v 1.2 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -92,10 +92,10 @@
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
+ final int getName = cpg.addInterfaceMethodref(DOM_INTF,
+ GET_NODE_NAME,
+ GET_NODE_NAME_SIG);
super.translate(classGen, methodGen);
- il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- GET_NODE_NAME,
- GET_NODE_NAME_SIG)));
+ il.append(new INVOKEINTERFACE(getName, 2));
}
}
1.2 +5 -5
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NamespaceUriCall.java
Index: NamespaceUriCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NamespaceUriCall.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NamespaceUriCall.java 2001/04/17 18:51:38 1.1
+++ NamespaceUriCall.java 2001/08/27 09:07:19 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NamespaceUriCall.java,v 1.1 2001/04/17 18:51:38 sboag Exp $
+ * @(#)$Id: NamespaceUriCall.java,v 1.2 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -94,10 +94,10 @@
final InstructionList il = methodGen.getInstructionList();
// Returns the string value for a node in the DOM
- final int getNamespace = cpg.addMethodref(classGen.getDOMClass(),
- "getNamespaceName",
- "(I)Ljava/lang/String;");
+ final int getNamespace = cpg.addInterfaceMethodref(DOM_INTF,
+ "getNamespaceName",
+ "(I)"+STRING_SIG);
super.translate(classGen, methodGen);
- il.append(new INVOKEVIRTUAL(getNamespace));
+ il.append(new INVOKEINTERFACE(getNamespace, 2));
}
}
1.4 +2 -5
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Number.java
Index: Number.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Number.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Number.java 2001/06/06 10:45:16 1.3
+++ Number.java 2001/08/27 09:07:19 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Number.java,v 1.3 2001/06/06 10:45:16 morten Exp $
+ * @(#)$Id: Number.java,v 1.4 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -307,8 +307,6 @@
ConstantPoolGen cpg = nodeCounterGen.getConstantPool();
final String className = matchGen.getClassName();
- final String DOM_SIG = nodeCounterGen.getDOMClassSig();
- final String DOM_CLASS = nodeCounterGen.getDOMClass();
LocalVariableGen local;
int field;
@@ -337,13 +335,12 @@
// Get NodeCounter._document and store locally
local = matchGen.addLocalVariable("document",
- Util.getJCRefType(DOM_SIG),
+ Util.getJCRefType(DOM_INTF_SIG),
null, null);
field = cpg.addFieldref(className, "_document", DOM_INTF_SIG);
il.append(ALOAD_0); // 'this' pointer on stack
il.append(new GETFIELD(field));
// Make sure we have the correct DOM type on the stack!!!
- il.append(new CHECKCAST(cpg.addClass(DOM_CLASS)));
il.append(new ASTORE(local.getIndex()));
matchGen.setDomIndex(local.getIndex());
}
1.10 +3 -8
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Param.java
Index: Param.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Param.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Param.java 2001/07/31 09:11:51 1.9
+++ Param.java 2001/08/27 09:07:19 1.10
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Param.java,v 1.9 2001/07/31 09:11:51 morten Exp $
+ * @(#)$Id: Param.java,v 1.10 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -141,15 +141,12 @@
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (_select != null) {
- final Type tselect = _select.typeCheck(stable);
- if (tselect instanceof ReferenceType == false) {
- _select = new CastExpr(_select, Type.Reference);
- }
+ _type = _select.typeCheck(stable);
}
else {
typeCheckContents(stable);
+ _type = Type.ResultTree;
}
- _type = Type.Reference;
return Type.Void;
}
@@ -217,8 +214,6 @@
}
else {
String signature = _type.toSignature();
- if (signature.equals(DOM_IMPL_SIG))
- signature = classGen.getDOMClassSig();
classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
cpg.addUtf8(signature),
null, cpg.getConstantPool()));
1.5 +3 -7
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParameterRef.java
Index: ParameterRef.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParameterRef.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ParameterRef.java 2001/08/23 14:06:22 1.4
+++ ParameterRef.java 2001/08/27 09:07:19 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ParameterRef.java,v 1.4 2001/08/23 14:06:22 tmiller Exp $
+ * @(#)$Id: ParameterRef.java,v 1.5 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -79,7 +79,6 @@
return "parameter-ref(" + _variable.getName() + ')';
}
-
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
@@ -105,17 +104,14 @@
}
else {
final String className = classGen.getClassName();
- String signature = parType.toSignature();
- if (signature.equals(DOM_IMPL_SIG))
- signature = classGen.getDOMClassSig();
-
il.append(classGen.loadTranslet());
// If inside a predicate we must cast this ref down
if (classGen.isExternal()) {
il.append(new CHECKCAST(cpg.addClass(className)));
}
il.append(new GETFIELD(cpg.addFieldref(className,
- parName, signature)));
+ parName,
+ parType.toSignature())));
}
}
}
1.4 +6 -7
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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ParentLocationPath.java 2001/06/17 12:23:30 1.3
+++ ParentLocationPath.java 2001/08/27 09:07:19 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ParentLocationPath.java,v 1.3 2001/06/17 12:23:30 curcuru Exp $
+ * @(#)$Id: ParentLocationPath.java,v 1.4 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -161,15 +161,14 @@
* and prevent returning a single node multiple times.
*/
if (_orderNodes) {
- final String DOM_CLASS = classGen.getDOMClass();
- final int order = cpg.addMethodref(DOM_CLASS,
- "orderNodes",
- "("+NODE_ITERATOR_SIG+"I)"+
- NODE_ITERATOR_SIG);
+ final String params = "("+NODE_ITERATOR_SIG+"I)"+NODE_ITERATOR_SIG;
+ final int order = cpg.addInterfaceMethodref(DOM_INTF,
+ "orderNodes",
+ params);
il.append(methodGen.loadDOM());
il.append(SWAP);
il.append(methodGen.loadContextNode());
- il.append(new INVOKEVIRTUAL(order));
+ il.append(new INVOKEINTERFACE(order, 3));
}
}
}
1.2 +5 -5
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentPattern.java
Index: ParentPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentPattern.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ParentPattern.java 2001/04/17 18:51:42 1.1
+++ ParentPattern.java 2001/08/27 09:07:19 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ParentPattern.java,v 1.1 2001/04/17 18:51:42 sboag Exp $
+ * @(#)$Id: ParentPattern.java,v 1.2 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -102,7 +102,6 @@
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
final LocalVariableGen local =
methodGen.addLocalVariable2("ppt",
Util.getJCRefType(NODE_SIG),
@@ -132,9 +131,10 @@
_right.translate(classGen, methodGen);
}
- il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- GET_PARENT,
- GET_PARENT_SIG)));
+ final int getParent = cpg.addInterfaceMethodref(DOM_INTF,
+ GET_PARENT,
+ GET_PARENT_SIG);
+ il.append(new INVOKEINTERFACE(getParent, 2));
final SyntaxTreeNode p = getParent();
if ((p == null) ||
1.2 +6 -6
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/PositionCall.java
Index: PositionCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/PositionCall.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PositionCall.java 2001/04/17 18:51:43 1.1
+++ PositionCall.java 2001/08/27 09:07:19 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: PositionCall.java,v 1.1 2001/04/17 18:51:43 sboag Exp $
+ * @(#)$Id: PositionCall.java,v 1.2 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -111,16 +111,16 @@
}
else {
final ConstantPoolGen cpg = classGen.getConstantPool();
- final String DOM_CLASS = classGen.getDOMClass();
// public int getTypedPosition(NodeIterator iterator, int type) {
- final int pos = cpg.addMethodref(DOM_CLASS,
- "getTypedPosition",
- "("+NODE_ITERATOR_SIG+"II)I");
+ final String params = "("+NODE_ITERATOR_SIG+"II)I";
+ final int pos = cpg.addInterfaceMethodref(DOM_INTF,
+ "getTypedPosition",
+ params);
il.append(methodGen.loadDOM());
il.append(methodGen.loadIterator());
il.append(new PUSH(cpg, _type));
il.append(methodGen.loadCurrentNode());
- il.append(new INVOKEVIRTUAL(pos));
+ il.append(new INVOKEINTERFACE(pos, 4));
}
}
}
1.10 +12 -4
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java
Index: Predicate.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Predicate.java 2001/08/01 11:52:58 1.9
+++ Predicate.java 2001/08/27 09:07:19 1.10
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Predicate.java,v 1.9 2001/08/01 11:52:58 morten Exp $
+ * @(#)$Id: Predicate.java,v 1.10 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -243,7 +243,6 @@
final InstructionList il = new InstructionList();
final ConstantPoolGen cpg = filterGen.getConstantPool();
- final String DOM_SIG = classGen.getDOMClassSig();
testGen = new TestGenerator(ACC_PUBLIC | ACC_FINAL,
de.fub.bytecode.generic.Type.BOOLEAN,
@@ -267,13 +266,13 @@
// Store the dom in a local variable
local = testGen.addLocalVariable("document",
- Util.getJCRefType(DOM_SIG),
+ Util.getJCRefType(DOM_INTF_SIG),
null, null);
final String className = classGen.getClassName();
il.append(filterGen.loadTranslet());
il.append(new CHECKCAST(cpg.addClass(className)));
il.append(new GETFIELD(cpg.addFieldref(className,
- DOM_FIELD, DOM_SIG)));
+ DOM_FIELD, DOM_INTF_SIG)));
il.append(new ASTORE(local.getIndex()));
// Store the dom index in the test generator
@@ -291,6 +290,15 @@
filterGen.addMethod(testGen.getMethod());
getXSLTC().dumpClass(filterGen.getJavaClass());
+ }
+
+ /**
+ * Returns true if the predicate is a test for the existance of an
+ * element or attribute. All we have to do is to get the first node
+ * from the step, check if it is there, and then return true/false.
+ */
+ public boolean isBooleanTest() {
+ return (_exp instanceof BooleanExpr);
}
/**
1.7 +2 -1
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/RelationalExpr.java
Index: RelationalExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/RelationalExpr.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RelationalExpr.java 2001/08/23 14:30:10 1.6
+++ RelationalExpr.java 2001/08/27 09:07:19 1.7
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: RelationalExpr.java,v 1.6 2001/08/23 14:30:10 tmiller Exp $
+ * @(#)$Id: RelationalExpr.java,v 1.7 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -110,6 +110,7 @@
_right = new CastExpr(_right, Type.Real);
_left = new CastExpr(_left, Type.Real);
}
+
// If one is of reference type, then convert the other too
if (hasReferenceArgs()) {
if (tleft instanceof ReferenceType) {
1.6 +1 -9
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Sort.java
Index: Sort.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Sort.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Sort.java 2001/08/17 13:17:44 1.5
+++ Sort.java 2001/08/27 09:07:19 1.6
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Sort.java,v 1.5 2001/08/17 13:17:44 morten Exp $
+ * @(#)$Id: Sort.java,v 1.6 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -410,7 +410,6 @@
ConstantPoolGen cpg,
String className) {
final InstructionList il = new InstructionList();
- final String DOM_CLASS = sortRecord.getDOMClass();
// String NodeSortRecord.extractValueFromDOM(dom,node,level);
final CompareGenerator extractMethod =
@@ -431,18 +430,11 @@
},
"extractValueFromDOM", className, il, cpg);
- // String DOM.getNodeValue(int node);
- final int getNodeValue = cpg.addMethodref(DOM_CLASS, "getNodeValue",
- "(I)" + STRING_SIG);
// Values needed for the switch statement
final int levels = sortObjects.size();
final int match[] = new int[levels];
final InstructionHandle target[] = new InstructionHandle[levels];
InstructionHandle tblswitch = null;
-
- il.append(ALOAD_1); // DOM arg
- il.append(new CHECKCAST(cpg.addClass(DOM_CLASS)));
- il.append(ASTORE_1);
// Compile switch statement only if the key has multiple levels
if (levels > 1) {
1.9 +34 -30
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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Step.java 2001/08/03 15:23:21 1.8
+++ Step.java 2001/08/27 09:07:19 1.9
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Step.java,v 1.8 2001/08/03 15:23:21 morten Exp $
+ * @(#)$Id: Step.java,v 1.9 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -203,7 +203,6 @@
* have type node-set.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
-
_hadPredicates = hasPredicates();
if (isAbbreviatedDot()) {
@@ -244,7 +243,6 @@
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
if (hasPredicates()) {
translatePredicates(classGen, methodGen);
@@ -253,17 +251,24 @@
// If it is an attribute but not '@*' or '@attr' with a parent
if ((_axis == Axis.ATTRIBUTE) &&
(_nodeType != NodeTest.ATTRIBUTE) && (!hasParent())) {
- final int gattr = cpg.addMethodref(DOM_CLASS,
- "getAttributeNode",
- "(II)I");
- il.append(methodGen.loadDOM());
- il.append(new PUSH(cpg, _nodeType));
- il.append(methodGen.loadContextNode());
- il.append(new INVOKEVIRTUAL(gattr));
-
+ int node = cpg.addInterfaceMethodref(DOM_INTF,
+ "getAttributeNode",
+ "(II)I");
+ int iter = cpg.addInterfaceMethodref(DOM_INTF,
+ "getTypedAxisIterator",
+ "(II)"+NODE_ITERATOR_SIG);
+ if (_type instanceof NodeType) {
+ il.append(methodGen.loadDOM());
+ il.append(new PUSH(cpg, _nodeType));
+ il.append(methodGen.loadContextNode());
+ il.append(new INVOKEINTERFACE(node, 3));
+ }
// If it is the case '@attr[P_1]...[P_k]'
- if (_type instanceof NodeSetType) {
- Type.Node.translateTo(classGen, methodGen, _type);
+ else if (_type instanceof NodeSetType) {
+ il.append(methodGen.loadDOM());
+ il.append(new PUSH(cpg, Axis.ATTRIBUTE));
+ il.append(new PUSH(cpg, _nodeType));
+ il.append(new INVOKEINTERFACE(iter, 3));
}
return;
}
@@ -280,12 +285,12 @@
_axis = Axis.ATTRIBUTE;
case NodeTest.ANODE:
// DOM.getAxisIterator(int axis);
- final int it = cpg.addMethodref(DOM_CLASS,
- "getAxisIterator",
- "(I)"+NODE_ITERATOR_SIG);
+ int git = cpg.addInterfaceMethodref(DOM_INTF,
+ "getAxisIterator",
+ "(I)"+NODE_ITERATOR_SIG);
il.append(methodGen.loadDOM());
il.append(new PUSH(cpg, _axis));
- il.append(new INVOKEVIRTUAL(it));
+ il.append(new INVOKEINTERFACE(git, 2));
break;
default:
final XSLTC xsltc = getParser().getXSLTC();
@@ -306,25 +311,25 @@
namespace = name.substring(0,star-1);
final int nsType = xsltc.registerNamespace(namespace);
- final int ns = cpg.addMethodref(DOM_CLASS,
+ final int ns = cpg.addInterfaceMethodref(DOM_INTF,
"getNamespaceAxisIterator",
"(II)"+NODE_ITERATOR_SIG);
il.append(methodGen.loadDOM());
il.append(new PUSH(cpg, _axis));
il.append(new PUSH(cpg, nsType));
- il.append(new INVOKEVIRTUAL(ns));
+ il.append(new INVOKEINTERFACE(ns, 3));
break;
}
case NodeTest.ELEMENT:
// DOM.getTypedAxisIterator(int axis, int type);
- final int ty = cpg.addMethodref(DOM_CLASS,
+ final int ty = cpg.addInterfaceMethodref(DOM_INTF,
"getTypedAxisIterator",
"(II)"+NODE_ITERATOR_SIG);
// Get the typed iterator we're after
il.append(methodGen.loadDOM());
il.append(new PUSH(cpg, _axis));
il.append(new PUSH(cpg, _nodeType));
- il.append(new INVOKEVIRTUAL(ty));
+ il.append(new INVOKEINTERFACE(ty, 3));
// Now, for reverse iterators we may need to re-arrange the
// node ordering (ancestor-type iterators).
@@ -348,7 +353,6 @@
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
if (_predicates.size() == 0) {
translate(classGen, methodGen);
@@ -384,20 +388,20 @@
path.translate(classGen, methodGen);
}
predicate.translate(classGen, methodGen);
- final int iter = cpg.addMethodref(DOM_CLASS,
- GET_NODE_VALUE_ITERATOR,
- GET_NODE_VALUE_ITERATOR_SIG);
- il.append(new INVOKEVIRTUAL(iter));
+ int iter = cpg.addInterfaceMethodref(DOM_INTF,
+ GET_NODE_VALUE_ITERATOR,
+ GET_NODE_VALUE_ITERATOR_SIG);
+ il.append(new INVOKEINTERFACE(iter, 4));
}
// Handle '//*[n]' expression
else if (predicate.isNthDescendant()) {
il.append(methodGen.loadDOM());
il.append(methodGen.loadContextNode());
predicate.translate(classGen, methodGen);
- final int nth = cpg.addMethodref(DOM_CLASS,
- "getNthDescendant",
- "(II)"+NODE_ITERATOR_SIG);
- il.append(new INVOKEVIRTUAL(nth));
+ int iter = cpg.addInterfaceMethodref(DOM_INTF,
+ "getNthDescendant",
+ "(II)"+NODE_ITERATOR_SIG);
+ il.append(new INVOKEINTERFACE(iter, 3));
}
// Handle 'elem[n]' expression
else if (predicate.isNthPositionFilter()) {
1.4 +9 -10
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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StepPattern.java 2001/07/10 17:45:25 1.3
+++ StepPattern.java 2001/08/27 09:07:19 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: StepPattern.java,v 1.3 2001/07/10 17:45:25 morten Exp $
+ * @(#)$Id: StepPattern.java,v 1.4 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -204,13 +204,13 @@
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
// context node is on the stack
+ final int getType = cpg.addInterfaceMethodref(DOM_INTF,
+ "getType", "(I)I");
il.append(methodGen.loadDOM());
il.append(SWAP);
- il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- "getType", "(I)I")));
+ il.append(new INVOKEINTERFACE(getType, 2));
il.append(new PUSH(cpg, _nodeType));
// Need to allow for long jumps here - don't know if 100% correct
@@ -299,9 +299,8 @@
// Get the parent of the matching node
il.append(methodGen.loadDOM());
il.append(new ILOAD(match.getIndex()));
- final String DOM_CLASS = classGen.getDOMClass();
- index = cpg.addMethodref(DOM_CLASS, GET_PARENT, GET_PARENT_SIG);
- il.append(new INVOKEVIRTUAL(index));
+ index = cpg.addInterfaceMethodref(DOM_INTF, GET_PARENT, GET_PARENT_SIG);
+ il.append(new INVOKEINTERFACE(index, 2));
// Start the iterator with the parent
il.append(methodGen.setStartNode());
@@ -337,7 +336,6 @@
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
int iteratorIndex = 0;
BranchHandle ifBlock = null;
@@ -389,8 +387,9 @@
// Get the parent of the node on the stack
il.append(methodGen.loadDOM());
il.append(new ILOAD(node.getIndex()));
- int index = cpg.addMethodref(DOM_CLASS, GET_PARENT, GET_PARENT_SIG);
- il.append(new INVOKEVIRTUAL(index));
+ int index = cpg.addInterfaceMethodref(DOM_INTF,
+ GET_PARENT, GET_PARENT_SIG);
+ il.append(new INVOKEINTERFACE(index, 2));
// Initialize the iterator with the parent
il.append(new ALOAD(iter.getIndex()));
1.16 +17 -25
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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Stylesheet.java 2001/07/31 10:04:51 1.15
+++ Stylesheet.java 2001/08/27 09:07:19 1.16
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Stylesheet.java,v 1.15 2001/07/31 10:04:51 morten Exp $
+ * @(#)$Id: Stylesheet.java,v 1.16 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -88,8 +88,8 @@
import org.apache.xalan.xsltc.DOM;
public final class Stylesheet extends SyntaxTreeNode {
- private String _version;
+ private String _version;
private QName _name;
private String _systemId;
private Stylesheet _parentStylesheet;
@@ -396,12 +396,10 @@
}
private void addDOMField(ClassGenerator classGen) {
- final FieldGen fgen =
- new FieldGen(ACC_PUBLIC,
- Util.getJCRefType(classGen.getDOMClassSig()),
- DOM_FIELD,
- classGen.getConstantPool());
-
+ final FieldGen fgen = new FieldGen(ACC_PUBLIC,
+ Util.getJCRefType(DOM_INTF_SIG),
+ DOM_FIELD,
+ classGen.getConstantPool());
classGen.addField(fgen.getField());
}
@@ -544,9 +542,8 @@
final ConstantPoolGen cpg = classGen.getConstantPool();
- // The signature of this method depends on the type of DOM we're using
final de.fub.bytecode.generic.Type[] argTypes = {
- Util.getJCRefType(classGen.getDOMClassSig()),
+ Util.getJCRefType(DOM_INTF_SIG),
Util.getJCRefType(NODE_ITERATOR_SIG),
Util.getJCRefType(TRANSLET_OUTPUT_SIG)
};
@@ -572,9 +569,9 @@
de.fub.bytecode.generic.Type.INT,
il.getEnd(), null);
- final int setFilter = cpg.addMethodref(classGen.getDOMClass(),
+ final int setFilter = cpg.addInterfaceMethodref(DOM_INTF,
"setFilter",
-
"(Lorg/apache/xalan/xsltc/dom/StripWhitespaceFilter;)V");
+ "(Lorg/apache/xalan/xsltc/StripFilter;)V");
il.append(new PUSH(cpg, DOM.ROOTNODE));
il.append(new ISTORE(current.getIndex()));
@@ -621,11 +618,10 @@
Whitespace.translateRules(whitespaceRules,classGen);
}
- if (classGen.containsMethod("stripSpace",
- "(Lorg/apache/xalan/xsltc/DOM;II)Z") !=
null) {
+ if (classGen.containsMethod(STRIP_SPACE, STRIP_SPACE_PARAMS) != null) {
il.append(toplevel.loadDOM());
il.append(classGen.loadTranslet());
- il.append(new INVOKEVIRTUAL(setFilter));
+ il.append(new INVOKEINTERFACE(setFilter, 2));
}
il.append(RETURN);
@@ -638,8 +634,7 @@
classGen.addMethod(toplevel.getMethod());
- return("("+ classGen.getDOMClassSig()+
- NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + ")V");
+ return("("+DOM_INTF_SIG+NODE_ITERATOR_SIG+TRANSLET_OUTPUT_SIG+")V");
}
@@ -651,7 +646,6 @@
final ConstantPoolGen cpg = classGen.getConstantPool();
- // The signature of this method depends on the type of DOM we're using
final de.fub.bytecode.generic.Type[] argTypes = {
Util.getJCRefType(DOM_INTF_SIG),
Util.getJCRefType(NODE_ITERATOR_SIG),
@@ -674,7 +668,7 @@
final int domField = cpg.addFieldref(getClassName(),
DOM_FIELD,
- classGen.getDOMClassSig());
+ DOM_INTF_SIG);
buildKeys.addException("org.apache.xalan.xsltc.TransletException");
@@ -752,7 +746,7 @@
applyTemplatesSig);
final int domField = cpg.addFieldref(getClassName(),
DOM_FIELD,
- classGen.getDOMClassSig());
+ DOM_INTF_SIG);
// push translet for PUTFIELD
il.append(classGen.loadTranslet());
@@ -767,16 +761,14 @@
il.append(transf.loadDOM());
il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
"makeDOMAdapter",
- "("
- + DOM_INTF_SIG
- + ")"
- + DOM_ADAPTER_SIG)));
+ "("+DOM_INTF_SIG+")"+
+ DOM_ADAPTER_SIG)));
// DOMAdapter is on the stack
if (isMultiDOM()) {
final int init = cpg.addMethodref(MULTI_DOM_CLASS,
"<init>",
- "(" + DOM_ADAPTER_SIG + ")V");
+ "("+DOM_INTF_SIG+")V");
il.append(new INVOKESPECIAL(init));
// MultiDOM is on the stack
}
1.12 +13 -5
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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SyntaxTreeNode.java 2001/07/31 09:11:51 1.11
+++ SyntaxTreeNode.java 2001/08/27 09:07:19 1.12
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: SyntaxTreeNode.java,v 1.11 2001/07/31 09:11:51 morten Exp $
+ * @(#)$Id: SyntaxTreeNode.java,v 1.12 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -408,6 +408,7 @@
index = cpg.addMethodref(DOM_IMPL,
"getOutputDomBuilder",
"()" + TRANSLET_OUTPUT_SIG);
+
il.append(new INVOKEVIRTUAL(index));
il.append(DUP);
il.append(methodGen.storeHandler());
@@ -425,28 +426,35 @@
// Check if we need to wrap the DOMImpl object in a DOMAdapter object
if (!DOM_CLASS.equals(DOM_IMPL_CLASS)) {
// new org.apache.xalan.xsltc.dom.DOMAdapter(DOMImpl,String[]);
- index = cpg.addMethodref(DOM_ADAPTER_CLASS, "<init>",
+ index = cpg.addMethodref(DOM_ADAPTER_CLASS,
+ "<init>",
"("+DOM_IMPL_SIG+
"["+STRING_SIG+
"["+STRING_SIG+")V");
il.append(new NEW(cpg.addClass(DOM_ADAPTER_CLASS)));
il.append(new DUP_X1());
il.append(SWAP);
+ // Give the DOM adapter an empty type mapping to start with.
+ // Type mapping is expensive and will only be done when casting
+ // a result tree fragment to a node-set.
il.append(new ICONST(0));
il.append(new ANEWARRAY(cpg.addClass(STRING)));
il.append(DUP);
il.append(new INVOKESPECIAL(index)); // leave DOMAdapter on stack
- // Must we wrap the DOMAdapter object in an MultiDOM object?
- if (DOM_CLASS.equals("org.apache.xalan.xsltc.dom.MultiDOM")) {
+ // Must we wrap the DOMAdapter object in a MultiDOM object?
+ /* Not needed with new design using DOM interface instead of
+ referencing DOM classes directly
+ if (DOM_CLASS.equals(MULTI_DOM_CLASS)) {
// new org.apache.xalan.xsltc.dom.MultiDOM(DOMAdapter);
index = cpg.addMethodref(MULTI_DOM_CLASS, "<init>",
- "("+DOM_ADAPTER_SIG+")V");
+ "("+DOM_INTF_SIG+")V");
il.append(new NEW(cpg.addClass(MULTI_DOM_CLASS)));
il.append(new DUP_X1());
il.append(SWAP);
il.append(new INVOKESPECIAL(index)); // leave MultiDOM on stack
}
+ */
}
// Restore old handler base from stack
1.10 +2 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java
Index: Template.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Template.java 2001/07/10 17:45:28 1.9
+++ Template.java 2001/08/27 09:07:19 1.10
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Template.java,v 1.9 2001/07/10 17:45:28 morten Exp $
+ * @(#)$Id: Template.java,v 1.10 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -311,7 +311,6 @@
if (_disabled) return;
// bug fix #4433133, add a call to named template from applyTemplates
String className = classGen.getClassName();
- final String DOM_CLASS_SIG = classGen.getDOMClassSig();
if (_compiled && isNamed()){
@@ -327,7 +326,7 @@
il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
methodName,
"("
- + DOM_CLASS_SIG
+ + DOM_INTF_SIG
+ NODE_ITERATOR_SIG
+ TRANSLET_OUTPUT_SIG
+ "I)V")));
1.4 +10 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TestSeq.java
Index: TestSeq.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TestSeq.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestSeq.java 2001/08/16 12:17:15 1.3
+++ TestSeq.java 2001/08/27 09:07:19 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TestSeq.java,v 1.3 2001/08/16 12:17:15 morten Exp $
+ * @(#)$Id: TestSeq.java,v 1.4 2001/08/27 09:07:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -105,7 +105,7 @@
* other templates that make up the test sequence.
*/
public double getPriority() {
- double prio = Double.MIN_VALUE;
+ double prio = (0 - Double.MAX_VALUE);
final int count = _patterns.size();
for (int i = 0; i < count; i++) {
final Pattern pattern = (Pattern)_patterns.elementAt(i);
@@ -113,6 +113,10 @@
final double tp = template.getPriority();
if (tp > prio) prio = tp;
}
+ if (_default != null) {
+ final double tp = _default.getPriority();
+ if (tp > prio) prio = tp;
+ }
return prio;
}
@@ -127,6 +131,10 @@
final Pattern pattern = (Pattern)_patterns.elementAt(i);
final Template template = pattern.getTemplate();
final int tp = template.getPosition();
+ if (tp > pos) pos = tp;
+ }
+ if (_default != null) {
+ final int tp = _default.getPosition();
if (tp > pos) pos = tp;
}
return pos;
1.5 +2 -1
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Text.java
Index: Text.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Text.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Text.java 2001/06/06 10:45:33 1.4
+++ Text.java 2001/08/27 09:07:20 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Text.java,v 1.4 2001/06/06 10:45:33 morten Exp $
+ * @(#)$Id: Text.java,v 1.5 2001/08/27 09:07:20 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -103,6 +103,7 @@
if ((str != null) && (str.equals("yes"))) {
_escaping = false;
}
+ parseChildren(parser);
}
public boolean contextDependent() {
1.4 +56 -19
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TransletOutput.java
Index: TransletOutput.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TransletOutput.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TransletOutput.java 2001/06/06 10:45:35 1.3
+++ TransletOutput.java 2001/08/27 09:07:20 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TransletOutput.java,v 1.3 2001/06/06 10:45:35 morten Exp $
+ * @(#)$Id: TransletOutput.java,v 1.4 2001/08/27 09:07:20 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -56,8 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * @author Jacek Ambroziak
- * @author Santiago Pericas-Geertsen
+ * @author Morten Jorgensen
*
*/
@@ -68,27 +67,55 @@
import org.apache.xalan.xsltc.compiler.util.*;
final class TransletOutput extends Instruction {
- private Expression _port; // port treated as AVT (7.1.3)
-
+
+ private Expression _filename;
+
+ private final static String MISSING_FILE_ATTR =
+ "The <xsltc:output> element requires a 'file' attribute.";
+
+ /**
+ * Displays the contents of this <xsltc:output> element.
+ */
public void display(int indent) {
indent(indent);
- Util.println("TransletOutput " + _port);
+ Util.println("TransletOutput: " + _filename);
}
+ /**
+ * Parse the contents of this <xsltc:output> element. The only attribute
+ * we recognise is the 'file' attribute that contains teh output
filename.
+ */
public void parseContents(Parser parser) {
- _port = AttributeValue.create(this, getAttribute("port"), parser);
+ // Get the output filename from the 'file' attribute
+ String filename = getAttribute("file");
+
+ // Verify that the filename is in fact set
+ if ((filename == null) || (filename.equals(EMPTYSTRING))) {
+ final ErrorMsg msg = new ErrorMsg(MISSING_FILE_ATTR);
+ parser.reportError(Constants.ERROR, msg);
+ }
+
+ // Save filename as an attribute value template
+ _filename = AttributeValue.create(this, filename, parser);
parseChildren(parser);
}
+ /**
+ * Type checks the 'file' attribute (must be able to convert it to a
str).
+ */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
- final Type ptype = _port.typeCheck(stable);
- if (ptype instanceof RealType == false) {
- _port = new CastExpr(_port, Type.Real);
+ final Type type = _filename.typeCheck(stable);
+ if (type instanceof StringType == false) {
+ _filename = new CastExpr(_filename, Type.String);
}
typeCheckContents(stable);
return Type.Void;
}
+ /**
+ * Compile code that opens the give file for output, dumps the contents
of
+ * the element to the file, then closes the file.
+ */
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
@@ -96,20 +123,30 @@
// Save the current output handler on the stack
il.append(methodGen.loadHandler());
- // retrieve selected output port
- final int getOutputHandler =
- cpg.addMethodref(TRANSLET_CLASS,
- "getOutputHandler",
- "(D)" + TRANSLET_OUTPUT_SIG);
+ final int open = cpg.addMethodref(TRANSLET_CLASS,
+ "openOutputHandler",
+ "("+STRING_SIG+")"+
+ TRANSLET_OUTPUT_SIG);
+
+ final int close = cpg.addMethodref(TRANSLET_CLASS,
+ "closeOutputHandler",
+ "("+TRANSLET_OUTPUT_SIG+")V");
+
+ // Create the new output handler (leave it on stack)
il.append(classGen.loadTranslet());
- _port.translate(classGen, methodGen);
- il.append(new INVOKEVIRTUAL(getOutputHandler));
+ _filename.translate(classGen, methodGen);
+ il.append(new INVOKEVIRTUAL(open));
- // overwrite current handler
+ // Overwrite current handler
il.append(methodGen.storeHandler());
- // translate contents with substituted handler
+ // Translate contents with substituted handler
translateContents(classGen, methodGen);
+
+ // Close the output handler (close file)
+ il.append(classGen.loadTranslet());
+ il.append(methodGen.storeHandler());
+ il.append(new INVOKEVIRTUAL(close));
// Restore old output handler from stack
il.append(methodGen.storeHandler());
1.5 +1 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ValueOf.java
Index: ValueOf.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ValueOf.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ValueOf.java 2001/06/11 12:53:02 1.4
+++ ValueOf.java 2001/08/27 09:07:20 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ValueOf.java,v 1.4 2001/06/11 12:53:02 morten Exp $
+ * @(#)$Id: ValueOf.java,v 1.5 2001/08/27 09:07:20 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -89,7 +89,6 @@
reportError(this, parser, ErrorMsg.NREQATTR_ERR, "select");
return;
}
-
final String str = getAttribute("disable-output-escaping");
if ((str != null) && (str.equals("yes"))) _escaping = false;
}
1.13 +5 -67
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java
Index: Variable.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Variable.java 2001/08/20 14:50:32 1.12
+++ Variable.java 2001/08/27 09:07:20 1.13
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Variable.java,v 1.12 2001/08/20 14:50:32 morten Exp $
+ * @(#)$Id: Variable.java,v 1.13 2001/08/27 09:07:20 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -80,24 +80,11 @@
// Index of this variable in the variable stack relative to base ptr
private int _stackIndex = -1;
- private boolean _escapes;
+ private boolean _escapes; // 'true' if the variable's value can change
- // If the variable is of result tree type, and this result tree
- // is implemented as a method, this is the name of the method.
- private String _methodName = null;
-
- /**
- * Returns the method name for this variable. Used if the value of the
- * variable is a result tree and a separate method is used to build it.
- * The method name is generate in typeCheck(), so this method should
never
- * be called before that.
- */
- public String getMethodName() {
- return _methodName;
- }
-
/**
- *
+ * This method returns 'true' if the variable value can change over time,
+ * such as with varibles inside a for-each loop.
*/
public void setEscapes() {
_escapes = true;
@@ -185,14 +172,7 @@
// Type check the element contents otherwise
else {
typeCheckContents(stable);
- // Compile into a method if variable value is not context dependant
- if (dependentContents() == false) {
- _methodName = "__rt_" + getXSLTC().nextVariableSerial();
- _type = new ResultTreeType(_methodName);
- }
- else {
- _type = Type.ResultTree;
- }
+ _type = Type.ResultTree;
}
// The return type is void as the variable element does not leave
@@ -202,40 +182,6 @@
}
/**
- * Compiles a method that generates the value of the variable
- */
- private void compileResultTreeMethod(ClassGenerator classGen) {
- final ConstantPoolGen cpg = classGen.getConstantPool();
- final InstructionList il = new InstructionList();
- final String DOM_CLASS_SIG = classGen.getDOMClassSig();
-
- final RtMethodGenerator methodGen =
- new RtMethodGenerator(ACC_PROTECTED,
- de.fub.bytecode.generic.Type.VOID,
- new de.fub.bytecode.generic.Type[] {
- Util.getJCRefType(DOM_CLASS_SIG),
- Util.getJCRefType(TRANSLET_OUTPUT_SIG)
- },
- new String[] {
- DOCUMENT_PNAME,
- TRANSLET_OUTPUT_PNAME
- },
- _methodName,
- classGen.getClassName(),
- il, cpg);
- methodGen.addException("org.apache.xalan.xsltc.TransletException");
-
- translateContents(classGen, methodGen);
- il.append(RETURN);
-
- methodGen.stripAttributes(true);
- methodGen.setMaxLocals();
- methodGen.setMaxStack();
- methodGen.removeNOPs();
- classGen.addMethod(methodGen.getMethod());
- }
-
- /**
* This method is part of a little trick that is needed to use local
* variables inside nested for-each loops. See the initializeVariables()
* method in the ForEach class for an explanation
@@ -302,12 +248,6 @@
if (_compiled) return;
_compiled = true;
- // If a result tree is implemented as method then compile and return
- if ((_select == null) && (_type != Type.ResultTree)) {
- compileResultTreeMethod(classGen);
- return;
- }
-
if (isLocal()) {
// Push args to call addVariable()
if (_escapes) {
@@ -343,8 +283,6 @@
}
else {
String signature = _type.toSignature();
- if (signature.equals(DOM_IMPL_SIG))
- signature = classGen.getDOMClassSig();
// Global variables are store in class fields
if (classGen.containsField(name) == null) {
1.6 +4 -19
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRef.java
Index: VariableRef.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRef.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- VariableRef.java 2001/08/20 14:50:32 1.5
+++ VariableRef.java 2001/08/27 09:07:20 1.6
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: VariableRef.java,v 1.5 2001/08/20 14:50:32 morten Exp $
+ * @(#)$Id: VariableRef.java,v 1.6 2001/08/27 09:07:20 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -80,19 +80,7 @@
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if ( (_variable.isLocal()) && (_escaped = isEscaped()) )
((Variable)_variable).setEscapes();
-
- // Attempt to get the cached variable type
- _type = _variable.getType();
-
- // If that does not work we must force a type-check (this is normally
- // only needed for globals in included/imported stylesheets
- if (_type == null) {
- _variable.typeCheck(stable);
- _type = _variable.getType();
- }
-
- // Return the type of the referenced variable
- return _type;
+ return super.typeCheck(stable);
}
private boolean isEscaped() {
@@ -142,17 +130,14 @@
}
else {
final String className = classGen.getClassName();
- String signature = varType.toSignature();
- if (signature.equals(DOM_IMPL_SIG))
- signature = classGen.getDOMClassSig();
il.append(classGen.loadTranslet());
-
// If inside a predicate we must cast this ref down
if (classGen.isExternal()) {
il.append(new CHECKCAST(cpg.addClass(className)));
}
il.append(new GETFIELD(cpg.addFieldref(className,
- varName, signature)));
+ varName,
+ varType.toSignature())));
}
}
}
1.5 +3 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Whitespace.java
Index: Whitespace.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Whitespace.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Whitespace.java 2001/06/06 10:45:41 1.4
+++ Whitespace.java 2001/08/27 09:07:20 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Whitespace.java,v 1.4 2001/06/06 10:45:41 morten Exp $
+ * @(#)$Id: Whitespace.java,v 1.5 2001/08/27 09:07:20 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -384,7 +384,7 @@
new String[] { "dom","node","type" },
"stripSpace",classGen.getClassName(),il,cpg);
-
classGen.addInterface("org/apache/xalan/xsltc/dom/StripWhitespaceFilter");
+ classGen.addInterface("org/apache/xalan/xsltc/StripFilter");
final int paramDom = stripSpace.getLocalIndex("dom");
final int paramCurrent = stripSpace.getLocalIndex("node");
@@ -487,7 +487,7 @@
new String[] { "dom","node","type" },
"stripSpace",classGen.getClassName(),il,cpg);
-
classGen.addInterface("org/apache/xalan/xsltc/dom/StripWhitespaceFilter");
+ classGen.addInterface("org/apache/xalan/xsltc/StripFilter");
if (defaultAction == STRIP_SPACE)
il.append(ICONST_1);
1.24 +6 -4
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.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- XSLTC.java 2001/08/02 16:01:51 1.23
+++ XSLTC.java 2001/08/27 09:07:20 1.24
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: XSLTC.java,v 1.23 2001/08/02 16:01:51 morten Exp $
+ * @(#)$Id: XSLTC.java,v 1.24 2001/08/27 09:07:20 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -103,7 +103,7 @@
private Stylesheet _stylesheet = null;
// Counters used by various classes to generate unique names.
- private int _variableSerial = 1;
+ // private int _variableSerial = 1;
private int _modeSerial = 1;
private int _stylesheetSerial = 1;
private int _stepPatternSerial = 1;
@@ -182,7 +182,7 @@
_namesIndex = new Vector(128);
_namespaceIndex = new Vector(32);
_parser.init();
- _variableSerial = 1;
+ //_variableSerial = 1;
_modeSerial = 1;
_stylesheetSerial = 1;
_stepPatternSerial = 1;
@@ -591,10 +591,12 @@
return code.intValue();
}
+ /*
public int nextVariableSerial() {
return _variableSerial++;
}
-
+ */
+
public int nextModeSerial() {
return _modeSerial++;
}
1.2 +2 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ClassGenerator.java
Index: ClassGenerator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ClassGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClassGenerator.java 2001/04/17 18:52:13 1.1
+++ ClassGenerator.java 2001/08/27 09:07:21 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ClassGenerator.java,v 1.1 2001/04/17 18:52:13 sboag Exp $
+ * @(#)$Id: ClassGenerator.java,v 1.2 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -113,7 +113,7 @@
_domClassSig = "Lorg/apache/xalan/xsltc/dom/DOMAdapter;";
}
_applyTemplatesSig = "("
- + _domClassSig
+ + Constants.DOM_INTF_SIG
+ Constants.NODE_ITERATOR_SIG
+ Constants.TRANSLET_OUTPUT_SIG
+ ")V";
1.4 +6 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMsg.java
Index: ErrorMsg.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMsg.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ErrorMsg.java 2001/07/19 18:48:31 1.3
+++ ErrorMsg.java 2001/08/27 09:07:21 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ErrorMsg.java,v 1.3 2001/07/19 18:48:31 morten Exp $
+ * @(#)$Id: ErrorMsg.java,v 1.4 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -99,6 +99,7 @@
public static final int ATTROUTS_ERR = 19;
public static final int ILL_ATTR_ERR = 20;
public static final int CIRCULAR_INC = 21;
+ public static final int TREESORT_ERR = 22;
static final String messages_d[] = {
"More than one stylesheet defined in the same file.",
@@ -122,7 +123,10 @@
"Illegal name ''{0}'' for processing instruction.",
"Attribute ''{0}'' outside of element.",
"Illegal attribute name ''{0}''.",
- "Circular import/include. Stylesheet ''{0}'' already loaded."
+ "Circular import/include. Stylesheet ''{0}'' already loaded.",
+ "Applying <xsl:sort> to a result tree is not supported (<xsl:sort> "+
+ "elements are ignored). You can, and should, sort the nodes when "+
+ "creating the result tree."
};
public ErrorMsg(int code) {
1.5 +7 -65
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MethodGenerator.java 2001/06/29 14:58:56 1.4
+++ MethodGenerator.java 2001/08/27 09:07:21 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: MethodGenerator.java,v 1.4 2001/06/29 14:58:56 morten Exp $
+ * @(#)$Id: MethodGenerator.java,v 1.5 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -89,6 +89,7 @@
private final Instruction _astoreIterator;
private final Instruction _aloadIterator;
private final Instruction _aloadDom;
+ private final Instruction _astoreDom;
private final Instruction _startElement;
private final Instruction _endElement;
@@ -114,6 +115,7 @@
_astoreIterator = new ASTORE(ITERATOR_INDEX);
_aloadIterator = new ALOAD(ITERATOR_INDEX);
_aloadDom = new ALOAD(DOM_INDEX);
+ _astoreDom = new ASTORE(DOM_INDEX);
final int startElement =
cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
@@ -187,72 +189,12 @@
super.removeLocalVariable(lvg);
}
- /**
- * Returns an instruction list that defines the map type subroutine.
- * This subroutine is added to a method only when needed.
- */
- /*
- private InstructionList compileMapTypeSub(ClassGenerator classGen) {
- final InstructionList il = new InstructionList();
- final ConstantPoolGen cpg = classGen.getConstantPool();
-
- final LocalVariableGen returnAddress =
- addLocalVariable2("returnAddress",
- de.fub.bytecode.generic.Type.OBJECT,
- il.getEnd());
- final LocalVariableGen node =
- addLocalVariable2("node",
- de.fub.bytecode.generic.Type.INT,
- il.getEnd());
- il.append(new ASTORE(returnAddress.getIndex()));
- il.append(new ISTORE(node.getIndex()));
- il.append(classGen.aloadTranslet());
- il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
- MAP_FIELD,
- MAP_FIELD_SIG)));
- il.append(classGen.aloadTranslet());
- il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
- TYPE_FIELD,
- TYPE_FIELD_SIG)));
- il.append(new ILOAD(node.getIndex()));
- il.append(InstructionConstants.SALOAD);
- il.append(InstructionConstants.SALOAD);
- il.append(new RET(returnAddress.getIndex()));
- //!!! until more sophisticated allocator
- //removeLocalVariable(returnAddress);
- //removeLocalVariable(node);
- return il;
- }
- */
-
- /**
- * Add a map type subroutine if needed. Must be called before
- * adding this method to a class.
- */
- /*
- public void addMapTypeSub() {
- if (_mapTypeSub != null) {
- getInstructionList().append(_mapTypeSub);
- }
- }
- */
-
- /**
- * Returns a JSR instruction that jumps to the map type subroutine.
- * This subroutine is compiled if needed but not added to the inst
- * stream until addMapTypeSub() is called.
- */
- /*
- public JSR getMapTypeSub(ClassGenerator classGen) {
- if (_mapTypeSub == null) {
- _mapTypeSub = compileMapTypeSub(classGen);
- }
- return new JSR(_mapTypeSub.getStart());
- }
- */
-
public Instruction loadDOM() {
return _aloadDom;
+ }
+
+ public Instruction storeDOM() {
+ return _astoreDom;
}
public Instruction storeHandler() {
1.6 +29 -12
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NodeSetType.java 2001/06/18 09:34:12 1.5
+++ NodeSetType.java 2001/08/27 09:07:21 1.6
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NodeSetType.java,v 1.5 2001/06/18 09:34:12 morten Exp $
+ * @(#)$Id: NodeSetType.java,v 1.6 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -211,22 +211,39 @@
Class clazz) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
-
+ final String className = clazz.getName();
+
il.append(methodGen.loadDOM());
- il.append(SWAP); // dom ref must be below node index
+ il.append(SWAP);
- final String className = clazz.getName();
if (className.equals("org.w3c.dom.Node")) {
- il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOM_CLASS,
- MAKE_NODE,
- MAKE_NODE_SIG2)));
+ int index = cpg.addInterfaceMethodref(DOM_INTF,
+ MAKE_NODE,
+ MAKE_NODE_SIG2);
+ il.append(new INVOKEINTERFACE(index, 2));
}
else if (className.equals("org.w3c.dom.NodeList")) {
- final int mkList = cpg.addMethodref(DOM_CLASS,
- MAKE_NODE_LIST,
- MAKE_NODE_LIST_SIG2);
- il.append(new INVOKEVIRTUAL(mkList));
+ int index = cpg.addInterfaceMethodref(DOM_INTF,
+ MAKE_NODE_LIST,
+ MAKE_NODE_LIST_SIG2);
+ il.append(new INVOKEINTERFACE(index, 2));
+ }
+ else if (className.equals("int")) {
+ int next = cpg.addInterfaceMethodref(NODE_ITERATOR,
+ "next", "()I");
+ int index = cpg.addInterfaceMethodref(DOM_INTF,
+ GET_NODE_VALUE,
+ "(I)"+STRING_SIG);
+ int str = cpg.addMethodref(BASIS_LIBRARY_CLASS,
+ STRING_TO_INT,
+ STRING_TO_INT_SIG);
+
+ // Get next node from the iterator
+ il.append(new INVOKEINTERFACE(next, 1));
+ // Get the node's string value (from the DOM)
+ il.append(new INVOKEINTERFACE(index, 2));
+ // Create a new Integer object from the string value
+ il.append(new INVOKESTATIC(str));
}
else {
classGen.getParser().internalError(); // undefined
1.4 +17 -17
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeType.java
Index: NodeType.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeType.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NodeType.java 2001/06/17 12:23:34 1.3
+++ NodeType.java 2001/08/27 09:07:21 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NodeType.java,v 1.3 2001/06/17 12:23:34 curcuru Exp $
+ * @(#)$Id: NodeType.java,v 1.4 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -142,17 +142,16 @@
StringType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
switch (_type) {
case NodeTest.ROOT:
case NodeTest.ELEMENT:
il.append(methodGen.loadDOM());
il.append(SWAP); // dom ref must be below node index
- int index = cpg.addMethodref(DOM_CLASS,
- GET_ELEMENT_VALUE,
- GET_ELEMENT_VALUE_SIG);
- il.append(new INVOKEVIRTUAL(index));
+ int index = cpg.addInterfaceMethodref(DOM_INTF,
+ GET_ELEMENT_VALUE,
+ GET_ELEMENT_VALUE_SIG);
+ il.append(new INVOKEINTERFACE(index, 2));
break;
case NodeTest.ANODE:
@@ -161,10 +160,10 @@
case NodeTest.PI:
il.append(methodGen.loadDOM());
il.append(SWAP); // dom ref must be below node index
- index = cpg.addMethodref(DOM_CLASS,
- GET_NODE_VALUE,
- GET_NODE_VALUE_SIG);
- il.append(new INVOKEVIRTUAL(index));
+ index = cpg.addInterfaceMethodref(DOM_INTF,
+ GET_NODE_VALUE,
+ GET_NODE_VALUE_SIG);
+ il.append(new INVOKEINTERFACE(index, 2));
break;
default:
@@ -264,21 +263,22 @@
Class clazz) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
il.append(methodGen.loadDOM());
il.append(SWAP); // dom ref must be below node index
String className = clazz.getName();
if (className.equals("org.w3c.dom.Node")) {
- int index = cpg.addMethodref(DOM_CLASS, MAKE_NODE, MAKE_NODE_SIG);
- il.append(new INVOKEVIRTUAL(index));
+ int index = cpg.addInterfaceMethodref(DOM_INTF,
+ MAKE_NODE,
+ MAKE_NODE_SIG);
+ il.append(new INVOKEINTERFACE(index, 2));
}
else if (className.equals("org.w3c.dom.NodeList")) {
- int index = cpg.addMethodref(DOM_CLASS,
- MAKE_NODE_LIST,
- MAKE_NODE_LIST_SIG);
- il.append(new INVOKEVIRTUAL(index));
+ int index = cpg.addInterfaceMethodref(DOM_INTF,
+ MAKE_NODE_LIST,
+ MAKE_NODE_LIST_SIG);
+ il.append(new INVOKEINTERFACE(index, 2));
}
else {
classGen.getParser().internalError();
1.5 +85 -33
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ResultTreeType.java 2001/06/28 15:36:35 1.4
+++ ResultTreeType.java 2001/08/27 09:07:21 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ResultTreeType.java,v 1.4 2001/06/28 15:36:35 morten Exp $
+ * @(#)$Id: ResultTreeType.java,v 1.5 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -64,6 +64,8 @@
package org.apache.xalan.xsltc.compiler.util;
+import org.apache.xalan.xsltc.DOM;
+
import org.apache.xalan.xsltc.compiler.util.Type;
import de.fub.bytecode.generic.*;
import org.apache.xalan.xsltc.compiler.Parser;
@@ -85,12 +87,11 @@
}
public boolean identicalTo(Type other) {
- return other instanceof ResultTreeType;
+ return (other instanceof ResultTreeType);
}
public String toSignature() {
- // caller will have to get the real signature from XSLTC in this case!
- return DOM_IMPL_SIG;
+ return DOM_INTF_SIG;
}
public de.fub.bytecode.generic.Type toJCType() {
@@ -110,7 +111,10 @@
* The translation to int is undefined since result trees
* are always converted to reals in arithmetic expressions.
*
- * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
+ * @param classGen A BCEL class generator
+ * @param methodGen A BCEL method generator
+ * @param type An instance of the type to translate the result tree to
+ * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator
methodGen,
Type type) {
@@ -138,7 +142,10 @@
* Expects an result tree on the stack and pushes a boolean.
* Translates a result tree to a boolean by first converting it to
string.
*
- * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
+ * @param classGen A BCEL class generator
+ * @param methodGen A BCEL method generator
+ * @param type An instance of BooleanType (any)
+ * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator
methodGen,
BooleanType type) {
@@ -149,20 +156,21 @@
/**
* Expects an result tree on the stack and pushes a string.
*
- * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
+ * @param classGen A BCEL class generator
+ * @param methodGen A BCEL method generator
+ * @param type An instance of StringType (any)
+ * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator
methodGen,
StringType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final String DOM_CLASS = classGen.getDOMClass();
- final String DOM_CLASS_SIG = classGen.getDOMClassSig();
if (_methodName == null) {
- int index = cpg.addMethodref(DOM_CLASS,
- "getStringValue",
- "()" + STRING_SIG);
- il.append(new INVOKEVIRTUAL(index));
+ int index = cpg.addInterfaceMethodref(DOM_INTF,
+ "getStringValue",
+ "()"+STRING_SIG);
+ il.append(new INVOKEINTERFACE(index, 1));
}
else {
final String className = classGen.getClassName();
@@ -174,14 +182,8 @@
il.append(new CHECKCAST(cpg.addClass(className)));
}
il.append(DUP);
- /*
- il.append(classGen.loadTranslet());
- if (classGen.isExternal()) {
- il.append(new CHECKCAST(cpg.addClass(className)));
- }
- */
il.append(new GETFIELD(cpg.addFieldref(className, "_dom",
- classGen.getDOMClassSig())));
+ DOM_INTF_SIG)));
// Create a new instance of a StringValueHandler
int index = cpg.addMethodref(STRING_VALUE_HANDLER, "<init>", "()V");
@@ -199,7 +201,7 @@
// Call the method that implements this result tree
index = cpg.addMethodref(className, _methodName,
- "("+ DOM_CLASS_SIG+
TRANSLET_OUTPUT_SIG+")V");
+ "("+DOM_INTF_SIG+TRANSLET_OUTPUT_SIG+")V");
il.append(new INVOKEVIRTUAL(index));
// Restore new handler and call getValue()
@@ -215,7 +217,10 @@
* Expects an result tree on the stack and pushes a real.
* Translates a result tree into a real by first converting it to string.
*
- * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
+ * @param classGen A BCEL class generator
+ * @param methodGen A BCEL method generator
+ * @param type An instance of RealType (any)
+ * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator
methodGen,
RealType type) {
@@ -227,7 +232,10 @@
* Expects a result tree on the stack and pushes a boxed result tree.
* Result trees are already boxed so the translation is just a NOP.
*
- * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
+ * @param classGen A BCEL class generator
+ * @param methodGen A BCEL method generator
+ * @param type An instance of ReferenceType (any)
+ * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator
methodGen,
ReferenceType type) {
@@ -258,11 +266,10 @@
il.append(new INVOKESPECIAL(index));
// Store new DOM into a local variable
- newDom =
- methodGen.addLocalVariable("rt_to_reference_dom",
- //!!??
- Util.getJCRefType(DOM_IMPL_SIG),
- null, null);
+ newDom = methodGen.addLocalVariable("rt_to_reference_dom",
+ Util.getJCRefType(DOM_INTF_SIG),
+ null, null);
+ il.append(new CHECKCAST(cpg.addClass(DOM_INTF_SIG)));
il.append(new ASTORE(newDom.getIndex()));
// Overwrite old handler with DOM handler
@@ -286,11 +293,10 @@
il.append(new INVOKEINTERFACE(index, 1));
// Call the method that implements this result tree
- final String DOM_CLASS_SIG = classGen.getDOMClassSig();
index = cpg.addMethodref(className,
_methodName,
"("
- + DOM_CLASS_SIG
+ + DOM_INTF_SIG
+ TRANSLET_OUTPUT_SIG
+")V");
il.append(new INVOKEVIRTUAL(index));
@@ -308,12 +314,50 @@
/**
* Expects a result tree on the stack and pushes a node-set (iterator).
+ * Note that the produced iterator is an iterator for the DOM that
+ * contains the result tree, and not the DOM that is currently in use.
+ * This conversion here will therefore not directly work with elements
+ * such as <xsl:apply-templates> and <xsl:for-each> without the DOM
+ * parameter/variable being updates as well.
*
- * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
+ * @param classGen A BCEL class generator
+ * @param methodGen A BCEL method generator
+ * @param type An instance of NodeSetType (any)
+ * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator
methodGen,
NodeSetType type) {
- classGen.getParser().notYetImplemented("result-tree -> node-set
conversion");
+ final ConstantPoolGen cpg = classGen.getConstantPool();
+ final InstructionList il = methodGen.getInstructionList();
+
+ // Put an extra copy of the result tree (DOM) on the stack
+ il.append(DUP);
+
+ // DOM adapters containing a result tree are not initialised with
+ // translet-type to DOM-type mapping. This must be done now for
+ // XPath expressions and patterns to work for the iterator we create.
+ il.append(classGen.loadTranslet()); // get names array
+ il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
+ NAMES_INDEX,
+ NAMES_INDEX_SIG)));
+ il.append(classGen.loadTranslet()); // get namespaces array
+ il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
+ NAMESPACE_INDEX,
+ NAMESPACE_INDEX_SIG)));
+ // Pass the type mappings to the DOM adapter
+ final int mapping = cpg.addInterfaceMethodref(DOM_INTF,
+ "setupMapping",
+ "(["+STRING_SIG+
+ "["+STRING_SIG+")V");
+ il.append(new INVOKEINTERFACE(mapping, 3));
+ il.append(DUP);
+
+ // Create an iterator with all the nodes in the DOM adapter
+ final int iter = cpg.addInterfaceMethodref(DOM_INTF,
+ "getChildren",
+ "(I)"+NODE_ITERATOR_SIG);
+ il.append(new PUSH(cpg, DOM.ROOTNODE));
+ il.append(new INVOKEINTERFACE(iter, 2));
}
/**
@@ -321,7 +365,10 @@
* It does not push a 0 or a 1 but instead returns branchhandle list
* to be appended to the false list.
*
- * @see
org.apache.xalan.xsltc.compiler.util.Type#translateToDesynthesized
+ * @param classGen A BCEL class generator
+ * @param methodGen A BCEL method generator
+ * @param type An instance of BooleanType (any)
+ * @see
org.apache.xalan.xsltc.compiler.util.Type#translateToDesynthesized
*/
public FlowList translateToDesynthesized(ClassGenerator classGen,
MethodGenerator methodGen,
@@ -337,6 +384,11 @@
* of the appropriate type after coercion. Result trees are translated
* to W3C Node or W3C NodeList and the translation is done
* via node-set type.
+ *
+ * @param classGen A BCEL class generator
+ * @param methodGen A BCEL method generator
+ * @param type An reference to the Class to translate to
+ * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator
methodGen,
Class clazz) {
1.2 +14 -6 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Axis.java 2001/04/17 18:52:26 1.1
+++ Axis.java 2001/08/27 09:07:21 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Axis.java,v 1.1 2001/04/17 18:52:26 sboag Exp $
+ * @(#)$Id: Axis.java,v 1.2 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -58,11 +58,17 @@
*
* @author Jacek Ambroziak
* @author Santiago Pericas-Geertsen
+ * @author Morten Jorgensen
*
*/
package org.apache.xalan.xsltc.dom;
+/*
+ * IMPORTANT NOTE - this interface will probably be replaced by
+ * org.apache.xml.dtm.Axis (very similar)
+ */
+
public interface Axis {
public static final int ANCESTOR = 0;
public static final int ANCESTORORSELF = 1;
@@ -72,11 +78,12 @@
public static final int DESCENDANTORSELF = 5;
public static final int FOLLOWING = 6;
public static final int FOLLOWINGSIBLING = 7;
- public static final int NAMESPACE = 8;
- public static final int PARENT = 9;
- public static final int PRECEDING = 10;
- public static final int PRECEDINGSIBLING = 11;
- public static final int SELF = 12;
+ public static final int NAMESPACEDECLS = 8;
+ public static final int NAMESPACE = 9;
+ public static final int PARENT = 10;
+ public static final int PRECEDING = 11;
+ public static final int PRECEDINGSIBLING = 12;
+ public static final int SELF = 13;
public static final String[] names = {
"ancestor",
@@ -88,6 +95,7 @@
"following",
"following-sibling",
"namespace",
+ "namespace-decls",
"parent",
"preceding",
"preceding-sibling",
1.3 +19 -7
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOMAdapter.java 2001/07/30 13:35:41 1.2
+++ DOMAdapter.java 2001/08/27 09:07:21 1.3
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOMAdapter.java,v 1.2 2001/07/30 13:35:41 morten Exp $
+ * @(#)$Id: DOMAdapter.java,v 1.3 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -67,18 +67,19 @@
import org.w3c.dom.NodeList;
import org.apache.xalan.xsltc.DOM;
+import org.apache.xalan.xsltc.StripFilter;
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.TransletOutputHandler;
import org.apache.xalan.xsltc.TransletException;
public final class DOMAdapter implements DOM {
private final DOMImpl _domImpl;
- private final short[] _mapping;
- private final short[] _reverse;
- private final short[] _NSmapping;
- private final short[] _NSreverse;
+ private short[] _mapping;
+ private short[] _reverse;
+ private short[] _NSmapping;
+ private short[] _NSreverse;
- private StripWhitespaceFilter _filter = null;
+ private StripFilter _filter = null;
public DOMAdapter(DOMImpl dom,
String[] namesArray,
@@ -90,6 +91,13 @@
_NSreverse = dom.getReverseNamespaceMapping(namespaceArray);
}
+ public void setupMapping(String[] names, String[] namespaces) {
+ _mapping = _domImpl.getMapping(names);
+ _reverse = _domImpl.getReverseMapping(names);
+ _NSmapping = _domImpl.getNamespaceMapping(namespaces);
+ _NSreverse = _domImpl.getReverseNamespaceMapping(namespaces);
+ }
+
/** returns singleton iterator containg the document root */
public NodeIterator getIterator() {
return _domImpl.getIterator();
@@ -110,7 +118,7 @@
}
}
- public void setFilter(StripWhitespaceFilter filter) {
+ public void setFilter(StripFilter filter) {
_filter = filter;
}
@@ -242,6 +250,10 @@
}
public String getDocumentURI() {
+ return(_domImpl.getDocumentURI());
+ }
+
+ public String getDocumentURI(int node) {
return(_domImpl.getDocumentURI());
}
1.21 +18 -5
xml-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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- DOMImpl.java 2001/08/20 14:50:32 1.20
+++ DOMImpl.java 2001/08/27 09:07:21 1.21
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOMImpl.java,v 1.20 2001/08/20 14:50:32 morten Exp $
+ * @(#)$Id: DOMImpl.java,v 1.21 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -160,6 +160,14 @@
return(_documentURI);
}
+ public String getDocumentURI(int node) {
+ return(_documentURI);
+ }
+
+ 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)
*/
@@ -175,6 +183,12 @@
}
/**
+ * Part of the DOM interface - no function here.
+ */
+ public void setFilter(StripFilter filter) { }
+
+
+ /**
* Returns true if node1 comes before node2 in document order
*/
public boolean lessThan(int node1, int node2) {
@@ -1370,7 +1384,7 @@
private static final int STRIP_SPACE = 1;
private static final int PRESERVE_SPACE = 2;
- private StripWhitespaceFilter _filter = null;
+ private StripFilter _filter = null;
private short[] _mapping = null;
private final NodeIterator _source;
private boolean _children = false;
@@ -1379,7 +1393,7 @@
public StrippingIterator(NodeIterator source,
short[] mapping,
- StripWhitespaceFilter filter) {
+ StripFilter filter) {
_filter = filter;
_mapping = mapping;
@@ -1467,7 +1481,7 @@
public NodeIterator strippingIterator(NodeIterator iterator,
short[] mapping,
- StripWhitespaceFilter filter) {
+ StripFilter filter) {
return(new StrippingIterator(iterator, mapping, filter));
}
@@ -1658,7 +1672,6 @@
// Just return the basic position if no type is specified
if (type == -1) type = _type[node];
- //if (type == -1) return(iterator.getPosition()); DEAD WRONG!!!!
int match = 1;
int curr = 0;
1.6 +19 -21
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LoadDocument.java 2001/08/07 08:58:05 1.5
+++ LoadDocument.java 2001/08/27 09:07:21 1.6
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: LoadDocument.java,v 1.5 2001/08/07 08:58:05 morten Exp $
+ * @(#)$Id: LoadDocument.java,v 1.6 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -88,12 +88,12 @@
* 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,
- AbstractTranslet translet,
- MultiDOM multiplexer)
+ public static NodeIterator document(String uri, String base,
+ AbstractTranslet translet, DOM dom)
throws Exception {
+ MultiDOM multiplexer = (MultiDOM)dom;
+
// Return an empty iterator if the URI is clearly invalid
// (to prevent some unncessary MalformedURL exceptions).
if ((uri == null) || (uri.equals("")))
@@ -122,12 +122,12 @@
// Check if we can get the DOM from a DOMCache
DOMCache cache = translet.getDOMCache();
- DOMImpl dom;
+ DOMImpl newdom;
mask = multiplexer.nextMask(); // peek
if (cache != null) {
- dom = cache.retrieveDocument(uri, mask, translet);
+ newdom = cache.retrieveDocument(uri, mask, translet);
}
else {
// Parse the input document and construct DOM object
@@ -143,29 +143,29 @@
final XMLReader reader = parser.getXMLReader();
// Set the DOM's DOM builder as the XMLReader's SAX2 content handler
- dom = new DOMImpl();
- reader.setContentHandler(dom.getBuilder());
+ newdom = new DOMImpl();
+ reader.setContentHandler(newdom.getBuilder());
// Create a DTD monitor and pass it to the XMLReader object
DTDMonitor dtdMonitor = new DTDMonitor();
dtdMonitor.handleDTD(reader);
- dom.setDocumentURI(uri);
+ newdom.setDocumentURI(uri);
reader.parse(uri);
// Set size of key/id indices
- translet.setIndexSize(dom.getSize());
+ translet.setIndexSize(newdom.getSize());
// Create index for any ID attributes defined in the document DTD
- dtdMonitor.buildIdIndex(dom, mask, translet);
+ dtdMonitor.buildIdIndex(newdom, mask, translet);
// Pass any unparsed URI elements to the translet
translet.setUnparsedEntityURIs(dtdMonitor.getUnparsedEntityURIs());
}
// Wrap the DOM object in a DOM adapter and add to multiplexer
- final DOMAdapter domAdapter = translet.makeDOMAdapter(dom);
+ final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
mask = multiplexer.addDOMAdapter(domAdapter);
// Create index for any key elements
- translet.buildKeys((DOM)multiplexer, null, null, DOM.ROOTNODE | mask);
+ translet.buildKeys((DOM)newdom, null, null, DOM.ROOTNODE | mask);
// Return a singleton iterator containing the root node
return new SingletonIterator(DOM.ROOTNODE | mask, true);
@@ -178,8 +178,7 @@
* several documents are requested.
*/
public static NodeIterator document(Object arg, String contextURI,
- AbstractTranslet translet,
- MultiDOM multiplexer)
+ AbstractTranslet translet, DOM dom)
throws TransletException {
try {
@@ -194,19 +193,18 @@
// If the argument is just a single string (an URI) we just return
// the nodes from the one document this URI points to.
if (arg instanceof String) {
- return document((String)arg, baseURI, translet, multiplexer);
+ return document((String)arg, baseURI, translet, dom);
}
// 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 {
- UnionIterator union = new UnionIterator(multiplexer);
+ UnionIterator union = new UnionIterator(dom);
NodeIterator iterator = (NodeIterator)arg;
int node;
while ((node = iterator.next()) != DOM.NULL) {
- String uri = multiplexer.getNodeValue(node);
- union.addIterator(document(uri, baseURI,
- translet, multiplexer));
+ String uri = dom.getNodeValue(node);
+ union.addIterator(document(uri, baseURI, translet, dom));
}
return(union);
}
1.5 +14 -9
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MultiDOM.java 2001/07/30 13:35:41 1.4
+++ MultiDOM.java 2001/08/27 09:07:21 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: MultiDOM.java,v 1.4 2001/07/30 13:35:41 morten Exp $
+ * @(#)$Id: MultiDOM.java,v 1.5 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -68,6 +68,7 @@
import org.w3c.dom.NodeList;
import org.apache.xalan.xsltc.DOM;
+import org.apache.xalan.xsltc.StripFilter;
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.TransletOutputHandler;
import org.apache.xalan.xsltc.TransletException;
@@ -79,7 +80,7 @@
private static final int CLR = 0x00FFFFFF;
private static final int SET = 0xFF000000;
- private DOMAdapter[] _adapters;
+ private DOM[] _adapters;
private int _free;
private int _size;
@@ -160,10 +161,10 @@
} // end of AxisIterator
- public MultiDOM(DOMAdapter main) {
+ public MultiDOM(DOM main) {
_size = INITIAL_SIZE;
_free = 1;
- _adapters = new DOMAdapter[INITIAL_SIZE];
+ _adapters = new DOM[INITIAL_SIZE];
_adapters[0] = main;
}
@@ -171,7 +172,11 @@
return(_free << 24);
}
- public int addDOMAdapter(DOMAdapter dom) {
+ public void setupMapping(String[] names, String[] namespaces) {
+ // This method only has a function in DOM adapters
+ }
+
+ public int addDOMAdapter(DOM dom) {
// Add the DOM adapter to the array of DOMs
final int domNo = _free++;
@@ -183,7 +188,7 @@
_adapters[domNo] = dom;
// Store reference to document (URI) in hashtable
- String uri = dom.getDocumentURI();
+ String uri = dom.getDocumentURI(0);
_documents.put(uri,new Integer(domNo));
return domNo << 24;
@@ -311,7 +316,7 @@
_adapters[textNode>>>24].characters(textNode & CLR, handler);
}
- public void setFilter(StripWhitespaceFilter filter) {
+ public void setFilter(StripFilter filter) {
for (int dom=0; dom<_free; dom++) {
_adapters[dom].setFilter(filter);
}
@@ -346,7 +351,7 @@
return(size);
}
- public String getNodeURI(int node) {
- return _adapters[node>>24].getDocumentURI();
+ public String getDocumentURI(int node) {
+ return _adapters[node>>24].getDocumentURI(0);
}
}
1.20 +7 -16
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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- AbstractTranslet.java 2001/08/17 13:17:45 1.19
+++ AbstractTranslet.java 2001/08/27 09:07:21 1.20
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AbstractTranslet.java,v 1.19 2001/08/17 13:17:45 morten Exp $
+ * @(#)$Id: AbstractTranslet.java,v 1.20 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -68,14 +68,13 @@
import java.util.Enumeration;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
-import org.apache.xalan.xsltc.*;
-import org.apache.xalan.xsltc.util.IntegerArray;
+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.StripWhitespaceFilter;
import org.apache.xalan.xsltc.dom.KeyIndex;
import org.apache.xalan.xsltc.dom.DTDMonitor;
+import org.apache.xalan.xsltc.util.IntegerArray;
public abstract class AbstractTranslet implements Translet {
@@ -459,17 +458,11 @@
* See compiler/TransletOutput for actual implementation.
************************************************************************/
- protected TransletOutputHandler[] _handlers;
+ public TransletOutputHandler openOutputHandler(String filename) {
+ return(null);
+ }
- protected final TransletOutputHandler getOutputHandler(double port) {
- try {
- return _handlers[(int) port];
- }
- catch (IndexOutOfBoundsException e) {
- BasisLibrary.runTimeError("Output port " + (int)port
- + " out of range.");
- return null;
- }
+ public void closeOutputHandler(TransletOutputHandler handler) {
}
/************************************************************************
@@ -488,7 +481,6 @@
*/
public final void transform(DOM document, TransletOutputHandler handler)
throws TransletException {
- _handlers = new TransletOutputHandler[] { handler };
transform(document, document.getIterator(), handler);
}
@@ -498,7 +490,6 @@
public final void transform(DOM document,
TransletOutputHandler[] handlers)
throws TransletException {
- _handlers = handlers;
transform(document, document.getIterator(), handlers[0]);
}
1.12 +24 -5
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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- BasisLibrary.java 2001/08/20 14:50:32 1.11
+++ BasisLibrary.java 2001/08/27 09:07:21 1.12
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: BasisLibrary.java,v 1.11 2001/08/20 14:50:32 morten Exp $
+ * @(#)$Id: BasisLibrary.java,v 1.12 2001/08/27 09:07:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -800,7 +800,12 @@
* Utility function: used in StringType to convert a string to an int.
*/
public static int stringToInt(String s) {
- return Integer.valueOf(s).intValue();
+ try {
+ return Integer.valueOf(s).intValue();
+ }
+ catch (NumberFormatException e) {
+ return(-1); // ???
+ }
}
/**
@@ -852,9 +857,23 @@
*/
public static NodeIterator referenceToNodeSet(Object obj) {
try {
- return (obj instanceof Node == false)
- ? (NodeIterator) obj
- : (NodeIterator) new SingletonIterator(((Node) obj).node);
+ // 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);
+ }
+ // Convert var/param -> result-tree fragment
+ else if (obj instanceof DOM) {
+ DOM dom = (DOM)obj;
+ return(dom.getIterator());
+ }
+ else {
+ runTimeTypeError("reference", "node-set");
+ return null;
+ }
}
catch (ClassCastException e) {
runTimeTypeError("reference", "node-set");
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]