|
From: Wolfgang M. M. <wol...@us...> - 2004-09-13 14:06:48
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26347/src/org/exist/xquery Modified Files: SequenceConstructor.java XQuery.java ElementConstructor.java Log Message: Fix for bug 1015954: Computed Node Constructors. Index: XQuery.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/XQuery.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** XQuery.java 12 Sep 2004 09:25:14 -0000 1.5 --- XQuery.java 13 Sep 2004 14:06:35 -0000 1.6 *************** *** 92,96 **** treeParser.getLastException()); } ! LOG.debug("compilation took " + (System.currentTimeMillis() - start)); return expr; } catch (RecognitionException e) { --- 92,96 ---- treeParser.getLastException()); } ! LOG.debug("Query:\n" + expr.pprint() + "\nCompilation took " + (System.currentTimeMillis() - start)); return expr; } catch (RecognitionException e) { Index: ElementConstructor.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/ElementConstructor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ElementConstructor.java 8 Aug 2004 19:03:26 -0000 1.7 --- ElementConstructor.java 13 Sep 2004 14:06:35 -0000 1.8 *************** *** 44,47 **** --- 44,48 ---- private AttributeConstructor attributes[] = null; private QName namespaceDecls[] = null; + private boolean isDynamic = true; public ElementConstructor(XQueryContext context) { *************** *** 52,55 **** --- 53,57 ---- super(context); this.qnameExpr = new LiteralValue(context, new StringValue(qname)); + this.isDynamic = false; } *************** *** 164,167 **** --- 166,171 ---- */ public String pprint() { + if(isDynamic) + return pprintDynamic(); StringBuffer buf = new StringBuffer(); buf.append('<').append(qnameExpr.pprint()); *************** *** 183,186 **** --- 187,201 ---- } + public String pprintDynamic() { + StringBuffer buf = new StringBuffer(); + buf.append("element { "); + buf.append(qnameExpr.pprint()); + buf.append(" } { "); + if(content != null) + buf.append(content.pprint()); + buf.append(" }"); + return buf.toString(); + } + /* (non-Javadoc) * @see org.exist.xquery.AbstractExpression#setPrimaryAxis(int) Index: SequenceConstructor.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/SequenceConstructor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SequenceConstructor.java 28 May 2004 10:54:12 -0000 1.2 --- SequenceConstructor.java 13 Sep 2004 14:06:35 -0000 1.3 *************** *** 23,29 **** package org.exist.xquery; - import java.util.ArrayList; import java.util.Iterator; - import java.util.List; import org.exist.xquery.value.Item; --- 23,27 ---- *************** *** 38,44 **** * @author wolf */ ! public class SequenceConstructor extends AbstractExpression { ! ! List expressions = new ArrayList(5); /** --- 36,40 ---- * @author wolf */ ! public class SequenceConstructor extends PathExpr { /** *************** *** 48,55 **** super(context); } - - public void addExpression(Expression expr) { - expressions.add(expr); - } /* (non-Javadoc) --- 44,47 ---- *************** *** 62,66 **** ValueSequence result = new ValueSequence(); Sequence temp; ! for(Iterator i = expressions.iterator(); i.hasNext(); ) { temp = ((Expression)i.next()).eval(contextSequence, contextItem); result.addAll(temp); --- 54,58 ---- ValueSequence result = new ValueSequence(); Sequence temp; ! for(Iterator i = steps.iterator(); i.hasNext(); ) { temp = ((Expression)i.next()).eval(contextSequence, contextItem); result.addAll(temp); *************** *** 74,78 **** public String pprint() { StringBuffer buf = new StringBuffer(); ! for(Iterator i = expressions.iterator(); i.hasNext(); ) { if(buf.length() > 0) buf.append(", "); --- 66,70 ---- public String pprint() { StringBuffer buf = new StringBuffer(); ! for(Iterator i = steps.iterator(); i.hasNext(); ) { if(buf.length() > 0) buf.append(", "); *************** *** 100,104 **** */ public void resetState() { ! for (Iterator i = expressions.iterator(); i.hasNext();) { ((Expression) i.next()).resetState(); } --- 92,96 ---- */ public void resetState() { ! for (Iterator i = steps.iterator(); i.hasNext();) { ((Expression) i.next()).resetState(); } |