You can subscribe to this list here.
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(71) |
Jun
(43) |
Jul
(9) |
Aug
(10) |
Sep
(21) |
Oct
(38) |
Nov
|
Dec
(11) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2012 |
Jan
|
Feb
(21) |
Mar
(9) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <pm_...@us...> - 2012-03-12 17:36:34
|
Revision: 4540 http://mxquery.svn.sourceforge.net/mxquery/?rev=4540&view=rev Author: pm_fischer Date: 2012-03-12 17:36:28 +0000 (Mon, 12 Mar 2012) Log Message: ----------- Forseq: create a window if no underlying iterator provides one Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/iterators/forseq/ForseqIterator.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/forseq/ForseqIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/forseq/ForseqIterator.java 2012-03-12 15:50:03 UTC (rev 4539) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/forseq/ForseqIterator.java 2012-03-12 17:36:28 UTC (rev 4540) @@ -17,6 +17,7 @@ import java.util.Vector; +import ch.ethz.mxquery.bindings.WindowFactory; import ch.ethz.mxquery.contextConfig.Context; import ch.ethz.mxquery.contextConfig.XQStaticContext; import ch.ethz.mxquery.datamodel.QName; @@ -142,8 +143,11 @@ //TODO: Do this stuff in FFLWOR protected void init() throws MXQueryException { //seq = WindowFactory.getNewWindow(context, this.subIters[0],parallelAccess); - if (subIters[0] instanceof VariableIterator) + if (subIters[0] instanceof VariableIterator) { seq = ((VariableIterator)subIters[0]).getUnderlyingIterator(); + if (seq == null) + seq = WindowFactory.getNewWindow(context, this.subIters[0],parallelAccess); + } else seq = (Window)subIters[0]; if(firstInit){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-03-12 15:50:10
|
Revision: 4539 http://mxquery.svn.sourceforge.net/mxquery/?rev=4539&view=rev Author: pm_fischer Date: 2012-03-12 15:50:03 +0000 (Mon, 12 Mar 2012) Log Message: ----------- - optimizations to avoid allocating buffers when not needed (e.g.,single let without reuse) - more aggressive window re-use - fix on collection problems Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Collection.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/GFLWORIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/LetIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/VariableIterator.java trunk/MXQuery/src/ch/ethz/mxquery/model/VariableHolder.java trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Collection.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Collection.java 2012-03-12 14:44:11 UTC (rev 4538) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Collection.java 2012-03-12 15:50:03 UTC (rev 4539) @@ -52,8 +52,8 @@ defaultCollection = true; else { XDMIterator it = subIters[0]; - if ((requiredAccess & DataflowAnalysis.NODEID_ORDER)!=0) - it = it.require(DataflowAnalysis.NODEID_ORDER); +// if ((requiredAccess & DataflowAnalysis.NODEID_ORDER)!=0) +// it = it.require(DataflowAnalysis.NODEID_ORDER); tok = it.next(); } if (defaultCollection || tok == Token.END_SEQUENCE_TOKEN ) { Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/GFLWORIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/GFLWORIterator.java 2012-03-12 14:44:11 UTC (rev 4538) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/GFLWORIterator.java 2012-03-12 15:50:03 UTC (rev 4539) @@ -116,7 +116,13 @@ TokenInterface tok; if (!init) { init = true; - returnExpr.setResettable(true); + // If we have a for or a for window, the return clause may have to be executed more than once + boolean retneedsReset = false; + for (int i=0;i<subIters.length;i++) + if (subIters[i] instanceof ForIterator || subIters[i] instanceof ForseqIterator) + retneedsReset = true; + if (retneedsReset) + returnExpr.setResettable(true); super.current = returnExpr; setupBlockingIterators(); if (!doNextBinding(posOfFirstBlockingIter)) { Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/LetIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/LetIterator.java 2012-03-12 14:44:11 UTC (rev 4538) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/LetIterator.java 2012-03-12 15:50:03 UTC (rev 4539) @@ -80,6 +80,7 @@ } if(needMat){ this.current = WindowFactory.getNewWindow(context, subIters[0]); + current.setResettable(true); }else{ this.current = subIters[0]; current.setResettable(true); @@ -161,6 +162,7 @@ lt.exprCategory = this.exprCategory; lt.isScoring = isScoring; lt.resettable = resettable; + lt.needMat = needMat; return lt; } @@ -171,6 +173,7 @@ varHolder = context.getVariable(variable); int reqOptions = varHolder.getRequiredOptions()|requiredOptions; subIters[0] = subIters[0].require(reqOptions); + needMat = varHolder.needsMaterialization(); } return this; } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/VariableIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/VariableIterator.java 2012-03-12 14:44:11 UTC (rev 4538) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/VariableIterator.java 2012-03-12 15:50:03 UTC (rev 4539) @@ -35,6 +35,7 @@ import ch.ethz.mxquery.model.Window; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.KXmlSerializer; +import ch.ethz.mxquery.util.LogLevel; import ch.ethz.mxquery.util.ObjectObjectPair; /** @@ -129,7 +130,10 @@ windowSchemaId = window.getWindowId(); Window wnd = window; window = window.getNewWindow(1, Window.END_OF_STREAM_POSITION); - window.setResettable(resettable); + if (valueHolder.needsMaterialization() && window.getWindowId() == windowSchemaId) + window.setResettable(true); // if may need to reuse the original window, we should reset it + else + window.setResettable(resettable); window.setContext(wnd.getContext(), false); current = window; } else { @@ -146,8 +150,11 @@ } if (current instanceof Window) return (Window)current; - else - throw new MXQueryException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "Window of a variable requested, got normal iterator", loc); + else { + logger.log(LogLevel.FINE, "Variable without underlying window requested"); + return null; + } + //throw new MXQueryException(ErrorCodes.A0009_EC_EVALUATION_NOT_POSSIBLE, "Window of a variable requested, got normal iterator", loc); } protected final void resetImpl() throws MXQueryException { @@ -161,18 +168,21 @@ super.freeResources(restartable); // FIXME causes errors if the windows is used somewhere else - try{ //currentToken = Token.START_SEQUENCE_TOKEN; if (window != null ){ if(windowSchemaId != window.getWindowId()){ window.destroyWindow(); + } else { + window.setWindowInUse(false); + if (window.isResettable()) + window.reset(); } window = null; } window = null; - }catch(Exception err){ - throw new RuntimeException(err.toString()); - } +// }catch(Exception err){ +// throw new RuntimeException(err.toString()); +// } if (valueHolder != null && valueHolder.getIter() != null && !restartable && !valueHolder.isAssignable()) { valueHolder.getIter().close(restartable); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/model/VariableHolder.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/model/VariableHolder.java 2012-03-12 14:44:11 UTC (rev 4538) +++ trunk/MXQuery/src/ch/ethz/mxquery/model/VariableHolder.java 2012-03-12 15:50:03 UTC (rev 4539) @@ -193,7 +193,7 @@ * @return true if materialization is needed */ public boolean needsMaterialization(){ - if(useCounter > 0 || resetable){ + if(useCounter > 1 || resetable){ return true; }else{ return false; Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2012-03-12 14:44:11 UTC (rev 4538) +++ trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2012-03-12 15:50:03 UTC (rev 4539) @@ -5518,6 +5518,7 @@ ((XDMIterator) o).setSubIters(new VariableIterator(predCtx, letLast, false, predicate.getLoc())); predCtx.incVariableUse(letLast); + predCtx.incVariableUse(var1); } } // FIXME:For variables, additive and multiplicative iterators, a numeric This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-03-12 14:44:22
|
Revision: 4538 http://mxquery.svn.sourceforge.net/mxquery/?rev=4538&view=rev Author: pm_fischer Date: 2012-03-12 14:44:11 +0000 (Mon, 12 Mar 2012) Log Message: ----------- revert change on XDMImportAdapter to create stores when materialization is needed Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2012-03-12 14:00:53 UTC (rev 4537) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2012-03-12 14:44:11 UTC (rev 4538) @@ -310,9 +310,10 @@ } public XDMIterator require(int requiredOptions) throws MXQueryException { - if ((requiredOptions & DataflowAnalysis.NODEID_ORDER) != 0) + if ((requiredOptions & DataflowAnalysis.NODEID_ORDER) != 0 && + (requiredOptions & DataflowAnalysis.MATERIALIZATION_SUPPORT) == 0) generateNodeIds = true; - return this; + return super.require(requiredOptions); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-03-12 14:01:04
|
Revision: 4537 http://mxquery.svn.sourceforge.net/mxquery/?rev=4537&view=rev Author: pm_fischer Date: 2012-03-12 14:00:53 +0000 (Mon, 12 Mar 2012) Log Message: ----------- removed accidential commit of dummy (=parse-only) STaX adapter Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java 2012-03-12 13:50:36 UTC (rev 4536) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java 2012-03-12 14:00:53 UTC (rev 4537) @@ -46,7 +46,7 @@ import ch.ethz.mxquery.xdmio.xmlAdapters.NonSchemaValidatingSaxImportAdapter; import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingDOMAdapter; import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingStaxAdapter; -import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingStaxAdapterDummy; +//import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingStaxAdapterDummy; import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingStaxAdapterProjection; import ch.ethz.mxquery.xdmio.xmlAdapters.ValidatedSaxImportAdapter; import ch.ethz.mxquery.xdmio.xmlAdapters.XPPImportAdapter; @@ -187,19 +187,19 @@ throw new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing: "+e.toString(),location); } } - case Context.NONVALIDATED_INPUT_MODE_STAX_DUMMY: { - XMLInputFactory factory = XMLInputFactory.newInstance(); - if (valMode == Context.NO_VALIDATION || valMode == Context.IGNORE_DTD) - factory.setProperty("javax.xml.stream.supportDTD", Boolean.FALSE); - else - factory.setProperty("javax.xml.stream.supportDTD", Boolean.TRUE); - try { - XMLStreamReader reader = factory.createXMLStreamReader(new StreamSource(new File(uri))); - return new NonValidatingStaxAdapterDummy(ctx,location,reader); - } catch (XMLStreamException e) { - throw new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing: "+e.toString(),location); - } - } +// case Context.NONVALIDATED_INPUT_MODE_STAX_DUMMY: { +// XMLInputFactory factory = XMLInputFactory.newInstance(); +// if (valMode == Context.NO_VALIDATION || valMode == Context.IGNORE_DTD) +// factory.setProperty("javax.xml.stream.supportDTD", Boolean.FALSE); +// else +// factory.setProperty("javax.xml.stream.supportDTD", Boolean.TRUE); +// try { +// XMLStreamReader reader = factory.createXMLStreamReader(new StreamSource(new File(uri))); +// return new NonValidatingStaxAdapterDummy(ctx,location,reader); +// } catch (XMLStreamException e) { +// throw new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing: "+e.toString(),location); +// } +// } case Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION: { XMLInputFactory factory = XMLInputFactory.newInstance(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-03-12 13:50:46
|
Revision: 4536 http://mxquery.svn.sourceforge.net/mxquery/?rev=4536&view=rev Author: pm_fischer Date: 2012-03-12 13:50:36 +0000 (Mon, 12 Mar 2012) Log Message: ----------- -Dataflow analysis - node IDs for collection, document-uri() Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Collection.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocumentUri.java trunk/MXQuery/src/ch/ethz/mxquery/update/store/llImpl/LLStoreSet.java trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java 2012-03-12 08:47:44 UTC (rev 4535) +++ trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java 2012-03-12 13:50:36 UTC (rev 4536) @@ -186,7 +186,7 @@ public static final int NONVALIDATED_INPUT_MODE_DOM = 3; public static final int NONVALIDATED_INPUT_MODE_SAX_TIDY = 4; public static final int NONVALIDATED_INPUT_MODE_STAX_PROJECTION = 5; - //public static final int NONVALIDATED_INPUT_MODE_STAX_DUMMY = 6; + public static final int NONVALIDATED_INPUT_MODE_STAX_DUMMY = 6; public static final int NO_VALIDATION = 0; public static final int IGNORE_DTD = 1; Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Collection.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Collection.java 2012-03-12 08:47:44 UTC (rev 4535) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Collection.java 2012-03-12 13:50:36 UTC (rev 4536) @@ -26,15 +26,17 @@ import ch.ethz.mxquery.exceptions.ErrorCodes; import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.model.CurrentBasedIterator; +import ch.ethz.mxquery.model.DataflowAnalysis; import ch.ethz.mxquery.model.XDMIterator; public class Collection extends CurrentBasedIterator { protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { - XDMIterator copy = new Collection(); + Collection copy = new Collection(); copy.setContext(context, true); copy.setSubIters(subIters); + copy.requiredAccess = requiredAccess; return copy; } private int index = -1; @@ -50,6 +52,8 @@ defaultCollection = true; else { XDMIterator it = subIters[0]; + if ((requiredAccess & DataflowAnalysis.NODEID_ORDER)!=0) + it = it.require(DataflowAnalysis.NODEID_ORDER); tok = it.next(); } if (defaultCollection || tok == Token.END_SEQUENCE_TOKEN ) { Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocumentUri.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocumentUri.java 2012-03-12 08:47:44 UTC (rev 4535) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DocumentUri.java 2012-03-12 13:50:36 UTC (rev 4536) @@ -25,6 +25,7 @@ import ch.ethz.mxquery.datamodel.xdm.Token; import ch.ethz.mxquery.datamodel.xdm.TokenInterface; import ch.ethz.mxquery.exceptions.MXQueryException; +import ch.ethz.mxquery.model.DataflowAnalysis; import ch.ethz.mxquery.model.TokenBasedIterator; import ch.ethz.mxquery.model.XDMIterator; @@ -59,5 +60,9 @@ public TypeInfo getStaticType() { return new TypeInfo(Type.ANY_URI,Type.OCCURRENCE_IND_ZERO_OR_ONE); } - + + public XDMIterator require(int requiredOptions) throws MXQueryException { + // Could relax to any NODE_* + return super.require(requiredOptions | DataflowAnalysis.NODEID_ORDER); + } } Modified: trunk/MXQuery/src/ch/ethz/mxquery/update/store/llImpl/LLStoreSet.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/update/store/llImpl/LLStoreSet.java 2012-03-12 08:47:44 UTC (rev 4535) +++ trunk/MXQuery/src/ch/ethz/mxquery/update/store/llImpl/LLStoreSet.java 2012-03-12 13:50:36 UTC (rev 4536) @@ -144,6 +144,10 @@ this.stores.put(uri, ftBuf); return ftBuf; } + + if ((requiredStorageOptions & DataflowAnalysis.NODEID_ORDER) != 0) + initialDataIterator = initialDataIterator.require(DataflowAnalysis.NODEID_ORDER); + // Streaming Store WindowBuffer strBuf = new WindowBuffer(initialDataIterator,false, 0,10000,false); this.stores.put(uri, strBuf); Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java 2012-03-12 08:47:44 UTC (rev 4535) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java 2012-03-12 13:50:36 UTC (rev 4536) @@ -46,6 +46,7 @@ import ch.ethz.mxquery.xdmio.xmlAdapters.NonSchemaValidatingSaxImportAdapter; import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingDOMAdapter; import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingStaxAdapter; +import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingStaxAdapterDummy; import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingStaxAdapterProjection; import ch.ethz.mxquery.xdmio.xmlAdapters.ValidatedSaxImportAdapter; import ch.ethz.mxquery.xdmio.xmlAdapters.XPPImportAdapter; @@ -183,9 +184,23 @@ XMLStreamReader reader = factory.createXMLStreamReader(new StreamSource(new File(uri))); return new NonValidatingStaxAdapter(ctx,location,reader); } catch (XMLStreamException e) { - throw new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing",location); + throw new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing: "+e.toString(),location); } } + case Context.NONVALIDATED_INPUT_MODE_STAX_DUMMY: { + XMLInputFactory factory = XMLInputFactory.newInstance(); + if (valMode == Context.NO_VALIDATION || valMode == Context.IGNORE_DTD) + factory.setProperty("javax.xml.stream.supportDTD", Boolean.FALSE); + else + factory.setProperty("javax.xml.stream.supportDTD", Boolean.TRUE); + try { + XMLStreamReader reader = factory.createXMLStreamReader(new StreamSource(new File(uri))); + return new NonValidatingStaxAdapterDummy(ctx,location,reader); + } catch (XMLStreamException e) { + throw new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing: "+e.toString(),location); + } + } + case Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION: { XMLInputFactory factory = XMLInputFactory.newInstance(); if (valMode == Context.NO_VALIDATION || valMode == Context.IGNORE_DTD) Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2012-03-12 08:47:44 UTC (rev 4535) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2012-03-12 13:50:36 UTC (rev 4536) @@ -312,7 +312,7 @@ public XDMIterator require(int requiredOptions) throws MXQueryException { if ((requiredOptions & DataflowAnalysis.NODEID_ORDER) != 0) generateNodeIds = true; - return super.require(requiredOptions); + return this; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-03-12 08:47:57
|
Revision: 4535 http://mxquery.svn.sourceforge.net/mxquery/?rev=4535&view=rev Author: pm_fischer Date: 2012-03-12 08:47:44 +0000 (Mon, 12 Mar 2012) Log Message: ----------- - more dataflow analysis for node id support - switch node id generation to "on-demand" (as output by data flow analysis) - some performance optimizations on TokenBuffer and StaX parser wrapper Modified Paths: -------------- trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Parse.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Soap_call.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/ValidateIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/scripting/WSFunction.java trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/TokenBufferStore.java trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapter.java trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/Doc.java Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java =================================================================== --- trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/android/src/ch/ethz/mxquery/functions/fn/Doc.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -52,6 +52,7 @@ private final int OPERATION_UNPARSED_LINES=3; private boolean inValidateExpression = false; private int operation = OPERATION_DOC; + private int requiredOptions = 0; private String docURI = null; private Reader rd = null; // keep around to close @@ -139,10 +140,12 @@ // else // cur = XDMInputFactory.createXMLInput(context, uri, true, context.getInputValidationMode(), loc); ((XMLSource)cur).setURI(uri); + cur = cur.require(requiredOptions); break; case OPERATION_TIDY: cur = XDMInputFactory.createTidyInput(context, rd, loc); ((XMLSource)cur).setURI(uri); + cur = cur.require(requiredOptions); break; case OPERATION_UNPARSED: StringBuffer sb = new StringBuffer(); @@ -201,6 +204,7 @@ copy.operation = operation; copy.setConstModePreserve(this.constModePreserve); copy.setSubIters(subIters); + copy.requiredOptions = requiredOptions; return copy; } @@ -258,4 +262,10 @@ else return null; } + + public XDMIterator require(int requiredOptions) throws MXQueryException { + this.requiredOptions = requiredOptions; + return super.require(requiredOptions); + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -186,7 +186,7 @@ public static final int NONVALIDATED_INPUT_MODE_DOM = 3; public static final int NONVALIDATED_INPUT_MODE_SAX_TIDY = 4; public static final int NONVALIDATED_INPUT_MODE_STAX_PROJECTION = 5; - + //public static final int NONVALIDATED_INPUT_MODE_STAX_DUMMY = 6; public static final int NO_VALIDATION = 0; public static final int IGNORE_DTD = 1; @@ -496,8 +496,10 @@ holder.setIter(st.getIterator(this)); } } - else - holder.setIter(iter); + else { + iter = iter.require(holder.getRequiredOptions()); + holder.setIter(iter); + } } /* Modified: trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -57,6 +57,7 @@ import ch.ethz.mxquery.iterators.SequenceTypeIterator; import ch.ethz.mxquery.iterators.TokenIterator; import ch.ethz.mxquery.model.CurrentBasedIterator; +import ch.ethz.mxquery.model.DataflowAnalysis; import ch.ethz.mxquery.model.Iterator; import ch.ethz.mxquery.model.Wildcard; import ch.ethz.mxquery.model.XDMIterator; @@ -97,9 +98,10 @@ public final static QName EHC004_DYNAMIC_SRC_ATTR_INCOMPATIBLE = new QName(exPathErrorNS,"err","HC004"); public final static QName EHC005_DYNAMIC_INVALID_REQUEST_ELEM = new QName(exPathErrorNS,"err","HC005"); public final static QName EHC006_DYNAMIC_TIMEOUT = new QName(exPathErrorNS,"err","HC006"); - private boolean generateNodeIds = true; + private boolean generateNodeIds = false; private static int nodeIdCount = 0; Identifier last_identifier; + private int requiredOptions = 0; private final static String uri = "http://www.mxquery.org/nodeconstruction"; static int docs = 0; @@ -136,6 +138,7 @@ HttpIO copy = new HttpIO(); copy.setContext(context, true); copy.setSubIters(subIters); + copy.requiredOptions = requiredOptions; return copy; } @@ -157,6 +160,9 @@ private void init() throws MXQueryException { + if ((requiredOptions & DataflowAnalysis.NODEID_ORDER) != 0) + generateNodeIds = true; + Context childContext = new Context(context); subIters[0].setResettable(true); @@ -551,13 +557,16 @@ || contentType.equalsIgnoreCase("application/xml") || contentType.equalsIgnoreCase("text/xml-external-parsed-entity") || contentType.equalsIgnoreCase("application/xml-external-parsed-entity") - || contentType.indexOf("+xml") >= 0) + || contentType.indexOf("+xml") >= 0) { resIts[resIts.length - 1] = XDMInputFactory.createXMLInput( context, new StringReader(result.toString()), false, context.getInputValidationMode(), loc); + resIts[resIts.length - 1].require(requiredOptions); + } else if (contentType.indexOf("html") >= 0) { resIts[resIts.length - 1] = XDMInputFactory.createTidyInput( - context, new StringReader(result.toString()), loc); + context, new StringReader(result.toString()), loc); + resIts[resIts.length - 1].require(requiredOptions); } else if (contentType.startsWith("text/") || contentType.equalsIgnoreCase("application/xml-dtd") || contentType.equalsIgnoreCase("application/json")) { resIts[resIts.length - 1] = new TokenIterator(context, new TextToken(Type.TEXT_NODE_UNTYPED_ATOMIC, createNextTokenId(3), result @@ -826,8 +835,11 @@ context.addNamespace(httpNS, httpURI); return super.staticInit(); } - + public XDMIterator require(int requiredOptions) throws MXQueryException { + this.requiredOptions = requiredOptions; + return super.require(requiredOptions); + } } Modified: trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/src/ch/ethz/mxquery/extensionsModules/zorbaRest/HttpIO.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -53,6 +53,7 @@ import ch.ethz.mxquery.functions.fn.EncodeForURI; import ch.ethz.mxquery.iterators.TokenIterator; import ch.ethz.mxquery.model.CurrentBasedIterator; +import ch.ethz.mxquery.model.DataflowAnalysis; import ch.ethz.mxquery.model.Iterator; import ch.ethz.mxquery.model.TokenSequenceIterator; import ch.ethz.mxquery.model.XDMIterator; @@ -79,6 +80,7 @@ private boolean generateNodeIds = true; private static int nodeIdCount = 0; Identifier last_identifier; + private int requiredOptions = 0; private final static String uri = "http://www.mxquery.org/nodeconstruction"; static int docs = 0; @@ -127,6 +129,7 @@ if (request_type == REQUEST_TYPE_DELETE) copy.setOperation("delete"); copy.tidy = tidy; + copy.requiredOptions = requiredOptions; return copy; } @@ -147,6 +150,10 @@ XDMIterator[] resIts; private void init() throws MXQueryException { + + if ((requiredOptions & DataflowAnalysis.NODEID_ORDER) != 0) + generateNodeIds = true; + String url = getStringValue(subIters[0]); if (request_type != REQUEST_TYPE_GET && url.indexOf('?') >= 0) { throw new DynamicException( @@ -563,13 +570,18 @@ if (contentType.equalsIgnoreCase("text/xml") || contentType.equalsIgnoreCase("application/xml") || contentType.indexOf("+xml") >= 0) - if (tidy) + if (tidy) { resIts[resIts.length - 4] = XDMInputFactory.createTidyInput( context, new StringReader(result.toString()), loc); - else + resIts[resIts.length - 4].require(requiredOptions); + + } + else { resIts[resIts.length - 4] = XDMInputFactory.createXMLInput( context, new StringReader(result.toString()), false, context.getInputValidationMode(), loc); + resIts[resIts.length - 4].require(requiredOptions); + } else if (contentType.indexOf("html") >= 0 && tidy) { resIts[resIts.length - 4] = XDMInputFactory.createTidyInput( context, new StringReader(result.toString()), loc); @@ -729,5 +741,9 @@ return docId; } + public XDMIterator require(int requiredOptions) throws MXQueryException { + this.requiredOptions = requiredOptions; + return super.require(requiredOptions); + } } Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -55,6 +55,7 @@ private final int OPERATION_UNPARSED_LINES=3; private boolean inValidateExpression = false; private int operation = OPERATION_DOC; + private int requiredOptions = 0; private String docURI = null; private Reader rd = null; // keep around to close @@ -135,9 +136,11 @@ else cur = XDMInputFactory.createXMLInput(context, uri, true, context.getInputValidationMode(), loc); ((XMLSource)cur).setURI(uri); + cur = cur.require(requiredOptions); break; case OPERATION_TIDY: cur = XDMInputFactory.createTidyInput(context, rd, loc); + cur = cur.require(requiredOptions); ((XMLSource)cur).setURI(uri); break; case OPERATION_UNPARSED: @@ -195,6 +198,7 @@ copy.setContext(context, true); copy.setInValidateExpression(inValidateExpression); copy.operation = operation; + copy.requiredOptions = requiredOptions; copy.setConstModePreserve(this.constModePreserve); copy.setSubIters(subIters); return copy; @@ -263,5 +267,9 @@ return new ObjectObjectPair(returned, new Set()); } + public XDMIterator require(int requiredOptions) throws MXQueryException { + this.requiredOptions = requiredOptions; + return super.require(requiredOptions); + } } Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Parse.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Parse.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Parse.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -33,13 +33,16 @@ public class Parse extends CurrentBasedIterator implements RequestTypeMulti{ private boolean useTidy; + private int requiredOptions = 0; + protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { Parse ret = new Parse(); ret.setSubIters(subIters); ret.setContext(context, false); ret.useTidy = useTidy; + ret.requiredOptions = requiredOptions; return ret; } @@ -62,6 +65,7 @@ current = XDMInputFactory.createXMLInput(context, new StringReader(add),false,context.getInputValidationMode(),loc); else current = XDMInputFactory.createTidyInput(context, new StringReader(add), loc); + current = current.require(requiredOptions); return; } public TypeInfo getStaticType() { @@ -83,5 +87,10 @@ public void setReturnType(int type) throws MXQueryException { } + + public XDMIterator require(int requiredOptions) throws MXQueryException { + this.requiredOptions = requiredOptions; + return super.require(requiredOptions); + } } Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Soap_call.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Soap_call.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Soap_call.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -36,6 +36,7 @@ import ch.ethz.mxquery.xdmio.XMLSource; public class Soap_call extends CurrentBasedIterator { + private int requiredOptions = 0; public TokenInterface next() throws MXQueryException{ if (called == 0) { init(); @@ -103,6 +104,7 @@ } XMLSource xmlIt = XDMInputFactory.createXMLInput(context, new StringReader(soapResult), false, context.getInputValidationMode(), loc); xmlIt.setURI(location); + xmlIt = (XMLSource)xmlIt.require(requiredOptions); current = new NodeIterator(context, xmlIt,loc); //currentToken = new TextToken(null, soapResult); @@ -112,9 +114,16 @@ } protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { - XDMIterator copy = new Soap_call(); + Soap_call copy = new Soap_call(); copy.setContext(context, true); copy.setSubIters(subIters); + copy.requiredOptions = requiredOptions; return copy; } + + public XDMIterator require(int requiredOptions) throws MXQueryException { + this.requiredOptions = requiredOptions; + return super.require(requiredOptions); + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/ValidateIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/ValidateIterator.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/ValidateIterator.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -1,123 +1,129 @@ -/* Copyright 2006 - 2009 ETH Zurich - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.ethz.mxquery.iterators; - -import java.io.Reader; -import java.util.Vector; - -import ch.ethz.mxquery.contextConfig.Context; -import ch.ethz.mxquery.datamodel.types.Type; -import ch.ethz.mxquery.datamodel.xdm.TokenInterface; -import ch.ethz.mxquery.exceptions.DynamicException; -import ch.ethz.mxquery.exceptions.ErrorCodes; -import ch.ethz.mxquery.exceptions.MXQueryException; -import ch.ethz.mxquery.exceptions.QueryLocation; -import ch.ethz.mxquery.exceptions.TypeException; -import ch.ethz.mxquery.model.CurrentBasedIterator; -import ch.ethz.mxquery.model.XDMIterator; -import ch.ethz.mxquery.util.StringReader; -import ch.ethz.mxquery.xdmio.XDMInputFactory; -import ch.ethz.mxquery.xdmio.XDMSerializer; - -public class ValidateIterator extends CurrentBasedIterator { - - private int mode; - - - private class DetectDocIterator extends CurrentBasedIterator{ - - public DetectDocIterator(Context ctx, XDMIterator it, QueryLocation loc) { - super(ctx,new XDMIterator[]{it},loc); - } - - private boolean isDoc = false; - private int numRootNodes = 0; - - protected XDMIterator copy(Context context, XDMIterator[] subIters, - Vector nestedPredCtxStack) throws MXQueryException { - return new DetectDocIterator(context, subIters[0],loc); - } - - public TokenInterface next() throws MXQueryException { - if (called == 0) { - called++; - current = subIters[0]; - TokenInterface tok = getNext(); - if (tok.getEventType() == Type.START_DOCUMENT) - isDoc = true; - if (tok.getEventType() == Type.START_TAG) - numRootNodes++; - return tok; - } - TokenInterface t1 = getNext(); - if ((depth == 1 || isDoc && depth ==2)&&t1.getEventType() == Type.START_TAG) { - numRootNodes++; - } - if (numRootNodes > 1 || (isDoc && depth==1 && t1.getEventType() == Type.START_DOCUMENT)) - if (isDoc && depth >1) - throw new DynamicException(ErrorCodes.E0061_DYNAMIC_VALIDATE_MORE_THAN_ONE_ELEMENT, "Attempting to validate a document containing more than one root element. Offending element name: "+t1.getName(), loc); - else - throw new TypeException(ErrorCodes.E0030_TYPE_VALIDATE_MORE_THAN_ONE_ELEMENT, "Attempting to validate more than one element/document.", loc); - - return t1; - } - - protected void resetImpl() throws MXQueryException { - super.resetImpl(); - isDoc = false; - numRootNodes = 0; - } - - public boolean isDoc() { - return isDoc; - } - - } - - public ValidateIterator(int mode, Context ctx, XDMIterator[] subIters, QueryLocation loc) { - super(ctx, subIters, loc); - this.mode = mode; - } - - protected void init() throws MXQueryException { - XDMSerializer ip = new XDMSerializer(); - DetectDocIterator docDetect = new DetectDocIterator(context, subIters[0], loc); - String strResult = ip.eventsToXML(docDetect); - Reader reader = new StringReader(strResult); - current = XDMInputFactory.createXMLInput(context, reader, docDetect.isDoc(), mode, loc); - } - - protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { - return new ValidateIterator(this.mode, this.context, subIters, loc); - } - - public TokenInterface next() throws MXQueryException { - if (called == 0) { - init(); - called++; - } - TokenInterface tok = current.next(); - return tok; - } - public boolean isExprParameter(int valueToCheck, boolean recursive) { - if (valueToCheck == EXPR_PARAM_XDMGEN) - return true; - else - return super.isExprParameter(valueToCheck, recursive); - } - - -} +/* Copyright 2006 - 2009 ETH Zurich + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.mxquery.iterators; + +import java.io.Reader; +import java.util.Vector; + +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.types.Type; +import ch.ethz.mxquery.datamodel.xdm.TokenInterface; +import ch.ethz.mxquery.exceptions.DynamicException; +import ch.ethz.mxquery.exceptions.ErrorCodes; +import ch.ethz.mxquery.exceptions.MXQueryException; +import ch.ethz.mxquery.exceptions.QueryLocation; +import ch.ethz.mxquery.exceptions.TypeException; +import ch.ethz.mxquery.model.CurrentBasedIterator; +import ch.ethz.mxquery.model.XDMIterator; +import ch.ethz.mxquery.util.StringReader; +import ch.ethz.mxquery.xdmio.XDMInputFactory; +import ch.ethz.mxquery.xdmio.XDMSerializer; + +public class ValidateIterator extends CurrentBasedIterator { + + private int mode; + private int requiredOptions = 0; + + private class DetectDocIterator extends CurrentBasedIterator{ + + public DetectDocIterator(Context ctx, XDMIterator it, QueryLocation loc) { + super(ctx,new XDMIterator[]{it},loc); + } + + private boolean isDoc = false; + private int numRootNodes = 0; + + protected XDMIterator copy(Context context, XDMIterator[] subIters, + Vector nestedPredCtxStack) throws MXQueryException { + return new DetectDocIterator(context, subIters[0],loc); + } + + public TokenInterface next() throws MXQueryException { + if (called == 0) { + called++; + current = subIters[0]; + TokenInterface tok = getNext(); + if (tok.getEventType() == Type.START_DOCUMENT) + isDoc = true; + if (tok.getEventType() == Type.START_TAG) + numRootNodes++; + return tok; + } + TokenInterface t1 = getNext(); + if ((depth == 1 || isDoc && depth ==2)&&t1.getEventType() == Type.START_TAG) { + numRootNodes++; + } + if (numRootNodes > 1 || (isDoc && depth==1 && t1.getEventType() == Type.START_DOCUMENT)) + if (isDoc && depth >1) + throw new DynamicException(ErrorCodes.E0061_DYNAMIC_VALIDATE_MORE_THAN_ONE_ELEMENT, "Attempting to validate a document containing more than one root element. Offending element name: "+t1.getName(), loc); + else + throw new TypeException(ErrorCodes.E0030_TYPE_VALIDATE_MORE_THAN_ONE_ELEMENT, "Attempting to validate more than one element/document.", loc); + + return t1; + } + + protected void resetImpl() throws MXQueryException { + super.resetImpl(); + isDoc = false; + numRootNodes = 0; + } + + public boolean isDoc() { + return isDoc; + } + + } + + public ValidateIterator(int mode, Context ctx, XDMIterator[] subIters, QueryLocation loc) { + super(ctx, subIters, loc); + this.mode = mode; + } + + protected void init() throws MXQueryException { + XDMSerializer ip = new XDMSerializer(); + DetectDocIterator docDetect = new DetectDocIterator(context, subIters[0], loc); + String strResult = ip.eventsToXML(docDetect); + Reader reader = new StringReader(strResult); + current = XDMInputFactory.createXMLInput(context, reader, docDetect.isDoc(), mode, loc); + current = current.require(requiredOptions); + } + + protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { + ValidateIterator val = new ValidateIterator(this.mode, this.context, subIters, loc); + val.requiredOptions = requiredOptions; + return val; + } + + public TokenInterface next() throws MXQueryException { + if (called == 0) { + init(); + called++; + } + TokenInterface tok = current.next(); + return tok; + } + public boolean isExprParameter(int valueToCheck, boolean recursive) { + if (valueToCheck == EXPR_PARAM_XDMGEN) + return true; + else + return super.isExprParameter(valueToCheck, recursive); + } + + public XDMIterator require(int requiredOptions) throws MXQueryException { + this.requiredOptions = requiredOptions; + return super.require(requiredOptions); + } +} Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/scripting/WSFunction.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/scripting/WSFunction.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/scripting/WSFunction.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -64,6 +64,7 @@ private String[] paramTypes; private QName returnName; private String returnType; + private int requiredOptions; public WSFunction(Context ctx, QueryLocation loc, QName name, String style,String soapAction, String namespace, Hashtable declaredNSs, String encoding, String location, String[] paramNames, @@ -238,7 +239,8 @@ soapResult = startTag+childElement+endTag; } XMLSource xmlIt = XDMInputFactory.createXMLInput(context, new StringReader(soapResult), false, context.getInputValidationMode(), loc); - xmlIt.setURI(location); + xmlIt.setURI(location); + xmlIt = (XMLSource)xmlIt.require(requiredOptions); if (this.returnType == null || this.returnType.equals("")){//the return 'part' is an element TypeInfo stepInfo = new TypeInfo(Type.START_TAG,Type.OCCURRENCE_IND_EXACTLY_ONE,this.returnName); @@ -319,9 +321,17 @@ } protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { - XDMIterator copy = new WSFunction(context, loc, name.copy(), style, soapAction, namespace, declaredNSs, encoding, location, paramNames, Iterator.copyStrings(paramTypes), returnName, returnType); + WSFunction copy = new WSFunction(context, loc, name.copy(), style, soapAction, namespace, declaredNSs, encoding, location, paramNames, Iterator.copyStrings(paramTypes), returnName, returnType); copy.setContext(context, true); copy.setSubIters(subIters); + copy.requiredOptions = requiredOptions; return copy; } + + public XDMIterator require(int requiredOptions) throws MXQueryException { + this.requiredOptions = requiredOptions; + return super.require(requiredOptions); + } + + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/TokenBufferStore.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/TokenBufferStore.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/TokenBufferStore.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -26,6 +26,7 @@ import ch.ethz.mxquery.datamodel.MXQueryNumber; import ch.ethz.mxquery.datamodel.Source; import ch.ethz.mxquery.datamodel.types.Type; +import ch.ethz.mxquery.datamodel.types.TypeDictionary; import ch.ethz.mxquery.datamodel.xdm.NamedToken; import ch.ethz.mxquery.datamodel.xdm.TextToken; import ch.ethz.mxquery.datamodel.xdm.Token; @@ -41,7 +42,7 @@ */ public class TokenBufferStore extends FIFOStore { - private int initialCapacity = 50; + private int initialCapacity = 250; //private int initialCapacity = 1000; @@ -90,8 +91,8 @@ public boolean isScoring; private int scoreCapacity = nodeIndexCapacity; + private TypeDictionary td = Context.getDictionary(); - //protected static int descendantCounter = 0; protected static int nodeIdCount = 0; @@ -308,7 +309,7 @@ break; } - if ( Type.isAtomicType(type, Context.getDictionary()) || type == Type.UNTYPED || type == Type.ITEM || type == Type.FUNCTION_ITEM) { + if ( Type.isAtomicType(type, td) || type == Type.UNTYPED || type == Type.ITEM || type == Type.FUNCTION_ITEM) { if (level == 0) { indexNewNode(); Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapter.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapter.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapter.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -1,232 +1,240 @@ -/* Copyright 2006 - 2009 ETH Zurich - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.ethz.mxquery.xdmio.xmlAdapters; - -import java.util.LinkedList; -import java.util.Vector; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import ch.ethz.mxquery.contextConfig.Context; -import ch.ethz.mxquery.datamodel.QName; -import ch.ethz.mxquery.datamodel.XQName; -import ch.ethz.mxquery.datamodel.types.Type; -import ch.ethz.mxquery.datamodel.xdm.CommentToken; -import ch.ethz.mxquery.datamodel.xdm.ElementToken; -import ch.ethz.mxquery.datamodel.xdm.NamedToken; -import ch.ethz.mxquery.datamodel.xdm.ProcessingInstrToken; -import ch.ethz.mxquery.datamodel.xdm.TextToken; -import ch.ethz.mxquery.datamodel.xdm.Token; -import ch.ethz.mxquery.datamodel.xdm.TokenInterface; -import ch.ethz.mxquery.exceptions.MXQueryException; -import ch.ethz.mxquery.exceptions.QueryLocation; -import ch.ethz.mxquery.model.XDMIterator; -import ch.ethz.mxquery.util.Utils; - -public class NonValidatingStaxAdapter extends XDMImportAdapter { - private XMLStreamReader reader; - - private LinkedList tokensList; - - public NonValidatingStaxAdapter(Context ctx, QueryLocation loc, XMLStreamReader reader) { - super(ctx, loc); - this.reader = reader; - this.tokensList = new LinkedList(); - } - - private TokenInterface getNext() { - TokenInterface tok = Token.END_SEQUENCE_TOKEN; - if (endOfSeq) - return tok; - try { - int event = reader.getEventType(); - switch (event) { - case XMLStreamConstants.ATTRIBUTE: - break; - case XMLStreamConstants.DTD: - break; - case XMLStreamConstants.CDATA: - case XMLStreamConstants.CHARACTERS: - case XMLStreamConstants.SPACE: - { - StringBuffer mergedText = new StringBuffer(); - while (event == XMLStreamConstants.CDATA || event == XMLStreamConstants.SPACE || event == XMLStreamConstants.CHARACTERS) { - mergedText.append(reader.getText()); - reader.next(); - event = reader.getEventType(); - } - return new TextToken(Type.TEXT_NODE_UNTYPED_ATOMIC, createNextTokenId(Type.TEXT_NODE_UNTYPED_ATOMIC, null), mergedText.toString(),curNsScope); - } - case XMLStreamConstants.COMMENT: - tok = new CommentToken(createNextTokenId(Type.COMMENT, null), reader.getText(),curNsScope); - break; - case XMLStreamConstants.END_DOCUMENT: - tok = new Token(Type.END_DOCUMENT,null,curNsScope); - break; - case XMLStreamConstants.END_ELEMENT: - String name = reader.getLocalName(); - String ns_uri = reader.getNamespaceURI(); - String prefix = reader.getPrefix(); - if (prefix != null && prefix.length() == 0) - prefix = null; - XQName tName = new QName(ns_uri, prefix, name); - tok = new ElementToken(Type.END_TAG, null, tName, curNsScope); - checkCloseNsScope(); - level--; - break; - case XMLStreamConstants.ENTITY_DECLARATION: // not used - break; - case XMLStreamConstants.ENTITY_REFERENCE: - break; - case XMLStreamConstants.NAMESPACE: - break; - case XMLStreamConstants.NOTATION_DECLARATION: - tok = new TextToken(createNextTokenId(Type.NOTATION, null), reader.getText()); - break; - case XMLStreamConstants.PROCESSING_INSTRUCTION: - tok = new ProcessingInstrToken(createNextTokenId(Type.PROCESSING_INSTRUCTION, null), reader.getPIData(), reader.getPITarget(),curNsScope); - break; - case XMLStreamConstants.START_DOCUMENT: - tok = new Token(Type.START_DOCUMENT,createNextTokenId(Type.START_DOCUMENT, null),curNsScope); - break; - case XMLStreamConstants.START_ELEMENT: - level++; - - boolean foundId = false; - boolean foundIdREFS = false; - - String xmlId = null; - String [] xmlIdREFS = null; - - boolean createdNSScope = false; - name = reader.getLocalName(); - ns_uri = reader.getNamespaceURI(); - prefix = reader.getPrefix(); - - if (prefix != null && prefix.length() == 0) - prefix = null; - tName = new QName(ns_uri, prefix, name); - tok = new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope); - - for (int i = 0; i < reader.getNamespaceCount(); i++) { - String namespacePrefix = reader.getNamespacePrefix(i); - String namespaceUri = reader.getNamespaceURI(i); - XQName q; - if (namespacePrefix == null) - q = new QName(null, "xmlns"); - else - q = new QName("xmlns", namespacePrefix); - boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, q, namespaceUri); - if (newOpened && !createdNSScope) - tok = new ElementToken(Type.START_TAG, tok.getNodeId(), tName, curNsScope); - } - - for (int i = 0, n = reader.getAttributeCount(); i < n; ++i) { - javax.xml.namespace.QName qName = reader.getAttributeName(i); - name = qName.getLocalPart(); - ns_uri = qName.getNamespaceURI(); - prefix = qName.getPrefix(); - - - - if (prefix.length() == 0) - prefix = null; - XQName q = new QName(ns_uri, prefix, name); - String value = reader.getAttributeValue(i); - - String attType = reader.getAttributeType(i); - - if (!foundId && (attType.equals("ID") || isXMLId(tName,q))) { - foundId = true; - xmlId = value; - } - if (!foundIdREFS && (attType.equals("IDREF") || isIDREF(tName,q))) { - foundIdREFS = true; - xmlIdREFS = new String[]{value}; - } - - if (!foundIdREFS && (attType.equals("IDREFS") || isIDREFS(tName,q))) { - foundIdREFS = true; - xmlIdREFS = Utils.split(value," ", false); - } - - - boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, q, value); - if (newOpened && !createdNSScope) - tok = new ElementToken(Type.START_TAG, tok.getNodeId(), tName, curNsScope); - - if (q.getNamespacePrefix() == null || q.getNamespacePrefix().equals("")) { - if (q.getLocalPart().equals("xmlns")) - continue; - } else if (q.getNamespacePrefix().equals("xmlns")) - continue; - NamedToken attToken = createAttributeToken(Type.UNTYPED_ATOMIC, value, q, curNsScope); - tokensList.add(attToken); - - if (foundId) { - NamedToken nmToken = (NamedToken) tok ; - nmToken.setID(xmlId); - } - if (foundIdREFS) { - NamedToken nmToken = (NamedToken) tok; - nmToken.setIDREFS(xmlIdREFS); - } - - - } - break; - default: - } - if (reader.hasNext()) - reader.next(); - else { - endOfSeq = true; - } - return tok; - } catch (XMLStreamException e) { - e.printStackTrace(); - } catch (MXQueryException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - try { - reader.close(); - } catch (XMLStreamException se) { - // TODO Auto-generated catch block - se.printStackTrace(); - } - } - return Token.END_SEQUENCE_TOKEN; - } - - public TokenInterface next() throws MXQueryException { - if (!tokensList.isEmpty()) { - TokenInterface tok = (TokenInterface) tokensList.removeFirst(); - return tok;//(Token) tokensList.remove(); - } - else { - TokenInterface tok = getNext(); - return tok; - } - } - - protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { - XDMImportAdapter res = new NonValidatingStaxAdapter(context, loc, reader); - res.uri = uri; - return res; - } -} +/* Copyright 2006 - 2009 ETH Zurich + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.mxquery.xdmio.xmlAdapters; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Vector; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.QName; +import ch.ethz.mxquery.datamodel.XQName; +import ch.ethz.mxquery.datamodel.types.Type; +import ch.ethz.mxquery.datamodel.xdm.CommentToken; +import ch.ethz.mxquery.datamodel.xdm.ElementToken; +import ch.ethz.mxquery.datamodel.xdm.NamedToken; +import ch.ethz.mxquery.datamodel.xdm.ProcessingInstrToken; +import ch.ethz.mxquery.datamodel.xdm.TextToken; +import ch.ethz.mxquery.datamodel.xdm.Token; +import ch.ethz.mxquery.datamodel.xdm.TokenInterface; +import ch.ethz.mxquery.exceptions.MXQueryException; +import ch.ethz.mxquery.exceptions.QueryLocation; +import ch.ethz.mxquery.model.XDMIterator; +import ch.ethz.mxquery.util.Utils; + +public class NonValidatingStaxAdapter extends XDMImportAdapter { + private XMLStreamReader reader; + private HashMap qNamePool = new HashMap(); + private LinkedList tokensList; + + public NonValidatingStaxAdapter(Context ctx, QueryLocation loc, XMLStreamReader reader) { + super(ctx, loc); + this.reader = reader; + this.tokensList = new LinkedList(); + } + + private TokenInterface getNext() { + TokenInterface tok = Token.END_SEQUENCE_TOKEN; + if (endOfSeq) + return tok; + try { + int event = reader.getEventType(); + switch (event) { + case XMLStreamConstants.ATTRIBUTE: + break; + case XMLStreamConstants.DTD: + break; + case XMLStreamConstants.CDATA: + case XMLStreamConstants.CHARACTERS: + case XMLStreamConstants.SPACE: + { + String text = reader.getText(); + reader.next(); + event = reader.getEventType(); + if (event == XMLStreamConstants.CDATA || event == XMLStreamConstants.SPACE || event == XMLStreamConstants.CHARACTERS) { + StringBuffer mergedText = new StringBuffer(text); + while (event == XMLStreamConstants.CDATA || event == XMLStreamConstants.SPACE || event == XMLStreamConstants.CHARACTERS) { + mergedText.append(reader.getText()); + reader.next(); + event = reader.getEventType(); + } + text = mergedText.toString(); + } + return new TextToken(Type.TEXT_NODE_UNTYPED_ATOMIC, createNextTokenId(Type.TEXT_NODE_UNTYPED_ATOMIC, null), text,curNsScope); + } + case XMLStreamConstants.COMMENT: + tok = new CommentToken(createNextTokenId(Type.COMMENT, null), reader.getText(),curNsScope); + break; + case XMLStreamConstants.END_DOCUMENT: + tok = new Token(Type.END_DOCUMENT,null,curNsScope); + break; + case XMLStreamConstants.END_ELEMENT: + XQName tName = transformQName(reader.getName()); + tok = new ElementToken(Type.END_TAG, null, tName, curNsScope); + checkCloseNsScope(); + level--; + break; + case XMLStreamConstants.ENTITY_DECLARATION: // not used + break; + case XMLStreamConstants.ENTITY_REFERENCE: + break; + case XMLStreamConstants.NAMESPACE: + break; + case XMLStreamConstants.NOTATION_DECLARATION: + tok = new TextToken(createNextTokenId(Type.NOTATION, null), reader.getText()); + break; + case XMLStreamConstants.PROCESSING_INSTRUCTION: + tok = new ProcessingInstrToken(createNextTokenId(Type.PROCESSING_INSTRUCTION, null), reader.getPIData(), reader.getPITarget(),curNsScope); + break; + case XMLStreamConstants.START_DOCUMENT: + tok = new Token(Type.START_DOCUMENT,createNextTokenId(Type.START_DOCUMENT, null),curNsScope); + break; + case XMLStreamConstants.START_ELEMENT: + level++; + + boolean foundId = false; + boolean foundIdREFS = false; + + String xmlId = null; + String [] xmlIdREFS = null; + + boolean createdNSScope = false; + tName = transformQName(reader.getName()); + tok = new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope); + + for (int i = 0; i < reader.getNamespaceCount(); i++) { + String namespacePrefix = reader.getNamespacePrefix(i); + String namespaceUri = reader.getNamespaceURI(i); + XQName q; + if (namespacePrefix == null) + q = new QName(null, "xmlns"); + else + q = new QName("xmlns", namespacePrefix); + boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, q, namespaceUri); + if (newOpened && !createdNSScope) + tok = new ElementToken(Type.START_TAG, tok.getNodeId(), tName, curNsScope); + } + + for (int i = 0, n = reader.getAttributeCount(); i < n; ++i) { + javax.xml.namespace.QName qName = reader.getAttributeName(i); + XQName q = transformQName(qName); + String value = reader.getAttributeValue(i); + + String attType = reader.getAttributeType(i); + + if (!foundId && (attType.equals("ID") || isXMLId(tName,q))) { + foundId = true; + xmlId = value; + } + if (!foundIdREFS && (attType.equals("IDREF") || isIDREF(tName,q))) { + foundIdREFS = true; + xmlIdREFS = new String[]{value}; + } + + if (!foundIdREFS && (attType.equals("IDREFS") || isIDREFS(tName,q))) { + foundIdREFS = true; + xmlIdREFS = Utils.split(value," ", false); + } + + + boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, q, value); + if (newOpened && !createdNSScope) + tok = new ElementToken(Type.START_TAG, tok.getNodeId(), tName, curNsScope); + + if (q.getNamespacePrefix() == null || q.getNamespacePrefix().equals("")) { + if (q.getLocalPart().equals("xmlns")) + continue; + } else if (q.getNamespacePrefix().equals("xmlns")) + continue; + NamedToken attToken = createAttributeToken(Type.UNTYPED_ATOMIC, value, q, curNsScope); + tokensList.add(attToken); + + if (foundId) { + NamedToken nmToken = (NamedToken) tok ; + nmToken.setID(xmlId); + } + if (foundIdREFS) { + NamedToken nmToken = (NamedToken) tok; + nmToken.setIDREFS(xmlIdREFS); + } + + + } + break; + default: + } + if (reader.hasNext()) + reader.next(); + else { + endOfSeq = true; + } + return tok; + } catch (XMLStreamException e) { + e.printStackTrace(); + } catch (MXQueryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + try { + reader.close(); + } catch (XMLStreamException se) { + // TODO Auto-generated catch block + se.printStackTrace(); + } + } + return Token.END_SEQUENCE_TOKEN; + } + + public TokenInterface next() throws MXQueryException { + if (!tokensList.isEmpty()) { + TokenInterface tok = (TokenInterface) tokensList.removeFirst(); + return tok;//(Token) tokensList.remove(); + } + else { + TokenInterface tok = getNext(); + return tok; + } + } + + protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { + XDMImportAdapter res = new NonValidatingStaxAdapter(context, loc, reader); + res.uri = uri; + return res; + } + + QName transformQName(javax.xml.namespace.QName qn) { +// if (qNamePool.containsKey(qn)) { +// return (QName)qNamePool.get(qn); +// } + String prefix = qn.getPrefix(); + if (prefix != null && prefix.length() == 0) + prefix = null; + QName q = new QName(qn.getNamespaceURI(),prefix,qn.getLocalPart()); +// qNamePool.put(qn, q); + return q; + } + + protected void freeResources(boolean restartable) + throws MXQueryException { + super.freeResources(restartable); + if (!restartable) + qNamePool.clear(); + } + +} Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -58,6 +58,7 @@ import ch.ethz.mxquery.datamodel.xdm.YearMonthDurAttrToken; import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.QueryLocation; +import ch.ethz.mxquery.model.DataflowAnalysis; import ch.ethz.mxquery.model.Iterator; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.Stack; @@ -72,7 +73,7 @@ protected String uri; protected short level = 0; protected Identifier last_id; - private boolean generateNodeIds = true; + private boolean generateNodeIds = false; protected String systemid = null; protected String publicid = null; protected String dtdRootElem = null; @@ -307,4 +308,13 @@ public void setProjectionPaths(Vector paths) { } + + public XDMIterator require(int requiredOptions) throws MXQueryException { + if ((requiredOptions & DataflowAnalysis.NODEID_ORDER) != 0) + generateNodeIds = true; + return super.require(requiredOptions); + } + + + } Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/Doc.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/Doc.java 2012-03-12 07:31:44 UTC (rev 4534) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/Doc.java 2012-03-12 08:47:44 UTC (rev 4535) @@ -55,7 +55,8 @@ private boolean inValidateExpression = false; private boolean tidyInput = false; private String docURI = null; - private NodeStoreIterator baseIterator = null; + private NodeStoreIterator baseIterator = null; + private int requiredOptions = 0; //private Reader rd = null; // keep around to close public Doc() { @@ -138,6 +139,7 @@ copy.setTidyInput(this.tidyInput); copy.setConstModePreserve(this.constModePreserve); copy.setSubIters(subIters); + copy.requiredOptions = requiredOptions; return copy; } @@ -188,5 +190,10 @@ else return null; } + + public XDMIterator require(int requiredOptions) throws MXQueryException { + this.requiredOptions = requiredOptions; + return super.require(requiredOptions); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-03-12 07:31:55
|
Revision: 4534 http://mxquery.svn.sourceforge.net/mxquery/?rev=4534&view=rev Author: pm_fischer Date: 2012-03-12 07:31:44 +0000 (Mon, 12 Mar 2012) Log Message: ----------- - push duplicate elimination of projection paths into PreparedStatementImpl Modified Paths: -------------- trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java =================================================================== --- trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-03-12 06:39:25 UTC (rev 4533) +++ trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-03-12 07:31:44 UTC (rev 4534) @@ -19,6 +19,7 @@ import java.util.Enumeration; import ch.ethz.mxquery.util.Hashtable; import ch.ethz.mxquery.util.ObjectObjectPair; +import ch.ethz.mxquery.util.Set; import java.util.Vector; @@ -28,6 +29,8 @@ import ch.ethz.mxquery.exceptions.StaticException; import ch.ethz.mxquery.iterators.TokenIterator; import ch.ethz.mxquery.datamodel.QName; +import ch.ethz.mxquery.datamodel.XQName; +import ch.ethz.mxquery.model.AbstractStep; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.model.Window; import ch.ethz.mxquery.model.VariableHolder; @@ -176,12 +179,66 @@ public Hashtable getProjectionPaths() throws StaticException { //Preliminary implementation, producing just a single doc + // Eliminate duplicate paths + Set distPaths = new Set(); + ObjectObjectPair paths = iter.getProjectionPaths(); + Set returned = (Set) paths.getFirst(); + Set used = (Set) paths.getSecond(); + + Set distReturned = new Set(); + Enumeration en = returned.elements(); + + while (en.hasMoreElements()) { + Vector curPath = (Vector) en.nextElement(); + String curPathSum = translateProjectionPath(curPath)+" #"; + if (!distPaths.contains(curPathSum)) { + distPaths.add(curPathSum); + distReturned.add(curPath); + } + } + + Set distUsed = new Set(); + + en = used.elements(); + while (en.hasMoreElements()) { + Vector curPath = (Vector) en.nextElement(); + String curPathSum = translateProjectionPath(curPath); + if (!distPaths.contains(curPathSum)) { + distPaths.add(curPathSum); + distUsed.add(curPath); + } + } + + Hashtable ht = new Hashtable(); - ht.put("DOC", paths); + ht.put("DOC", new ObjectObjectPair(distReturned, distUsed)); return ht; } + private String translateProjectionPath(Vector curPath) throws StaticException { + StringBuffer pathString = new StringBuffer(); + for (int i=0;i<curPath.size();i++) { + AbstractStep as = (AbstractStep)curPath.elementAt(i); + if (as == AbstractStep.ROOT_STEP) + pathString.append("/"); + else if (as == AbstractStep.KEEP_SUBTREE) + pathString.append(" #"); + else + { + pathString.append(as.getDirectionString(true)); + XQName xq = as.getNodeTest().getXQName(); + if (xq != null) + // TODO: What about namespace URIs? + pathString.append(xq.toString()); + else throw new StaticException(ErrorCodes.A0002_EC_NOT_SUPPORTED,"Unsupported node test for projection - please report",QueryLocation.OUTSIDE_QUERY_LOC); + if (i<curPath.size()-2 || ( (AbstractStep)curPath.elementAt(curPath.size()-1) != AbstractStep.KEEP_SUBTREE && i<curPath.size()-1) ) + pathString.append("/"); + } + } + return pathString.toString(); + }; + public void setProjectionInformation(QName varname, ObjectObjectPair paths) throws StaticException { VariableHolder vh = ctx.getVariable(varname); Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-03-12 06:39:25 UTC (rev 4533) +++ trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-03-12 07:31:44 UTC (rev 4534) @@ -18,6 +18,7 @@ import ch.ethz.mxquery.util.Hashtable; import ch.ethz.mxquery.util.ObjectObjectPair; +import ch.ethz.mxquery.util.Set; import java.util.Vector; @@ -32,6 +33,7 @@ import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.StaticException; +import ch.ethz.mxquery.model.AbstractStep; import ch.ethz.mxquery.model.VariableHolder; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.query.PreparedStatement; @@ -185,16 +187,70 @@ public Hashtable getProjectionPaths() throws StaticException { //Preliminary implementation, producing just a single doc + // Eliminate duplicate paths + Set distPaths = new Set(); + ObjectObjectPair paths = iter.getProjectionPaths(); + Set returned = (Set) paths.getFirst(); + Set used = (Set) paths.getSecond(); + + Set distReturned = new Set(); + Enumeration en = returned.elements(); + + while (en.hasMoreElements()) { + Vector curPath = (Vector) en.nextElement(); + String curPathSum = translateProjectionPath(curPath)+" #"; + if (!distPaths.contains(curPathSum)) { + distPaths.add(curPathSum); + distReturned.add(curPath); + } + } + + Set distUsed = new Set(); + + en = used.elements(); + while (en.hasMoreElements()) { + Vector curPath = (Vector) en.nextElement(); + String curPathSum = translateProjectionPath(curPath); + if (!distPaths.contains(curPathSum)) { + distPaths.add(curPathSum); + distUsed.add(curPath); + } + } + + Hashtable ht = new Hashtable(); - ht.put("DOC", paths); + ht.put("DOC", new ObjectObjectPair(distReturned, distUsed)); return ht; } + private String translateProjectionPath(Vector curPath) throws StaticException { + StringBuffer pathString = new StringBuffer(); + for (int i=0;i<curPath.size();i++) { + AbstractStep as = (AbstractStep)curPath.elementAt(i); + if (as == AbstractStep.ROOT_STEP) + pathString.append("/"); + else if (as == AbstractStep.KEEP_SUBTREE) + pathString.append(" #"); + else + { + pathString.append(as.getDirectionString(true)); + XQName xq = as.getNodeTest().getXQName(); + if (xq != null) + // TODO: What about namespace URIs? + pathString.append(xq.toString()); + else throw new StaticException(ErrorCodes.A0002_EC_NOT_SUPPORTED,"Unsupported node test for projection - please report",QueryLocation.OUTSIDE_QUERY_LOC); + if (i<curPath.size()-2 || ( (AbstractStep)curPath.elementAt(curPath.size()-1) != AbstractStep.KEEP_SUBTREE && i<curPath.size()-1) ) + pathString.append("/"); + } + } + return pathString.toString(); + }; + public void setProjectionInformation(QName varname, ObjectObjectPair paths) throws StaticException { VariableHolder vh = ctx.getVariable(varname); vh.setProjectionPaths(paths); } - + } Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-03-12 06:39:25 UTC (rev 4533) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-03-12 07:31:44 UTC (rev 4534) @@ -16,7 +16,9 @@ import ch.ethz.mxquery.util.Hashtable; import ch.ethz.mxquery.util.ObjectObjectPair; +import ch.ethz.mxquery.util.Set; +import java.util.Enumeration; import java.util.Vector; import com.google.gwt.dom.client.Document; @@ -33,6 +35,7 @@ import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.StaticException; +import ch.ethz.mxquery.model.AbstractStep; import ch.ethz.mxquery.model.VariableHolder; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.query.PreparedStatement; @@ -180,12 +183,66 @@ } public Hashtable getProjectionPaths() throws StaticException { //Preliminary implementation, producing just a single doc + // Eliminate duplicate paths + Set distPaths = new Set(); + ObjectObjectPair paths = iter.getProjectionPaths(); + Set returned = (Set) paths.getFirst(); + Set used = (Set) paths.getSecond(); + + Set distReturned = new Set(); + Enumeration en = returned.elements(); + + while (en.hasMoreElements()) { + Vector curPath = (Vector) en.nextElement(); + String curPathSum = translateProjectionPath(curPath)+" #"; + if (!distPaths.contains(curPathSum)) { + distPaths.add(curPathSum); + distReturned.add(curPath); + } + } + + Set distUsed = new Set(); + + en = used.elements(); + while (en.hasMoreElements()) { + Vector curPath = (Vector) en.nextElement(); + String curPathSum = translateProjectionPath(curPath); + if (!distPaths.contains(curPathSum)) { + distPaths.add(curPathSum); + distUsed.add(curPath); + } + } + + Hashtable ht = new Hashtable(); - ht.put("DOC", paths); + ht.put("DOC", new ObjectObjectPair(distReturned, distUsed)); return ht; - } + } + private String translateProjectionPath(Vector curPath) throws StaticException { + StringBuffer pathString = new StringBuffer(); + for (int i=0;i<curPath.size();i++) { + AbstractStep as = (AbstractStep)curPath.elementAt(i); + if (as == AbstractStep.ROOT_STEP) + pathString.append("/"); + else if (as == AbstractStep.KEEP_SUBTREE) + pathString.append(" #"); + else + { + pathString.append(as.getDirectionString(true)); + XQName xq = as.getNodeTest().getXQName(); + if (xq != null) + // TODO: What about namespace URIs? + pathString.append(xq.toString()); + else throw new StaticException(ErrorCodes.A0002_EC_NOT_SUPPORTED,"Unsupported node test for projection - please report",QueryLocation.OUTSIDE_QUERY_LOC); + if (i<curPath.size()-2 || ( (AbstractStep)curPath.elementAt(curPath.size()-1) != AbstractStep.KEEP_SUBTREE && i<curPath.size()-1) ) + pathString.append("/"); + } + } + return pathString.toString(); + }; + public void setProjectionInformation(QName varname, ObjectObjectPair paths) throws StaticException { VariableHolder vh = ctx.getVariable(varname); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-03-12 06:39:31
|
Revision: 4533 http://mxquery.svn.sourceforge.net/mxquery/?rev=4533&view=rev Author: pm_fischer Date: 2012-03-12 06:39:25 +0000 (Mon, 12 Mar 2012) Log Message: ----------- - data flow analysis for node id requirements - small performance improvements for child - suppress logging output in parser Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Put.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/CompareIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/DocOrderIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/ExceptIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/IntersectIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/UnionIterator.java trunk/MXQuery/src/ch/ethz/mxquery/model/CurrentBasedIterator.java trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Put.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Put.java 2012-03-02 10:01:31 UTC (rev 4532) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Put.java 2012-03-12 06:39:25 UTC (rev 4533) @@ -91,7 +91,7 @@ File fn = new File(uri); UpdateableStore putStore = null; - if (!(targetID.getStore() instanceof UpdateableStore)) + if (targetID == null || !(targetID.getStore() instanceof UpdateableStore)) { putStore = nodeParam.getContext().getStores().createUpdateableStore(uri.toString(),nodeParam,true, true); putStore.materialize(); Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-03-02 10:01:31 UTC (rev 4532) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-03-12 06:39:25 UTC (rev 4533) @@ -122,25 +122,25 @@ this.called++; TokenInterface tok = Token.START_SEQUENCE_TOKEN; - int type = tok.getEventType(); - while (type != Type.END_SEQUENCE) { + //int type = tok.getEventType(); + curEventType = Type.START_SEQUENCE; + while (curEventType != Type.END_SEQUENCE) { // next on child iterator tok = getNext(); - type = tok.getEventType(); - if (type == Type.END_SEQUENCE) + if (curEventType == Type.END_SEQUENCE) return tok; - if (!Type.isNode(type)) + if (!Type.isNode(curEventType)) throw new TypeException(ErrorCodes.E0019_TYPE_STEP_RESULT_IS_ATOMIC, "Child axis applied on non-node",loc ); - if (depth == 1 && tok.getEventType() == Type.START_TAG || tok.getEventType() == Type.START_DOCUMENT) + if (depth == 1 && curEventType == Type.START_TAG || curEventType == Type.START_DOCUMENT) newParent = true; int targetDepth = 1; if (match) { // if current node is already matching the child // condition - if (type == Type.END_TAG && depth == targetDepth + if (curEventType == Type.END_TAG && depth == targetDepth && (tok.getName().equals(lastStep))) { // child // if the current depth is equal to initial depth, it's the // end of the matching sequence @@ -163,19 +163,18 @@ continue; break; case Type.TYPE_NK_ANY_NODE_TEST: - if (boundNode == null && (type == Type.START_DOCUMENT || type == Type.START_TAG)) { + if (boundNode == null && (curEventType == Type.START_DOCUMENT || curEventType == Type.START_TAG)) { boundNode = tok; tok = getNext(); - type = tok.getEventType(); } if (depth == 0) boundNode = null; - if ((depth != targetDepth && depth != targetDepth+1) || Type.isAttribute(tok.getEventType()) || !CheckNodeType.checkNode(tok)) + if ((depth != targetDepth && depth != targetDepth+1) || Type.isAttribute(curEventType) || !CheckNodeType.checkNode(tok)) continue; - else if (type == Type.START_TAG) + else if (curEventType == Type.START_TAG) match = true; // set match flag to true if there is nested content // skip over the bound node's END token - if (depth == 1 && type == Type.END_TAG && boundNode != null && boundNode.getName() != null && boundNode.getName().equals(tok.getName())) + if (depth == 1 && curEventType == Type.END_TAG && boundNode != null && boundNode.getName() != null && boundNode.getName().equals(tok.getName())) continue; break; @@ -184,9 +183,8 @@ while (depth == 1) { tok = getNext(); } - type = tok.getEventType(); - if (depth != targetDepth || type != Type.START_TAG + if (depth != targetDepth || curEventType != Type.START_TAG || (!CheckNodeType.step_comparison(tok,step_uri,step_local))) continue; else { Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/CompareIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/CompareIterator.java 2012-03-02 10:01:31 UTC (rev 4532) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/CompareIterator.java 2012-03-12 06:39:25 UTC (rev 4533) @@ -31,6 +31,7 @@ import ch.ethz.mxquery.exceptions.StaticException; import ch.ethz.mxquery.exceptions.TypeException; import ch.ethz.mxquery.model.Constants; +import ch.ethz.mxquery.model.DataflowAnalysis; import ch.ethz.mxquery.model.TokenBasedIterator; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.KXmlSerializer; @@ -334,5 +335,11 @@ return new ObjectObjectPair(returned, used); } + public XDMIterator require(int requiredOptions) throws MXQueryException { + if (compareType == Constants.COMP_NODE) + requiredOptions = requiredOptions | DataflowAnalysis.NODEID_ORDER; + return super.require(requiredOptions); + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/DocOrderIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/DocOrderIterator.java 2012-03-02 10:01:31 UTC (rev 4532) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/DocOrderIterator.java 2012-03-12 06:39:25 UTC (rev 4533) @@ -29,7 +29,9 @@ import ch.ethz.mxquery.exceptions.ErrorCodes; import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.QueryLocation; +import ch.ethz.mxquery.model.Constants; import ch.ethz.mxquery.model.CurrentBasedIterator; +import ch.ethz.mxquery.model.DataflowAnalysis; import ch.ethz.mxquery.model.Window; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.QuickSort; @@ -174,5 +176,8 @@ return new MXQueryDouble(0); } + public XDMIterator require(int requiredOptions) throws MXQueryException { + return super.require(requiredOptions | DataflowAnalysis.NODEID_ORDER); + } } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/ExceptIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/ExceptIterator.java 2012-03-02 10:01:31 UTC (rev 4532) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/ExceptIterator.java 2012-03-12 06:39:25 UTC (rev 4533) @@ -27,6 +27,7 @@ import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.TypeException; import ch.ethz.mxquery.model.CurrentBasedIterator; +import ch.ethz.mxquery.model.DataflowAnalysis; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.Set; @@ -158,4 +159,10 @@ protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { return new ExceptIterator(context, subIters[0], subIters[1], loc); } + + public XDMIterator require(int requiredOptions) throws MXQueryException { + return super.require(requiredOptions | DataflowAnalysis.NODEID_ORDER); + } + + } \ No newline at end of file Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/IntersectIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/IntersectIterator.java 2012-03-02 10:01:31 UTC (rev 4532) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/IntersectIterator.java 2012-03-12 06:39:25 UTC (rev 4533) @@ -26,6 +26,7 @@ import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.TypeException; import ch.ethz.mxquery.model.CurrentBasedIterator; +import ch.ethz.mxquery.model.DataflowAnalysis; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.Set; @@ -136,4 +137,9 @@ protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { return new IntersectIterator(context, subIters[0], subIters[1],loc); } + + public XDMIterator require(int requiredOptions) throws MXQueryException { + return super.require(requiredOptions | DataflowAnalysis.NODEID_ORDER); + } + } \ No newline at end of file Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/UnionIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/UnionIterator.java 2012-03-02 10:01:31 UTC (rev 4532) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/UnionIterator.java 2012-03-12 06:39:25 UTC (rev 4533) @@ -26,6 +26,7 @@ import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.TypeException; import ch.ethz.mxquery.model.CurrentBasedIterator; +import ch.ethz.mxquery.model.DataflowAnalysis; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.Set; @@ -167,4 +168,9 @@ Vector nestedPredCtxStack) throws MXQueryException { return new UnionIterator(context, subIters[0], subIters[1], loc); } + + public XDMIterator require(int requiredOptions) throws MXQueryException { + return super.require(requiredOptions | DataflowAnalysis.NODEID_ORDER); + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/model/CurrentBasedIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/model/CurrentBasedIterator.java 2012-03-02 10:01:31 UTC (rev 4532) +++ trunk/MXQuery/src/ch/ethz/mxquery/model/CurrentBasedIterator.java 2012-03-12 06:39:25 UTC (rev 4533) @@ -25,7 +25,7 @@ public abstract class CurrentBasedIterator extends Iterator { protected XDMIterator current = null; - + protected int curEventType = Type.END_SEQUENCE; public CurrentBasedIterator(){ this(null, null, null); } @@ -45,10 +45,10 @@ protected TokenInterface getNext() throws MXQueryException { TokenInterface tok = current.next(); - int i = tok.getEventType(); - if (i == Type.START_TAG || i == Type.START_DOCUMENT) { + curEventType = tok.getEventType(); + if (curEventType == Type.START_TAG || curEventType == Type.START_DOCUMENT) { depth++; - } else if (i == Type.END_TAG || i == Type.END_DOCUMENT) { + } else if (curEventType == Type.END_TAG || curEventType == Type.END_DOCUMENT) { depth--; } Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2012-03-02 10:01:31 UTC (rev 4532) +++ trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2012-03-12 06:39:25 UTC (rev 4533) @@ -371,8 +371,8 @@ CompilerOptions co, Hashtable options, String locationInfo, Object queryVersion) throws MXQueryException { long parseTime = 0; - if (logger.isLoggable(LogLevel.INFO)) { - logger.log(LogLevel.INFO,"Parsing started"); + if (logger.isLoggable(LogLevel.FINE)) { + logger.log(LogLevel.FINE,"Parsing started"); parseTime = System.currentTimeMillis(); } this.query = query; @@ -392,9 +392,9 @@ } Iterator result = Module(); - if (logger.isLoggable(LogLevel.INFO)) { + if (logger.isLoggable(LogLevel.FINE)) { long parseDuration = System.currentTimeMillis() - parseTime; - logger.log(LogLevel.INFO,"Parsing completed, took "+parseDuration+ " ms"); + logger.log(LogLevel.FINE,"Parsing completed, took "+parseDuration+ " ms"); } if (result != null) { if (index < queryLen) { @@ -1748,7 +1748,7 @@ } getCurrentContext().addFunction(fn); - logger.log(LogLevel.INFO, "Completed parsing function "+qname.toString()+ " took "+(System.currentTimeMillis()-startTime)); + logger.log(LogLevel.FINE, "Completed parsing function "+qname.toString()+ " took "+(System.currentTimeMillis()-startTime)); return true; } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-03-02 10:01:38
|
Revision: 4532 http://mxquery.svn.sourceforge.net/mxquery/?rev=4532&view=rev Author: pm_fischer Date: 2012-03-02 10:01:31 +0000 (Fri, 02 Mar 2012) Log Message: ----------- - moved readString method from Utils to PlatformDependentUtils, as InputStream is not available on GWT - unified Utils.java for all platforms, brought encoding fix to XQIB Modified Paths: -------------- trunk/MXQuery/altsrc/ch/ethz/mxquery/util/PlatformDependentUtils.java trunk/MXQuery/midp_src/ch/ethz/mxquery/util/PlatformDependentUtils.java trunk/MXQuery/src/ch/ethz/mxquery/sms/ftstore/LinguisticTokenGenerator.java trunk/MXQuery/src/ch/ethz/mxquery/sms/ftstore/WordNetRemoteThesaurus.java trunk/MXQuery/src/ch/ethz/mxquery/util/PlatformDependentUtils.java trunk/MXQuery/src/ch/ethz/mxquery/util/Utils.java Removed Paths: ------------- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/Utils.java Modified: trunk/MXQuery/altsrc/ch/ethz/mxquery/util/PlatformDependentUtils.java =================================================================== --- trunk/MXQuery/altsrc/ch/ethz/mxquery/util/PlatformDependentUtils.java 2012-02-08 17:17:09 UTC (rev 4531) +++ trunk/MXQuery/altsrc/ch/ethz/mxquery/util/PlatformDependentUtils.java 2012-03-02 10:01:31 UTC (rev 4532) @@ -16,6 +16,8 @@ package ch.ethz.mxquery.util; import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import ch.ethz.mxquery.util.PrintStream; import java.io.UnsupportedEncodingException; @@ -142,5 +144,22 @@ return new MXQueryDateTime(cal, tz.getRawOffset() / (1000 * 60), MXQueryDateTime.VALUE_TYPE_DATE_TIME); } + + public static String readString(InputStream is) { + String text; + // Extract data in 256 byte chunks. + try { + byte[] data = new byte[256]; + int len = 0; + StringBuffer raw = new StringBuffer(); + while ( -1 != (len = is.read(data)) ) { + raw.append(new String(data, 0, len)); + } + text = raw.toString(); + } catch (IOException ex) { + text = ex.toString(); + }; + return text; + } } Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/util/PlatformDependentUtils.java =================================================================== --- trunk/MXQuery/midp_src/ch/ethz/mxquery/util/PlatformDependentUtils.java 2012-02-08 17:17:09 UTC (rev 4531) +++ trunk/MXQuery/midp_src/ch/ethz/mxquery/util/PlatformDependentUtils.java 2012-03-02 10:01:31 UTC (rev 4532) @@ -16,6 +16,8 @@ package ch.ethz.mxquery.util; import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import ch.ethz.mxquery.util.PrintStream; import java.io.UnsupportedEncodingException; @@ -113,5 +115,22 @@ return new MXQueryDateTime(cal, tz.getRawOffset() / (1000 * 60), MXQueryDateTime.VALUE_TYPE_DATE_TIME); } - + + public static String readString(InputStream is) { + String text; + // Extract data in 256 byte chunks. + try { + byte[] data = new byte[256]; + int len = 0; + StringBuffer raw = new StringBuffer(); + while ( -1 != (len = is.read(data)) ) { + raw.append(new String(data, 0, len)); + } + text = raw.toString(); + } catch (IOException ex) { + text = ex.toString(); + }; + return text; + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/sms/ftstore/LinguisticTokenGenerator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/sms/ftstore/LinguisticTokenGenerator.java 2012-02-08 17:17:09 UTC (rev 4531) +++ trunk/MXQuery/src/ch/ethz/mxquery/sms/ftstore/LinguisticTokenGenerator.java 2012-03-02 10:01:31 UTC (rev 4532) @@ -24,6 +24,7 @@ import ch.ethz.mxquery.datamodel.xdm.TextToken; import ch.ethz.mxquery.exceptions.ErrorCodes; import ch.ethz.mxquery.exceptions.MXQueryException; +import ch.ethz.mxquery.util.PlatformDependentUtils; import ch.ethz.mxquery.util.Utils; /** @@ -302,7 +303,7 @@ abbrevTrie = new TrieNode(); try{ InputStream is = this.getClass().getResourceAsStream("abbreviations.txt"); - String strLine = Utils.readString(is); + String strLine = PlatformDependentUtils.readString(is); String [] words = Utils.split(strLine, "\n", false); for (int j=0;j<words.length;j++) { String currentWord = words[j].trim(); Modified: trunk/MXQuery/src/ch/ethz/mxquery/sms/ftstore/WordNetRemoteThesaurus.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/sms/ftstore/WordNetRemoteThesaurus.java 2012-02-08 17:17:09 UTC (rev 4531) +++ trunk/MXQuery/src/ch/ethz/mxquery/sms/ftstore/WordNetRemoteThesaurus.java 2012-03-02 10:01:31 UTC (rev 4532) @@ -24,6 +24,7 @@ import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.model.ft.Range; import ch.ethz.mxquery.model.ws.SoapInvoker; +import ch.ethz.mxquery.util.PlatformDependentUtils; import ch.ethz.mxquery.util.Utils; /** @@ -97,7 +98,7 @@ posTrie = new TrieNode(); InputStream is = this.getClass().getResourceAsStream("pos.txt"); - String strLine = Utils.readString(is); + String strLine = PlatformDependentUtils.readString(is); String[] triple = Utils.split(strLine, "\n", false); for (int j = 0; j < triple.length; j++) { String t = triple[j].trim(); Modified: trunk/MXQuery/src/ch/ethz/mxquery/util/PlatformDependentUtils.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/util/PlatformDependentUtils.java 2012-02-08 17:17:09 UTC (rev 4531) +++ trunk/MXQuery/src/ch/ethz/mxquery/util/PlatformDependentUtils.java 2012-03-02 10:01:31 UTC (rev 4532) @@ -16,6 +16,8 @@ package ch.ethz.mxquery.util; import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import ch.ethz.mxquery.util.PrintStream; import java.io.UnsupportedEncodingException; @@ -140,5 +142,23 @@ return new MXQueryDateTime(cal, tz.getRawOffset() / (1000 * 60), MXQueryDateTime.VALUE_TYPE_DATE_TIME); - } + } + + public static String readString(InputStream is) { + String text; + // Extract data in 256 byte chunks. + try { + byte[] data = new byte[256]; + int len = 0; + StringBuffer raw = new StringBuffer(); + while ( -1 != (len = is.read(data)) ) { + raw.append(new String(data, 0, len)); + } + text = raw.toString(); + } catch (IOException ex) { + text = ex.toString(); + }; + return text; + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/util/Utils.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/util/Utils.java 2012-02-08 17:17:09 UTC (rev 4531) +++ trunk/MXQuery/src/ch/ethz/mxquery/util/Utils.java 2012-03-02 10:01:31 UTC (rev 4532) @@ -63,24 +63,7 @@ return strs; } - - public static String readString(InputStream is) { - String text; - // Extract data in 256 byte chunks. - try { - byte[] data = new byte[256]; - int len = 0; - StringBuffer raw = new StringBuffer(); - while ( -1 != (len = is.read(data)) ) { - raw.append(new String(data, 0, len)); - } - text = raw.toString(); - } catch (IOException ex) { - text = ex.toString(); - }; - return text; - } - + /** * Splits a string into an array of Strings * @param source The source string Deleted: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/Utils.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/Utils.java 2012-02-08 17:17:09 UTC (rev 4531) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/Utils.java 2012-03-02 10:01:31 UTC (rev 4532) @@ -1,524 +0,0 @@ -/* Copyright 2006 - 2009 ETH Zurich - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.ethz.mxquery.util; - -import java.io.IOException; -//import java.io.InputStream; -import java.util.Vector; - -import ch.ethz.mxquery.sms.ftstore.DiacriticsUtils; - - -public final class Utils { - - /** - * - * @param name - full class name - * @return - class name without package name - */ - public static String getSimpleClassName(String name) { - int lastDot = name.lastIndexOf('.') + 1; - return name.substring(lastDot); - } - - /** - * Splits a string into an array of Strings - * @param source The source string - * @param delimeter The delimeter String, that seperates the parts of the sequence - * @param createEmptySegments TODO - * @return An array of all elements of the splitted sequence - */ - public static String[] split(String source, String delimeter, boolean createEmptySegments) { - int next = 0; - Vector parts = new Vector(); - - while ((next = source.indexOf(delimeter)) > -1) { - if (source.substring(0, next).length() > 0 || createEmptySegments) { - parts.addElement(source.substring(0, next)); - } - - source = source.substring(next+delimeter.length()); - } - - if (source.length() > 0) { - parts.addElement(source); - } - - String[] strs = new String[parts.size()]; - parts.copyInto(strs); - - return strs; - } - - -// public static String readString(InputStream is) { -// String text; -// // Extract data in 256 byte chunks. -// try { -// byte[] data = new byte[256]; -// int len = 0; -// StringBuffer raw = new StringBuffer(); -// while ( -1 != (len = is.read(data)) ) { -// raw.append(new String(data, 0, len)); -// } -// text = raw.toString(); -// } catch (IOException ex) { -// text = ex.toString(); -// }; -// return text; -// } - - /** - * Splits a string into an array of Strings - * @param source The source string - * @param delimiters The delimiters, that seperate the parts of the sequence - * @return An array of all elements of the splitted sequence - */ - - public static String[] split(String source, String[] delimiters){ - - int begin = 0; - Vector parts = new Vector(); - String newElement = ""; - boolean delimitersFound = false; - - for (int i= 0; i < source.length(); i++){ - - for (int j = 0; j < delimiters.length;j++){ - if (source.charAt(i)== delimiters[j].toCharArray()[0]){ - - delimitersFound = true; - - if (source.substring(begin,i).length() > 0) { - - if (begin != 0){ - - newElement = source.substring(begin+1,i); - if (newElement.trim().length() > 0){ - parts.addElement(newElement); - } - - } - else{ - newElement = source.substring(begin,i); - if (newElement.length() > 0){ - parts.addElement(newElement); - } - } - begin = i; - - } - else{ - begin = i+1; - } - } - - } - - } - - if (delimitersFound){ - if (source.length() > 0) { - parts.addElement(source.substring(begin+1)); - } - } - else{ - parts.addElement(source.substring(begin)); - } - - - String[] strs = new String[parts.size()]; - parts.copyInto(strs); - return strs; - - } - - public static String replaceAll(String original, String oldExpr, String replacement) { - String ret = ""; - int pos = 0, index; - while ((index = original.indexOf(oldExpr)) >= 0) { - ret += original.substring(pos, index); - ret += replacement; - original = original.substring(index + 1); - } - ret += original; - return ret; - } - - public static String expandCharRefs(String res) { - StringBuffer normTarget = new StringBuffer(res.length()); - int origPos = 0; - while (origPos < res.length()) { - if (res.charAt(origPos) == '&' && origPos+3 < res.length() && res.charAt(origPos+1)=='#') { - // translate remaining WS char refs in order to prevent them from being "eaten" - int endCharRef = res.indexOf(';', origPos); - if (endCharRef > 0 && endCharRef < origPos + 10) { - String toTranslate = res.substring(origPos+2,endCharRef); - int codePoint = -1; - if (toTranslate.indexOf('x') >=0) { - // Hex digits - String charRef = toTranslate.substring(1); - if (charRef.length() != 0) - codePoint = Integer.parseInt(charRef, 16); - } else { //Decimal digits - String charRef = toTranslate; - if (charRef.length() != 0) - codePoint = Integer.parseInt(charRef,10); - } - if (codePoint >= 0) { - normTarget.append(PlatformDependentUtils.codepointToChars(codePoint)); - origPos = endCharRef+1; - } else { - normTarget.append(res.charAt(origPos)); - origPos++; - } - } - } else { - normTarget.append(res.charAt(origPos)); - origPos++; - } - } - return normTarget.toString(); - } - - public static String normalizeEOL (String res, boolean useXML11Rules){ - StringBuffer normTarget = new StringBuffer(res.length()); - int origPos = 0; - while (origPos < res.length()) { - if (res.charAt(origPos) == '\r') { - if (origPos+1<res.length() && res.charAt(origPos+1) == '\n') { - origPos++; // skip - } - if (res.length() !=1) - normTarget.append('\n'); - else - normTarget.append('\r'); //\r constant - } - else - normTarget.append(res.charAt(origPos)); - origPos++; - } - return new String(normTarget); - } - - /** - * Implementation of normalization in attributes and element content - remove whitespace at beginning and end + reduce whitespace in the middle to one, but only translate xD,x9 etc. - * @param res String to be normalized - * @return the normalized String - */ - public static String normalizeStringContent (String res, boolean isIdAttr) { - StringBuffer normTarget = new StringBuffer(res.length()); - int origPos = 0; - // eat all whitespace at the beginning - while (origPos < res.length() && isWhiteSpace(res.charAt(origPos))){ - if (!isIdAttr) - normTarget.append(' '); - origPos++; - } - if (origPos == res.length() && res.length() != 0) { - return normTarget.toString(); - } - while(origPos < res.length()) { - // append non-whitespace characters - while (origPos < res.length() && !isWhiteSpace(res.charAt(origPos))) { - if (res.charAt(origPos) == '&' && origPos+3 < res.length() && res.charAt(origPos+1)=='#') { - // translate remaining WS char refs in order to prevent them from being "eaten" - int endCharRef = res.indexOf(';', origPos); - if (endCharRef > 0 && endCharRef < origPos + 10) { - String toTranslate = res.substring(origPos+2,endCharRef); - int codePoint = -1; - if (toTranslate.indexOf('x') >=0) { - // Hex digits - String charRef = toTranslate.substring(1); - if (charRef.length() != 0) - codePoint = Integer.parseInt(charRef, 16); - } else { //Decimal digits - String charRef = toTranslate; - if (charRef.length() != 0) - codePoint = Integer.parseInt(charRef,10); - } - if (codePoint >= 0) { - normTarget.append(PlatformDependentUtils.codepointToChars(codePoint)); - origPos = endCharRef+1; - } else { - normTarget.append(res.charAt(origPos)); - origPos++; - } - } - } else { - normTarget.append(res.charAt(origPos)); - origPos++; - } - } - // skip whitespaces - while (origPos < res.length() && isWhiteSpace(res.charAt(origPos))) { - normTarget.append(' '); - origPos++; - } - // append a single whitespace if not at end -// if (origPos < res.length()) -// normTarget.append(' '); - } - return normTarget.toString(); - } - - /** - * Implementation of F&O normalize-string function - remove whitespace at beginning and end + reduce whitespace in the middle to one - * @param res String to be normalized - * @return the normalized string - */ - public static String normalizeString (String res) { - StringBuffer normTarget = new StringBuffer(res.length()); - int origPos = 0; - // eat all whitespace at the beginning - while (origPos < res.length() && isWhiteSpace(res.charAt(origPos))){ - origPos++; - } - while(origPos < res.length()) { - // append non-whitespace characters - while (origPos < res.length() && !isWhiteSpace(res.charAt(origPos))) { - normTarget.append(res.charAt(origPos)); - origPos++; - } - // skip whitespaces - while (origPos < res.length() && isWhiteSpace(res.charAt(origPos))) { - origPos++; - } - // append a single whitespace if not at end - if (origPos < res.length()) - normTarget.append(' '); - } - return normTarget.toString(); - } - - public static boolean isWhiteSpace(char cToCheck) { - if (cToCheck == ' '|| cToCheck == '\r' || cToCheck == '\n' || cToCheck == '\t') { - return true; - } - return false; - } - - - public final static boolean isLetter (char ch) { - if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) - return true; - return false; - } - - public static boolean isLowerCase(String text){ - for (int i=0; i < text.length(); i++){ - int c = text.charAt(i); - if (!isLowerCaseLetter(c)){ - return false; - } - } - return true; - } - - public static boolean isUpperCase(String text){ - for (int i=0; i < text.length(); i++){ - int c = text.charAt(i); - if (!isUpperCaseLetter(c)){ - return false; - } - } - return true; - } - - public static boolean isLowerCaseLetter(int chr) { - if ((chr <= 122 && 97 <= chr) || DiacriticsUtils.isLowerCaseDiacritics(chr)) - return true; - return false; - } - - - public static boolean isUpperCaseLetter(int chr) { - if ((chr <= 90 && 65 <= chr) || DiacriticsUtils.isUpperCaseDiacritics(chr)) - return true; - return false; - } - - public static boolean sameCase(String text, String text2){ - - for (int i=0; i < text.length(); i++){ - int c = text.charAt(i); - int c2 = text2.charAt(i); - if (!((isUpperCaseLetter(c)) && (isUpperCaseLetter(c2)) || (c <= 122 && 97 <= c) && (c2 <= 122 && 97 <= c2))){ - return false; - } - } - - return true; - } - - - private static String hex(int c) { - return Integer.toHexString(c); - } - - public static String stripLeadingWhitespace(String val) { - int wsPos = 0; - while (wsPos < val.length() && isWhiteSpace(val.charAt(wsPos))) { - wsPos++; - } - if (wsPos < val.length()) - return val.substring(wsPos); - return val; - } - - /** For character encoding in URL/URI/IRI */ - - public static String getEncodedCharacter(char c) { - StringBuffer result = new StringBuffer(); - if (c < 128) { - result.append("%"); - result.append(hex(c)); - } else if (c > 127 && c < 2048) { - result.append("%"); - result.append(hex((c >> 6) | 0xC0)); - - result.append("%"); - result.append(hex((c & 0x3F) | 0x80)); - } else if (c > 2047 && c < 65536) { - result.append("%"); - result.append(hex((c >> 12) | 0xE0)); - - result.append("%"); - result.append(hex(((c >> 6) & 0x3F) | 0x80)); - - result.append("%"); - result.append(hex((c & 0x3F) | 0x80)); - } else if (c > 65535) { - result.append("%"); - result.append(hex((c >> 18) | 0xF0)); - - result.append("%"); - result.append(hex(((c >> 12) & 0x3F) | 0x80)); - - result.append("%"); - result.append(hex(((c >> 6) & 0x3F) | 0x80)); - - result.append("%"); - result.append(hex((c & 0x3F) | 0x80)); - } - - return result.toString().toUpperCase(); - } - - /** - * This method is for helping to retain the order of comparators and compareTypes - * @param i1 - * @param i2 - * @return the order relationship: 0 equals, -1 if i1<i2, -1 if i1>i2 - */ - public static int compareComparator(int i1, int i2){ - if(i1 == i2){ - return 0; - }else if (i1 < i2){ - return -1; - }else{ - return 1; - } - } - - /** - * Get the cartesian product of values - * @param combinations Helper Vector, usually empty at top-level invocation - * @param cur Helper Vector, usually empty at top-level invocation - * @param vectors Items that should be combined - * @param len Length of items to look at - * @return the certesian product of vectors with length of len - */ - public static Vector getCombinations(Vector combinations, Vector cur, Vector vectors, int len) { - if (len == vectors.size()){ - Vector newVector = new Vector(); - for (int i=0; i < cur.size(); i++){ - newVector.addElement(cur.elementAt(i)); - } - - combinations.addElement(newVector); - } - else{ - Vector vector = (Vector)vectors.elementAt(len); - if (vector.size() > 0) - for (int i=0; i < vector.size(); i++){ - cur.addElement(vector.elementAt(i)); - len = len+1; - getCombinations(combinations, cur, vectors, len); - len = len -1; - cur.removeElement(vector.elementAt(i)); - } else { - len = len+1; - getCombinations(combinations, cur, vectors, len); - len = len -1; - } - - } - return combinations; - } - - /** - * Add the contents of one vector to the second - needed for CLDC - * @param from - * @param to - * @return the content of the contents of both vectors: first the content of to, then from - */ - // add elements of vector to another vector - public static Vector addToVector(Vector from, Vector to){ - - for (int i=0; i < from.size(); i++){ - to.addElement(from.elementAt(i)); - } - - return to; - } - /** - * Add the contents of an array to a Vector - needed for CLDC - * @param from - * @param to - * @return the content of the contents of both vectors: first the content of to, then from - */ - public static Vector addArrayToVector(Object[] from, Vector to){ - if (from != null) - for (int i=0; i < from.length; i++){ - to.addElement(from[i]); - } - - return to; - } - - public static Object [] dumpVectorToArray(Vector vec) { - Object [] ret = new Object[vec.size()]; - for (int i=0;i<ret.length;i++) { - ret[i] = vec.elementAt(i); - } - return ret; - } - - - - /** for testing purposes */ - /*public static void main(String[] args){ - String test = "this"; - String[] delimiters = {",", "(", ")", ";", ".", "!","?", "{", "}","\"", "[", "]", "|", "#", "%", "&", "/", " "}; - String[] result = split(test,delimiters); - - for (int j=0; j < result.length; j++){ - System.out.println(result[j]); - } - - }*/ -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-08 17:01:20
|
Revision: 4530 http://mxquery.svn.sourceforge.net/mxquery/?rev=4530&view=rev Author: pm_fischer Date: 2012-02-08 17:01:07 +0000 (Wed, 08 Feb 2012) Log Message: ----------- restore building on Android Modified Paths: -------------- trunk/MXQuery/build.xml Modified: trunk/MXQuery/build.xml =================================================================== --- trunk/MXQuery/build.xml 2012-02-08 16:19:00 UTC (rev 4529) +++ trunk/MXQuery/build.xml 2012-02-08 17:01:07 UTC (rev 4530) @@ -1116,6 +1116,7 @@ <delete> <fileset dir="${androidtmp.dir}/ch/ethz/mxquery/xdmio/xmlAdapters/"> <include name="NonValidatingStaxAdapter.java"/> + <include name="NonValidatingStaxAdapterProjection.java"/> <include name="Token2StaxAdapter.java"/> </fileset> </delete> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-08 16:19:10
|
Revision: 4529 http://mxquery.svn.sourceforge.net/mxquery/?rev=4529&view=rev Author: pm_fischer Date: 2012-02-08 16:19:00 +0000 (Wed, 08 Feb 2012) Log Message: ----------- one more build blocker on MIDP Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2012-02-08 15:43:03 UTC (rev 4528) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2012-02-08 16:19:00 UTC (rev 4529) @@ -15,7 +15,6 @@ package ch.ethz.mxquery.xdmio.xmlAdapters; -import java.util.ArrayList; import java.util.Vector; import ch.ethz.mxquery.bindings.WindowFactory; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-08 15:43:16
|
Revision: 4528 http://mxquery.svn.sourceforge.net/mxquery/?rev=4528&view=rev Author: pm_fischer Date: 2012-02-08 15:43:03 +0000 (Wed, 08 Feb 2012) Log Message: ----------- One more attempt to fix build problems and push out all projection work Modified Paths: -------------- trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java trunk/MXQuery/src/ch/ethz/mxquery/query/PreparedStatement.java trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark02.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark03.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark04.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark05.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark06.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark07.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark08.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark09.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark10.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark11.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark12.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark13.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark14.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark15.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark16.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark17.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark18.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark19.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark20.xq Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java =================================================================== --- trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-08 15:43:03 UTC (rev 4528) @@ -181,4 +181,11 @@ ht.put("DOC", paths); return ht; } + + public void setProjectionInformation(QName varname, + ObjectObjectPair paths) throws StaticException { + VariableHolder vh = ctx.getVariable(varname); + vh.setProjectionPaths(paths); + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java 2012-02-08 15:43:03 UTC (rev 4528) @@ -760,7 +760,7 @@ while (returnedPaths.hasMoreElements()) { Vector curRetPath = (Vector)returnedPaths.nextElement(); Vector res = new Vector(); - res.addAll(curRetPath); + Utils.addToVector(curRetPath,res); res.addElement(AbstractStep.KEEP_SUBTREE); used.add(res); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java 2012-02-08 15:43:03 UTC (rev 4528) @@ -38,7 +38,9 @@ import ch.ethz.mxquery.util.KXmlSerializer; import ch.ethz.mxquery.util.ObjectObjectPair; import ch.ethz.mxquery.util.Set; +import ch.ethz.mxquery.util.Utils; + /** * Event of an Attribute Declaration in XQuery ('@attributename') * @@ -184,7 +186,7 @@ while (pathEnum.hasMoreElements()) { Vector prev = (Vector) pathEnum.nextElement(); Vector res = new Vector(); - res.addAll(prev); + Utils.addToVector(prev,res); res.addElement(new AbstractStep(AXIS_ATTRIBUTE, stepData)); returned.add(res); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-02-08 15:43:03 UTC (rev 4528) @@ -42,6 +42,7 @@ import ch.ethz.mxquery.util.LogLevel; import ch.ethz.mxquery.util.ObjectObjectPair; import ch.ethz.mxquery.util.Set; +import ch.ethz.mxquery.util.Utils; /** * @@ -274,7 +275,7 @@ while (pathEnum.hasMoreElements()) { Vector res = new Vector(); Vector prev = (Vector) pathEnum.nextElement(); - res.addAll(prev); + Utils.addToVector(prev,res); if (stepData.getXQName() != null) res.addElement(new AbstractStep(AXIS_CHILD, stepData)); else Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java 2012-02-08 15:43:03 UTC (rev 4528) @@ -45,6 +45,7 @@ import ch.ethz.mxquery.util.KXmlSerializer; import ch.ethz.mxquery.util.ObjectObjectPair; import ch.ethz.mxquery.util.Set; +import ch.ethz.mxquery.util.Utils; /** * @@ -464,7 +465,7 @@ while (pathEnum.hasMoreElements()) { Vector prev = (Vector) pathEnum.nextElement(); Vector res = new Vector(); - res.addAll(prev); + Utils.addToVector(prev,res); res.addElement(new AbstractStep(descAxis, stepData)); returned.add(res); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java 2012-02-08 15:43:03 UTC (rev 4528) @@ -48,6 +48,7 @@ import ch.ethz.mxquery.util.KXmlSerializer; import ch.ethz.mxquery.util.ObjectObjectPair; import ch.ethz.mxquery.util.Set; +import ch.ethz.mxquery.util.Utils; import ch.ethz.mxquery.util.URIUtils; /** @@ -621,7 +622,7 @@ while (returnedPaths.hasMoreElements()) { Vector curRetPath = (Vector)returnedPaths.nextElement(); Vector res = new Vector(); - res.addAll(curRetPath); + Utils.addToVector(curRetPath,res); res.addElement(AbstractStep.KEEP_SUBTREE); used.add(res); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/PreparedStatement.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/query/PreparedStatement.java 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery/src/ch/ethz/mxquery/query/PreparedStatement.java 2012-02-08 15:43:03 UTC (rev 4528) @@ -25,6 +25,7 @@ import ch.ethz.mxquery.exceptions.StaticException; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.Hashtable; +import ch.ethz.mxquery.util.ObjectObjectPair; import ch.ethz.mxquery.xdmio.StoreSet; import ch.ethz.mxquery.xdmio.XDMSerializerSettings; @@ -152,4 +153,13 @@ */ public Hashtable getProjectionPaths() throws StaticException; + /** + * Provide projection path information for external variables + * @param varname A QName denoting the variable + * @param paths returned/used paths of the input of this variable + * @throws StaticException thrown if the variable could not be found + */ + public void setProjectionInformation(QName varname, ObjectObjectPair paths) throws StaticException; + + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-08 15:43:03 UTC (rev 4528) @@ -190,4 +190,11 @@ ht.put("DOC", paths); return ht; } + + public void setProjectionInformation(QName varname, + ObjectObjectPair paths) throws StaticException { + VariableHolder vh = ctx.getVariable(varname); + vh.setProjectionPaths(paths); + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-08 15:43:03 UTC (rev 4528) @@ -88,8 +88,6 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; -import sun.dc.pr.PathStroker; - import ch.ethz.mxquery.contextConfig.Context; import ch.ethz.mxquery.datamodel.QName; import ch.ethz.mxquery.datamodel.XQName; @@ -104,27 +102,35 @@ import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.model.AbstractStep; +import ch.ethz.mxquery.model.StepInformation; import ch.ethz.mxquery.model.XDMIterator; public class NonValidatingStaxAdapterProjection extends XDMImportAdapter { private XMLStreamReader reader; - private LinkedList tokensList; + private LinkedList tokensList; private ArrayList projectionPaths; - private int [] projPathPos; + private HashSet [] projPathPos; + // at which position is each projected path: advance when open, go back when close + // if there were only child steps, each path has only a single position + // once we include descendant steps, each path can be at multiple steps: + // finding a matching descendant node means that we both advance (to process the following steps) + // and stay at this node (to find nested - private Stack bufferedPathName; - private Stack bufferedAttributes; + private Stack bufferedPathName; // keep track of the "moved" paths seen so far, only output if a descendant is actually kept + private Stack bufferedAttributes; // keep attributes of "kept" elements or "kept" attributes themselves. + //attributes of "moved" elements do not be kept if they are not "kept" themselves - private HashSet activePaths; + private HashSet activePaths; // keep track of the paths that are currently active private int [] lastActiveStep; - private Stack keptNodes; // level?, pointer to bufferPathName + private Stack keptNodes; // nodes that were seen as "keep" while other still moved + // needed if the moving paths never go to keep/keep_sub - private int pathProducedLevel = 0; + private int pathProducedLevel = 0; // up to which level did we already produce the "moved" paths int skipKeepLevel = -1; @@ -177,8 +183,27 @@ } tok = new CommentToken(createNextTokenId(Type.COMMENT, null), reader.getText(),curNsScope); break; - case XMLStreamConstants.END_DOCUMENT: - tok = new Token(Type.END_DOCUMENT,null,curNsScope); + case XMLStreamConstants.END_DOCUMENT: { + java.util.Iterator pathIt = activePaths.iterator(); + while (pathIt.hasNext()) { + int pathPos = ((Integer)pathIt.next()).intValue(); + java.util.Iterator pathPosIt = projPathPos[pathPos].iterator(); + HashSet newVals = new HashSet(); + while (pathPosIt.hasNext()) { + int curPos = ((Integer)pathPosIt.next()).intValue(); + AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos)); + if (as == AbstractStep.ROOT_STEP) { + pathPosIt.remove(); + newVals.add(new Integer(--curPos)); + } + } + projPathPos[pathPos].addAll(newVals); + } + // Sanity check: all paths are active again + if (activePaths.size() != projectionPaths.size()) + throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Number of active paths does not match overall paths"+activePaths.size()+" "+projectionPaths.size(), loc); + tok = new Token(Type.END_DOCUMENT,null,curNsScope); + } break; case XMLStreamConstants.END_ELEMENT: { boolean emitTag = false; @@ -276,9 +301,23 @@ java.util.Iterator pathIt = activePaths.iterator(); while (pathIt.hasNext()) { int pathPos = ((Integer)pathIt.next()).intValue(); + java.util.Iterator pathPosIt = projPathPos[pathPos].iterator(); + HashSet newVals = new HashSet(); + while (pathPosIt.hasNext()) { + int curPos = ((Integer)pathPosIt.next()).intValue(); + AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos)); + if (as.getDirection() == StepInformation.AXIS_CHILD || + (as.getDirection() == StepInformation.AXIS_DESCENDANT && level < curPos)) { + // TODO: More precise "drop" from descendant than literal path position + pathPosIt.remove(); + newVals.add(new Integer(--curPos)); + } + } + projPathPos[pathPos].addAll(newVals); + } + - projPathPos[pathPos]--; - } + restoreDroppedPaths(); bufferedPathName.pop(); } break; @@ -287,36 +326,24 @@ //decide if keep or move directly, when we came from SKIP //SKIP->KEEP: reached skipKeepLevel, level above matched // SKIP->MOVE: reached skipKeepLevel, level above did not match - //javax.xml.namespace.QName name = reader.getName(); - for (int pathPos=0;pathPos<projectionPaths.size();pathPos++) { - Vector path = (Vector)projectionPaths.get(pathPos); - - if (path.size()==level+1) { - XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[pathPos])).getNodeTest().getXQName(); - if (equalsQNames(curPathCheck, name)) - activePaths.add(new Integer(pathPos)); - } - + for (int pathPos=0;pathPos<projectionPaths.size();pathPos++) { + Vector path = (Vector)projectionPaths.get(pathPos); + + if (path.size()==level+1) { + java.util.Iterator pathPosIt = projPathPos[pathPos].iterator(); + while (pathPosIt.hasNext()) { + int curPos = ((Integer)pathPosIt.next()).intValue(); + AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos)); + XQName curPathCheck = as.getNodeTest().getXQName(); + if (equalsQNames(curPathCheck, name)) + activePaths.add(new Integer(pathPos)); + } + } + } -// Vector path = (Vector)projectionPaths.get(0); - -// if (path.size() == projPathPos[0]+1) {// last element in path, and not a "KEEP" // really keep emitTag = true; -// } else { -// curProjMode = PROJ_MODE_MOVE; -// if (bufferedPathName.size() > level && bufferedPathName.get(level).equals(name)) { -// emitTag = true; -// -// } -// bufferedPathName.pop(); -// projPathPos[0]--; -// } -// XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[0])).getNodeTest().getXQName(); -// if (!equalsQNames(curPathCheck,name)) -// throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck+" saw "+name, loc); - //projPathPos[0]--; curProjMode = PROJ_MODE_MOVE; pathProducedLevel--; @@ -364,15 +391,26 @@ } tok = new ProcessingInstrToken(createNextTokenId(Type.PROCESSING_INSTRUCTION, null), reader.getPIData(), reader.getPITarget(),curNsScope); break; - case XMLStreamConstants.START_DOCUMENT: - AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0])); - if (as == AbstractStep.ROOT_STEP) { - projPathPos[0]++; - curProjMode = PROJ_MODE_MOVE; + case XMLStreamConstants.START_DOCUMENT: { + + java.util.Iterator pathIt = activePaths.iterator(); + while (pathIt.hasNext()) { + int pathPos = ((Integer)pathIt.next()).intValue(); + java.util.Iterator pathPosIt = projPathPos[pathPos].iterator(); + HashSet newVals = new HashSet(); + while (pathPosIt.hasNext()) { + int curPos = ((Integer)pathPosIt.next()).intValue(); + AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos)); + if (as == AbstractStep.ROOT_STEP) { + pathPosIt.remove(); + newVals.add(new Integer(++curPos)); + } } - - tok = new Token(Type.START_DOCUMENT,createNextTokenId(Type.START_DOCUMENT, null),curNsScope); - break; + projPathPos[pathPos].addAll(newVals); + } + tok = new Token(Type.START_DOCUMENT,createNextTokenId(Type.START_DOCUMENT, null),curNsScope); + } + break; case XMLStreamConstants.START_ELEMENT: level++; // "shortcut": if we skip, we do not even have to retrieve names etc @@ -399,54 +437,64 @@ // check if node name fits with currently active paths switch (curProjMode) { - case PROJ_MODE_MOVE: + case PROJ_MODE_MOVE: { boolean bufferNode = false; java.util.Iterator pathIt = activePaths.iterator(); while (pathIt.hasNext()) { int pathPos = ((Integer)pathIt.next()).intValue(); - as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(projPathPos[pathPos])); - // if any path goes to keep, we need to keep everything below - if (as == AbstractStep.KEEP_SUBTREE) { - curProjMode = PROJ_MODE_KEEP_SUB; - skipKeepLevel = level; - emitTag = true; - // no need to cover individual paths any more? - // break? - } else { + java.util.Iterator pathPosIt = projPathPos[pathPos].iterator(); + while (pathPosIt.hasNext()) { + int curPos = ((Integer)pathPosIt.next()).intValue(); + AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos)); + + // if any path goes to keep, we need to keep everything below + if (as == AbstractStep.KEEP_SUBTREE) { + curProjMode = PROJ_MODE_KEEP_SUB; + skipKeepLevel = level; + emitTag = true; + } else { XQName curPathCheck = as.getNodeTest().getXQName(); + int dir = as.getDirection(); + // if child, become inactive if we don't match or reach keep + // if descendant, stay moving even if there is no match or we find keep if (equalsQNames(curPathCheck,name)) { // possibly relevant path, so buffer the path bufferNode = true; - // check name: if true, then either keep or move + // check name: if true, then either keep or move Vector path = ((Vector)projectionPaths.get(pathPos)); - if (path.size() <= projPathPos[pathPos]+1) { + if (path.size() <= curPos+1) { //curProjMode = PROJ_MODE_KEEP; // mark that we may have to keep this node keepNode = true; - lastActiveStep[pathPos] = level; - activePaths.remove(new Integer(pathPos)); + if (dir == StepInformation.AXIS_CHILD) { + lastActiveStep[pathPos] = level; + pathIt.remove(); + } } - else if (path.elementAt(path.size()-1)==AbstractStep.KEEP_SUBTREE && path.size() <= projPathPos[pathPos]+2) { + else if (path.elementAt(path.size()-1)==AbstractStep.KEEP_SUBTREE && path.size() <= curPos+2) { curProjMode = PROJ_MODE_KEEP_SUB; } // else stay in MOVE - } else { // otherwise remove from set of active paths + } else { + // if no match and child step, remove from set of active paths // only assign new last active -// if (lastActiveStep[pathPos]<0) + if (dir == StepInformation.AXIS_CHILD) { lastActiveStep[pathPos] = level; -// else { -// lastActiveStep[pathPos] = lastActiveStep[pathPos]; // dummy for debugging -// } - activePaths.remove(new Integer(pathPos)); - //curProjMode = PROJ_MODE_SKIP; + pathIt.remove(); + } else if (dir == StepInformation.AXIS_DESCENDANT) { + bufferNode = true; + } } + } + } + } if (bufferNode) bufferedPathName.push(name); - + } break; case PROJ_MODE_KEEP_SUB: emitTag = true; // no check, just output @@ -474,15 +522,33 @@ } - // TODO: set up/sort things out according to state transitions + // set up/sort things out according to state transitions if (oldMode == PROJ_MODE_MOVE && curProjMode == PROJ_MODE_MOVE) { // advance all active paths java.util.Iterator pathIt = activePaths.iterator(); while (pathIt.hasNext()) { int pathPos = ((Integer)pathIt.next()).intValue(); - - projPathPos[pathPos]++; + java.util.Iterator pathPosIt = projPathPos[pathPos].iterator(); + HashSet newVals = new HashSet(); + while (pathPosIt.hasNext()) { + int curPos = ((Integer)pathPosIt.next()).intValue(); + AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos)); + int dir = as.getDirection(); + // Child moves down, descandant stays and moves on + if (dir == StepInformation.AXIS_CHILD) { + pathPosIt.remove(); + newVals.add(new Integer(++curPos)); + } + else if (dir == StepInformation.AXIS_DESCENDANT) { + XQName curPathCheck = as.getNodeTest().getXQName(); + if (equalsQNames(curPathCheck,name) && curPos < ((Vector)projectionPaths.get(pathPos)).size()-1) { + newVals.add(new Integer(++curPos)); + } + } + + } + projPathPos[pathPos].addAll(newVals); } if (keepNode) // put this node on the "keep" list @@ -657,11 +723,12 @@ public void setProjectionPaths(Vector paths) { projectionPaths = new ArrayList(); projectionPaths.addAll(paths); - projPathPos = new int[projectionPaths.size()]; + projPathPos = new HashSet[projectionPaths.size()]; activePaths = new HashSet(); lastActiveStep = new int[projectionPaths.size()]; for (int i=0;i<projPathPos.length;i++) { - projPathPos[i] = 0; + projPathPos[i] = new HashSet(); + projPathPos[i].add(new Integer(0)); activePaths.add(new Integer(i)); lastActiveStep[i] = -1; } Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java =================================================================== --- trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-08 15:43:03 UTC (rev 4528) @@ -184,5 +184,12 @@ Hashtable ht = new Hashtable(); ht.put("DOC", paths); return ht; + } + + public void setProjectionInformation(QName varname, + ObjectObjectPair paths) throws StaticException { + VariableHolder vh = ctx.getVariable(varname); + vh.setProjectionPaths(paths); } + } Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,5 +1,5 @@ -let $auction := doc() -let $auction := doc("xmark.xml") +declare variable $input external; +let $auction := $input return for $b in $auction/site/people/person -where $b/@id = 'person0' +where $b/id = 'person0' return $b/name/text() Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark02.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark02.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark02.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,3 +1,5 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $b in $auction/site/open_auctions/open_auction return <increase>{$b/bidder[1]/increase/text()}</increase> \ No newline at end of file Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark03.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark03.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark03.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $b in $auction/site/open_auctions/open_auction where $b/bidder[1]/increase * 2 <= $b/bidder[last()]/increase return Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark04.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark04.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark04.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $b in $auction/site/open_auctions/open_auction where some $pr1 in $b/bidder/personref[person = "person20"], Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark05.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark05.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark05.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return count( for $i in $auction/site/closed_auctions/closed_auction where $i/price >= 40 Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark06.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark06.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark06.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,2 +1,4 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $b in $auction//site/regions return count($b//item) \ No newline at end of file Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark07.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark07.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark07.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $p in $auction/site return count($p//description) + count($p//annotation) + count($p//emailaddress) \ No newline at end of file Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark08.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark08.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark08.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $p in $auction/site/people/person let $a := for $t in $auction/site/closed_auctions/closed_auction Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark09.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark09.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark09.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return let $ca := $auction/site/closed_auctions/closed_auction return let $ei := $auction/site/regions/europe/item Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark10.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark10.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark10.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $i in distinct-values($auction/site/people/person/profile/interest/category) let $p := Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark11.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark11.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark11.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $p in $auction/site/people/person let $l := for $i in $auction/site/open_auctions/open_auction/initial Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark12.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark12.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark12.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $p in $auction/site/people/person let $l := for $i in $auction/site/open_auctions/open_auction/initial Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark13.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark13.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark13.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,3 +1,5 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $i in $auction/site/regions/australia/item return <item name="{$i/name}">{$i/description}</item> \ No newline at end of file Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark14.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark14.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark14.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $i in $auction/site//item where contains($i/description, "gold") return $i/name \ No newline at end of file Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark15.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark15.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark15.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $a in $auction/site/closed_auctions/closed_auction/annotation/description/parlist/ listitem/ Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark16.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark16.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark16.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $a in $auction/site/closed_auctions/closed_auction where not( Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark17.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark17.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark17.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $p in $auction/site/people/person where empty($p/homepage) return <person name="{$p/name}"/> \ No newline at end of file Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark18.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark18.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark18.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,9 +1,10 @@ declare namespace local = "http://www.foobar.org"; +declare variable $input external; declare function local:convert($v as xs:decimal?) as xs:decimal? { 2.20371 * $v (: convert Dfl to Euro :) }; - -let $auction := doc("auction.xml") return +let $auction := $input +return for $i in $auction/site/open_auctions/open_auction return local:convert($i/reserve) \ No newline at end of file Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark19.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark19.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark19.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return for $b in $auction/site/regions//item let $k := $b/name order by $b/location ascending empty greatest Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark20.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark20.xq 2012-02-07 09:34:46 UTC (rev 4527) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark20.xq 2012-02-08 15:43:03 UTC (rev 4528) @@ -1,4 +1,6 @@ -let $auction := doc("auction.xml") return +declare variable $input external; +let $auction := $input +return <result> <preferred> {count($auction/site/people/person/profile[income >= 100000])} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 09:34:56
|
Revision: 4527 http://mxquery.svn.sourceforge.net/mxquery/?rev=4527&view=rev Author: pm_fischer Date: 2012-02-07 09:34:46 +0000 (Tue, 07 Feb 2012) Log Message: ----------- remove Projection STaX adapter from MIDP Modified Paths: -------------- trunk/MXQuery/build.xml Modified: trunk/MXQuery/build.xml =================================================================== --- trunk/MXQuery/build.xml 2012-02-07 09:21:35 UTC (rev 4526) +++ trunk/MXQuery/build.xml 2012-02-07 09:34:46 UTC (rev 4527) @@ -465,6 +465,7 @@ <delete file="${midptmp.dir}/ch/ethz/mxquery/xdmio/xmlAdapters/NonSchemaValidatingSaxImportAdapter.java"/> <delete file="${midptmp.dir}/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingDOMAdapter.java"/> <delete file="${midptmp.dir}/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapter.java"/> + <delete file="${midptmp.dir}/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java"/> <delete file="${midptmp.dir}/ch/ethz/mxquery/query/webservice/MultipleXQueryServer.java"/> <delete file="${midptmp.dir}/ch/ethz/mxquery/query/webservice/SingleXQueryServer.java"/> <delete file="${midptmp.dir}/ch/ethz/mxquery/query/webservice/XSPMain.java"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 09:21:45
|
Revision: 4526 http://mxquery.svn.sourceforge.net/mxquery/?rev=4526&view=rev Author: pm_fischer Date: 2012-02-07 09:21:35 +0000 (Tue, 07 Feb 2012) Log Message: ----------- PUL now fixed properly Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/model/updatePrimitives/PendingUpdateList.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/model/updatePrimitives/PendingUpdateList.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/model/updatePrimitives/PendingUpdateList.java 2012-02-07 09:04:38 UTC (rev 4525) +++ trunk/MXQuery/src/ch/ethz/mxquery/model/updatePrimitives/PendingUpdateList.java 2012-02-07 09:21:35 UTC (rev 4526) @@ -387,9 +387,6 @@ throw new DynamicException(ErrorCodes.U0021_UPDATE_DYNAMIC_INVALID_XDM,"Duplicate attribute names in updates",null); else seenAttrNames.add(attName); - } else { - if (seenAttrNames.size() > 0) - seenAttrNames = new Set(); } else { if (seenAttrNames.size() > 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 09:04:44
|
Revision: 4525 http://mxquery.svn.sourceforge.net/mxquery/?rev=4525&view=rev Author: pm_fischer Date: 2012-02-07 09:04:38 +0000 (Tue, 07 Feb 2012) Log Message: ----------- PUL fix Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/model/updatePrimitives/PendingUpdateList.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/model/updatePrimitives/PendingUpdateList.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/model/updatePrimitives/PendingUpdateList.java 2012-02-07 08:59:24 UTC (rev 4524) +++ trunk/MXQuery/src/ch/ethz/mxquery/model/updatePrimitives/PendingUpdateList.java 2012-02-07 09:04:38 UTC (rev 4525) @@ -387,7 +387,6 @@ throw new DynamicException(ErrorCodes.U0021_UPDATE_DYNAMIC_INVALID_XDM,"Duplicate attribute names in updates",null); else seenAttrNames.add(attName); - } } else { if (seenAttrNames.size() > 0) seenAttrNames = new Set(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 08:59:31
|
Revision: 4524 http://mxquery.svn.sourceforge.net/mxquery/?rev=4524&view=rev Author: pm_fischer Date: 2012-02-07 08:59:24 +0000 (Tue, 07 Feb 2012) Log Message: ----------- - Merge updated projection tests - Adapt classpath to refer to the up-to-date QName class - consider fixed context scoping in order by also for projection Modified Paths: -------------- trunk/MXQuery/.classpath trunk/MXQuery/src/ch/ethz/mxquery/iterators/GOrderByIterator.java trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionXMarkTests.java Modified: trunk/MXQuery/.classpath =================================================================== --- trunk/MXQuery/.classpath 2012-02-07 08:57:31 UTC (rev 4523) +++ trunk/MXQuery/.classpath 2012-02-07 08:59:24 UTC (rev 4524) @@ -1,16 +1,15 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry exported="true" kind="lib" path="lib/tagsoup-1.2.jar"/> - <classpathentry exported="true" kind="lib" path="lib/jax-1_1-fr-qname-class.jar"/> - <classpathentry exported="true" kind="lib" path="lib/kxml2-min-2.3.0.jar"/> - <classpathentry exported="true" kind="lib" path="lib/xmlpull_1_1_3_4c.jar"/> - <classpathentry exported="true" kind="lib" path="lib/jsr173_1.0_api.jar"/> - <classpathentry exported="true" kind="lib" path="lib/servlet-api.jar"/> - <classpathentry exported="true" kind="lib" path="lib/xqjapi.jar"/> - <classpathentry exported="true" kind="lib" path="lib/xercesImpl.jar"/> - <classpathentry exported="true" kind="lib" path="lib/commons-cli-1.2.jar"/> - <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/> - <classpathentry kind="output" path="bin"/> -</classpath> +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry exported="true" kind="lib" path="lib/tagsoup-1.2.jar"/> + <classpathentry exported="true" kind="lib" path="lib/jax-1_1-fr-qname-class.jar"/> + <classpathentry exported="true" kind="lib" path="lib/kxml2-min-2.3.0.jar"/> + <classpathentry exported="true" kind="lib" path="lib/xmlpull_1_1_3_4c.jar"/> + <classpathentry exported="true" kind="lib" path="lib/servlet-api.jar"/> + <classpathentry exported="true" kind="lib" path="lib/xqjapi.jar"/> + <classpathentry exported="true" kind="lib" path="lib/xercesImpl.jar"/> + <classpathentry exported="true" kind="lib" path="lib/commons-cli-1.2.jar"/> + <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/> + <classpathentry kind="output" path="bin"/> +</classpath> Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/GOrderByIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/GOrderByIterator.java 2012-02-07 08:57:31 UTC (rev 4523) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/GOrderByIterator.java 2012-02-07 08:59:24 UTC (rev 4524) @@ -316,6 +316,22 @@ } public ObjectObjectPair getProjectionPaths() throws StaticException { + + // order by re-binds variables, so we need to assign + // the projection path of the original variables to them + + for (int i = 0; i < orderedVarsQNames.length; i++) { + VariableHolder varholder = context + .getVariable(orderedVarsQNames[i]); + // use parent context for original variables (given the FLWOR nesting + // TODO: does this always work? + VariableHolder origvar = context.getParent() + .getVariable(orderedVarsQNames[i]); + varholder.setProjectionPaths(origvar.getProjectionPaths()); + } + + + Set returned = new Set(); Set used = new Set(); Modified: trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java =================================================================== --- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java 2012-02-07 08:57:31 UTC (rev 4523) +++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java 2012-02-07 08:59:24 UTC (rev 4524) @@ -3,14 +3,27 @@ */ package ch.ethz.mxquery.test; +import java.io.StringReader; import java.util.Enumeration; +import java.util.Vector; +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.QName; +import ch.ethz.mxquery.datamodel.XQName; +import ch.ethz.mxquery.exceptions.MXQueryException; +import ch.ethz.mxquery.model.AbstractStep; +import ch.ethz.mxquery.model.StepInformation; +import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.query.PreparedStatement; import ch.ethz.mxquery.testsuite.XQueryTestBase; import ch.ethz.mxquery.util.Hashtable; import ch.ethz.mxquery.util.ObjectObjectPair; import ch.ethz.mxquery.util.Set; +import ch.ethz.mxquery.xdmio.XDMInputFactory; +import ch.ethz.mxquery.xdmio.XDMSerializer; +import ch.ethz.mxquery.xdmio.XDMSerializerSettings; +import ch.ethz.mxquery.xdmio.XMLSource; /** @@ -21,7 +34,578 @@ private static final String TEST_PROJECTION_PREFIX = "ProjectionTests"; private static final String TEST_PROJECTION_QUERY_PREFIX = TEST_PROJECTION_PREFIX+"/queries/"; + private static final String TEST_PROJECTION_DOC_PREFIX = TEST_PROJECTION_PREFIX+"/docs/"; + public void test_SinglePath_RootOnly() throws MXQueryException{ + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + String xmlDoc = "<a/>"; + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + + Vector projPaths = new Vector(); + projPaths.addElement(setUpPath1Keep()); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("", res); + +} + + + + public void test_SinglePath_OneChild() throws MXQueryException{ + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + String xmlDoc = "<a><b/></a>"; + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("", res); + } + + public void test_SinglePath_SingleKeepNoChilds() throws MXQueryException{ + String xmlDoc = "<a><b><c/></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/></b></a>", res); + + } + + public void test_SinglePath_SingleNoChilds() throws MXQueryException{ + String xmlDoc = "<a><b><c/></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/></b></a>", res); + + } + + + public void test_SinglePath_SingleKeepTextChild() throws MXQueryException{ + String xmlDoc = "<a><b><c>Text</c></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c>Text</c></b></a>", res); + + } + + public void test_SinglePath_SingleTextChild() throws MXQueryException{ + String xmlDoc = "<a><b><c>Text</c></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/></b></a>", res); + + } + + + public void test_SinglePath_SingleKeepElementChild1() throws MXQueryException{ + String xmlDoc = "<a><b><c><d/></c></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c><d/></c></b></a>", res); + + } + + public void test_SinglePath_SingleElementChild1() throws MXQueryException{ + String xmlDoc = "<a><b><c><d/></c></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/></b></a>", res); + + } + + + public void test_SinglePath_SingleKeepElementChild2() throws MXQueryException{ + String xmlDoc = "<a><b><c><d/><e/></c></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c><d/><e/></c></b></a>", res); + + } + + + public void test_SinglePath_SingleElementChild2() throws MXQueryException{ + String xmlDoc = "<a><b><c><d/><e/></c></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/></b></a>", res); + + } + + + public void test_SinglePath_BeforeAfterKeep() throws MXQueryException{ + String xmlDoc = "<a><x/><b><c><d/><e/></c></b><y/></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c><d/><e/></c></b></a>", res); + + } + + + public void test_SinglePath_BeforeAfter() throws MXQueryException{ + String xmlDoc = "<a><x/><b><c><d/><e/></c></b><y/></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/></b></a>", res); + + } + + + public void test_SinglePath_OneEmptyKeep() throws MXQueryException{ + String xmlDoc = "<a><b><c><d/><e/></c></b><b/></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c><d/><e/></c></b></a>", res); +// showProjectedQuery(reader, projPaths); + + } + + + public void test_SinglePath_OneEmpty() throws MXQueryException{ + String xmlDoc = "<a><b><c><d/><e/></c></b><b/></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/></b></a>", res); + //showProjectedQuery(reader, projPaths); + + } + + + public void test_SinglePath_TwoEmptyKeep() throws MXQueryException{ + String xmlDoc = "<a><b/><b><c><d/><e/></c></b><b/></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c><d/><e/></c></b></a>", res); +// showProjectedQuery(reader, projPaths); + + } + + + public void test_SinglePath_TwoEmpty() throws MXQueryException{ + String xmlDoc = "<a><b/><b><c><d/><e/></c></b><b/></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/></b></a>", res); + //showProjectedQuery(reader, projPaths); + + } + + + public void test_SinglePath_SingleKeepTwoElementChild() throws MXQueryException{ + String xmlDoc = "<a><b><c><d/></c><c></c></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c><d/></c><c/></b></a>", res); + + } + + public void test_SinglePath_SingleTwoElementChild() throws MXQueryException{ + String xmlDoc = "<a><b><c><d/></c><c/></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/><c/></b></a>", res); + //showProjectedQuery(reader, projPaths); + + } + + + public void test_TwoPaths_SingleKeepNoChilds1() throws MXQueryException{ + String xmlDoc = "<a><b><c/></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + Vector path2 = setUpPath2(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + projPaths.addElement(path2); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/></b></a>", res); + + } + + + public void test_TwoPaths_SingleKeepNoChilds2() throws MXQueryException{ + String xmlDoc = "<a><d><e/></d></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + Vector path2 = setUpPath2(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + projPaths.addElement(path2); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><d/></a>", res); + + } + + + public void test_TwoPaths_PaperSample1() throws MXQueryException{ + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"proj1.xml", true, Context.NO_VALIDATION, null); + Vector path1 = setUpPath1Keep(); + Vector path2 = setUpPath2(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + projPaths.addElement(path2); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c><f/></c></b><d/></a>", res); + + } + + + // Test for kept node above, not produced below: Paths={/a/b, /a/b/c/d}, <a><b><c/></b></a> => <a><b/></a> + + public void test_TwoPaths_KeepAbove1() throws MXQueryException{ + + String xmlDoc = "<a><b><c/></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = new Vector(); + path1.addElement(AbstractStep.ROOT_STEP); + path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a"))); + path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("b"))); + path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("c"))); + path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("d"))); + + Vector path2 = new Vector(); + path2.addElement(AbstractStep.ROOT_STEP); + path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a"))); + path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("b"))); + + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + projPaths.addElement(path2); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b/></a>", res); +// showProjectedQuery(reader, projPaths); + } + + + public void test_SingleDescPath_SingleKeepNoChilds() throws MXQueryException{ + String xmlDoc = "<a><b><c/></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpDescPath1Keep(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/></b></a>", res); + + } + + public void test_SingleDescPath_SingleNoChilds() throws MXQueryException{ + String xmlDoc = "<a><b><c/></b></a>"; + + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, new StringReader(xmlDoc), true, Context.NO_VALIDATION, null); + Vector path1 = setUpDescPath1(); + + Vector projPaths = new Vector(); + projPaths.addElement(path1); + //projPaths.addElement(path2); + + String res = runProjectedQuery(reader, projPaths); + assertEquals("<a><b><c/></b></a>", res); + + } + + + + +// public void test_Load1() { +// Context ctx = new Context(); +// ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); +// try { +// XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"proj1.xml", true, Context.NO_VALIDATION, null); +// Vector path1 = new Vector(); +// path1.addElement(AbstractStep.ROOT_STEP); +// path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a"))); +// path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("b"))); +// path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("c"))); +// path1.addElement(AbstractStep.KEEP_SUBTREE); +// +// Vector path2 = new Vector(); +// path2.addElement(AbstractStep.ROOT_STEP); +// path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a"))); +// path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("d"))); +// +// +// Vector projPaths = new Vector(); +// projPaths.addElement(path1); +// //projPaths.addElement(path2); +// +// reader.setProjectionPaths(projPaths); +// +// XDMSerializer ser = new XDMSerializer(); +// ser.eventsToXML(new PrintStream(System.out),reader); +// } catch (MXQueryException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// } +// +// +// public void test_Load2() { +// Context ctx = new Context(); +// ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); +// try { +// XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"proj1b.xml", true, Context.NO_VALIDATION, null); +// Vector path1 = setUpPath1(); +// +// setUpPath2(); +// +// +// Vector projPaths = new Vector(); +// projPaths.addElement(path1); +// //projPaths.addElement(path2); +// +// reader.setProjectionPaths(projPaths); +// +// XDMSerializer ser = new XDMSerializer(); +// ser.eventsToXML(new PrintStream(System.out),reader); +// } catch (MXQueryException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// } + + + private Vector setUpPath1() throws MXQueryException { + Vector path1 = new Vector(); + path1.addElement(AbstractStep.ROOT_STEP); + path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a"))); + path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("b"))); + path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("c"))); + return path1; + } + + private Vector setUpPath1Keep() throws MXQueryException { + Vector path1 = setUpPath1(); + path1.addElement(AbstractStep.KEEP_SUBTREE); + return path1; + } + + + private Vector setUpDescPath1() throws MXQueryException { + Vector path1 = new Vector(); + path1.addElement(AbstractStep.ROOT_STEP); + path1.addElement(new AbstractStep(StepInformation.AXIS_DESCENDANT,new QName("b"))); + path1.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("c"))); + return path1; + } + + private Vector setUpDescPath1Keep() throws MXQueryException { + Vector path1 = setUpDescPath1(); + path1.addElement(AbstractStep.KEEP_SUBTREE); + return path1; + } + + + private Vector setUpPath2() throws MXQueryException { + Vector path2 = new Vector(); + path2.addElement(AbstractStep.ROOT_STEP); + path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("a"))); + path2.addElement(new AbstractStep(StepInformation.AXIS_CHILD,new QName("d"))); + return path2; + } + + private String runProjectedQuery(XMLSource reader, Vector projPaths) + throws MXQueryException { + reader.setProjectionPaths(projPaths); + XDMSerializerSettings set = new XDMSerializerSettings(); + set.setOmitXMLDeclaration(true); + XDMSerializer ser = new XDMSerializer(set); + String res = ser.eventsToXML(reader); + return res; + } + + + private void showProjectedQuery(XMLSource reader, Vector projPaths) + throws MXQueryException { + reader.setProjectionPaths(projPaths); + XDMSerializerSettings set = new XDMSerializerSettings(); + set.setOmitXMLDeclaration(true); + XDMSerializer ser = new XDMSerializer(set); + ser.eventsToXML(System.out,reader); + } + + public void test_Path1() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"Path1.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); @@ -29,7 +613,7 @@ handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); - } + } public void test_Path2() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"Path2.xq"); @@ -171,20 +755,44 @@ //assertEquals(resultBuffer.toString().trim(), "false"); } - private void handleProjectionPaths(Hashtable projPaths) { + private void handleProjectionPaths(Hashtable projPaths) throws Exception{ ObjectObjectPair paths = (ObjectObjectPair) projPaths.get("DOC"); Set returned = (Set) paths.getFirst(); Set used = (Set) paths.getSecond(); Enumeration en = returned.elements(); while (en.hasMoreElements()) { - String curPath = (String) en.nextElement(); + String curPath = translateProjectionPath(en); System.out.println(curPath+" #"); } en = used.elements(); while (en.hasMoreElements()) { - String curPath = (String) en.nextElement(); + String curPath = translateProjectionPath(en); System.out.println(curPath); } + } + + private String translateProjectionPath(Enumeration en) throws Exception { + Vector curPath = (Vector) en.nextElement(); + StringBuffer pathString = new StringBuffer(); + for (int i=0;i<curPath.size();i++) { + AbstractStep as = (AbstractStep)curPath.elementAt(i); + if (as == AbstractStep.ROOT_STEP) + pathString.append("/"); + else if (as == AbstractStep.KEEP_SUBTREE) + pathString.append(" #"); + else + { + pathString.append(as.getDirectionString(true)); + XQName xq = as.getNodeTest().getXQName(); + if (xq != null) + // TODO: What about namespace URIs? + pathString.append(xq.toString()); + else throw new Exception("Unsupported node test for projection - please report"); + if (i<curPath.size()-2 || ( (AbstractStep)curPath.elementAt(curPath.size()-1) != AbstractStep.KEEP_SUBTREE && i<curPath.size()-1) ) + pathString.append("/"); + } + } + return pathString.toString(); }; } Modified: trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionXMarkTests.java =================================================================== --- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionXMarkTests.java 2012-02-07 08:57:31 UTC (rev 4523) +++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionXMarkTests.java 2012-02-07 08:59:24 UTC (rev 4524) @@ -4,13 +4,24 @@ package ch.ethz.mxquery.test; import java.util.Enumeration; +import java.util.Vector; +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.QName; +import ch.ethz.mxquery.datamodel.XQName; +import ch.ethz.mxquery.exceptions.MXQueryException; +import ch.ethz.mxquery.exceptions.StaticException; +import ch.ethz.mxquery.model.AbstractStep; import ch.ethz.mxquery.query.PreparedStatement; import ch.ethz.mxquery.testsuite.XQueryTestBase; import ch.ethz.mxquery.util.Hashtable; import ch.ethz.mxquery.util.ObjectObjectPair; import ch.ethz.mxquery.util.Set; +import ch.ethz.mxquery.xdmio.XDMInputFactory; +import ch.ethz.mxquery.xdmio.XDMSerializer; +import ch.ethz.mxquery.xdmio.XDMSerializerSettings; +import ch.ethz.mxquery.xdmio.XMLSource; /** @@ -21,28 +32,110 @@ private static final String TEST_PROJECTION_PREFIX = "ProjectionTests"; private static final String TEST_PROJECTION_QUERY_PREFIX = TEST_PROJECTION_PREFIX+"/queries/"; - - public void test_XMark01() throws Exception{ + private static final String TEST_PROJECTION_DOC_PREFIX = TEST_PROJECTION_PREFIX+"/docs/"; + + public void test_XMark01_Paths() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark01.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + + + public void test_XMark01_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark01.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); +// System.out.println(res); + showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + + public void test_XMark01_Normal() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark01.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + + System.out.println(resultBuffer.toString()); + //assertEquals(resultBuffer.toString().trim(), "false"); + } + + + + public void test_XMark01_Projected() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark01.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runWithProjection(query, fileName); + + System.out.println(resultBuffer.toString()); + //assertEquals(resultBuffer.toString().trim(), "false"); + } + + + public void test_XMark01_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark01.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark02() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark02.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + public void test_XMark02_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark02.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + + public void test_XMark02_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark02.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark03() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark03.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); @@ -50,28 +143,111 @@ }; + public void test_XMark03_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark03.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + + public void test_XMark03_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark03.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark04() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark04.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + + public void test_XMark04_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark04.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + + public void test_XMark04_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark04.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark05() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark05.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + + public void test_XMark05_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark05.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + public void test_XMark05_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark05.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + public void test_XMark06() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark06.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); @@ -79,38 +255,145 @@ }; + public void test_XMark06_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark06.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.item.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + public void test_XMark06_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark06.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark07() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark07.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + + public void test_XMark07_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark06.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + public void test_XMark07_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark06.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark08() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark08.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + public void test_XMark08_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark08.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + public void test_XMark08_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark08.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + public void test_XMark09() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark09.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + public void test_XMark09_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark09.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + public void test_XMark09_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark09.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + public void test_XMark10() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark10.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); @@ -118,47 +401,181 @@ }; + public void test_XMark10_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark10.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + public void test_XMark10_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark10.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark11() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark11.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + public void test_XMark11_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark11.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + public void test_XMark11_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark11.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark12() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark12.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + public void test_XMark12_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark12.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + public void test_XMark12_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark12.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark13() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark13.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + public void test_XMark13_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark13.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + public void test_XMark13_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark13.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + public void test_XMark14() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark14.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + + public void test_XMark14_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark14.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + public void test_XMark14_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark14.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark15() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark15.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); @@ -166,66 +583,353 @@ }; + public void test_XMark15_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark15.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); +// String inputfile = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + String inputfile = "D:/Git-Repos/Projection_Data/10MB/auction-simplified.xml"; + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, inputfile, true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + public void test_XMark15_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark15.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + + public void test_XMark16() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark16.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + public void test_XMark16_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark16.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + public void test_XMark16_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark16.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark17() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark17.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + public void test_XMark17_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark17.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + + public void test_XMark17_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark17.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark18() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark18.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + public void test_XMark18_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark18.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); + Hashtable ht = pi.getProjectionPaths(); + Context ctx = new Context(); + ctx.setParserType(Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION); + XMLSource reader = XDMInputFactory.createXMLInput(ctx, TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml", true, Context.NO_VALIDATION, null); +// showProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + String res = runProjectedQuery(reader, handleProjectionPathsForProcessing(ht)); + System.out.println(res); + //assertEquals(resultBuffer.toString().trim(), "false"); + }; + + + public void test_XMark18_Compare() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark18.xq"); + String fileName = TEST_PROJECTION_DOC_PREFIX+"XMark_0.01.simple.xml"; + runQueryNormal(query, fileName); + String normalRes = resultBuffer.toString(); + runWithProjection(query, fileName); + String projRes = resultBuffer.toString(); + System.out.println(); + assertEquals(normalRes,projRes); + } + + public void test_XMark19() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark19.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new QName("input"), getRootProjectionPaths()); Hashtable ht = pi.getProjectionPaths(); handleProjectionPaths(ht); //assertEquals(resultBuffer.toString().trim(), "false"); }; + + public void test_XMark19_Load() throws Exception{ + String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"XMark19.xq"); + PreparedStatement pi = prepareQuery(query, false,false, false, false, false); + pi.setProjectionInformation(new ... [truncated message content] |
From: <pm_...@us...> - 2012-02-07 08:57:41
|
Revision: 4523 http://mxquery.svn.sourceforge.net/mxquery/?rev=4523&view=rev Author: pm_fischer Date: 2012-02-07 08:57:31 +0000 (Tue, 07 Feb 2012) Log Message: ----------- more merging Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 08:56:21 UTC (rev 4522) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 08:57:31 UTC (rev 4523) @@ -171,9 +171,10 @@ return new TextToken(Type.TEXT_NODE_UNTYPED_ATOMIC, createNextTokenId(Type.TEXT_NODE_UNTYPED_ATOMIC, null), mergedText.toString(),curNsScope); } case XMLStreamConstants.COMMENT: - if (curProjMode == PROJ_MODE_SKIP || curProjMode == PROJ_MODE_MOVE) + if (curProjMode == PROJ_MODE_SKIP || curProjMode == PROJ_MODE_MOVE) { + reader.next(); continue; - + } tok = new CommentToken(createNextTokenId(Type.COMMENT, null), reader.getText(),curNsScope); break; case XMLStreamConstants.END_DOCUMENT: @@ -181,16 +182,23 @@ break; case XMLStreamConstants.END_ELEMENT: { boolean emitTag = false; - javax.xml.namespace.QName name_debug = reader.getName(); + tok = null; + javax.xml.namespace.QName name = reader.getName(); switch (curProjMode) { case PROJ_MODE_KEEP_SUB: //KEEP_SUB->MOVE: reached skipKeepLevel //KEEP_SUB->KEEP_SUB: any closing tag greater than skipKeepLevel if (skipKeepLevel == level) { + restoreDroppedPaths(); curProjMode = PROJ_MODE_MOVE; skipKeepLevel = -1; bufferedPathName.pop(); pathProducedLevel--; +// java.util.Iterator pathIt = activePaths.iterator(); +// while (pathIt.hasNext()) { +// int pathPos = ((Integer)pathIt.next()).intValue(); +// projPathPos[pathPos]--; +// } } emitTag = true; break; @@ -198,8 +206,10 @@ // go to "KEEP", check later if we keep or move if (skipKeepLevel == level+1) { + //javax.xml.namespace.QName name = reader.getName(); + curProjMode = PROJ_MODE_MOVE; restoreDroppedPaths(); - curProjMode = PROJ_MODE_MOVE; + if (pathProducedLevel >= level) { emitTag = true; pathProducedLevel--; @@ -208,7 +218,8 @@ } else if (skipKeepLevel == level) { - javax.xml.namespace.QName name = reader.getName(); + //javax.xml.namespace.QName name = reader.getName(); + boolean foundMove = false; boolean foundKeep = false; for (int pathPos=0;pathPos<projectionPaths.size();pathPos++) { // check those paths that we active before we started skipping @@ -216,25 +227,24 @@ if (lastActiveStep[pathPos]==level) { // they will become active again activePaths.add(new Integer(pathPos)); + foundMove =true; } - // last step was KEEP - if (lastActiveStep[pathPos]+1==level) { - // they will become active again - activePaths.add(new Integer(pathPos)); - // decide if we go to KEEP - Vector path = (Vector)projectionPaths.get(pathPos); - XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[pathPos])).getNodeTest().getXQName(); - if (equalsQNames(curPathCheck,name) || /*FIXME*/ level != projPathPos[pathPos]) { - foundKeep = true; - } + + Vector path = (Vector)projectionPaths.get(pathPos); + if (path.size()==level && lastActiveStep[pathPos]==level-1) { +// activePaths.add(new Integer(pathPos)); + foundKeep = true; } + } - if (foundKeep) + if (foundMove) { + curProjMode = PROJ_MODE_MOVE; + skipKeepLevel = -1; + } else + if (foundKeep) { curProjMode = PROJ_MODE_KEEP; - else - curProjMode = PROJ_MODE_MOVE; - - skipKeepLevel = -1; + skipKeepLevel = -1; + } } else { reader.next(); @@ -243,25 +253,33 @@ } break; case PROJ_MODE_MOVE: { - restoreDroppedPaths(); - javax.xml.namespace.QName name = reader.getName(); + + //javax.xml.namespace.QName name = reader.getName(); //TODO: remove this consistency check - only trivially possible for a single path - XQName curPathCheck = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0]-1)).getNodeTest().getXQName(); - if (!equalsQNames(curPathCheck,name)) - throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck+" saw "+name, loc); +// XQName curPathCheck = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0]-1)).getNodeTest().getXQName(); +// if (!equalsQNames(curPathCheck,name)) +// throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck+" saw "+name, loc); // if kept nodes are on the path, i.e. we had "KEEP" for them but did not produce any lower // output them if (!keptNodes.empty()&&((Integer)keptNodes.peek()).intValue() == level ) { tok = extractPendingElements(); - // TODO: extract+emit! - } + XQName tName = transformQName((javax.xml.namespace.QName)bufferedPathName.elementAt(level-1)); + tokensList.add(new ElementToken(Type.END_TAG, createNextTokenId(Type.END_TAG, tName.toString()), tName, curNsScope)); + pathProducedLevel--; + } else if (pathProducedLevel >= level) { emitTag = true; pathProducedLevel--; } - projPathPos[0]--; + java.util.Iterator pathIt = activePaths.iterator(); + while (pathIt.hasNext()) { + int pathPos = ((Integer)pathIt.next()).intValue(); + + projPathPos[pathPos]--; + } + restoreDroppedPaths(); bufferedPathName.pop(); } break; case PROJ_MODE_KEEP: { @@ -269,8 +287,18 @@ //decide if keep or move directly, when we came from SKIP //SKIP->KEEP: reached skipKeepLevel, level above matched // SKIP->MOVE: reached skipKeepLevel, level above did not match - javax.xml.namespace.QName name = reader.getName(); - + //javax.xml.namespace.QName name = reader.getName(); + for (int pathPos=0;pathPos<projectionPaths.size();pathPos++) { + Vector path = (Vector)projectionPaths.get(pathPos); + + if (path.size()==level+1) { + XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[pathPos])).getNodeTest().getXQName(); + if (equalsQNames(curPathCheck, name)) + activePaths.add(new Integer(pathPos)); + } + + } + // Vector path = (Vector)projectionPaths.get(0); // if (path.size() == projPathPos[0]+1) {// last element in path, and not a "KEEP" @@ -303,15 +331,14 @@ // + level--; if (emitTag) { - javax.xml.namespace.QName name = reader.getName(); + //javax.xml.namespace.QName name = reader.getName(); XQName tName = transformQName(name); tok = new ElementToken(Type.END_TAG, null, tName, curNsScope); checkCloseNsScope(); - level--; - } else { - reader.next(); - level--; + } else if (tok==null){ + reader.next(); continue; } @@ -324,13 +351,17 @@ case XMLStreamConstants.NAMESPACE: break; case XMLStreamConstants.NOTATION_DECLARATION: - if (curProjMode == PROJ_MODE_SKIP || curProjMode == PROJ_MODE_MOVE) + if (curProjMode == PROJ_MODE_SKIP || curProjMode == PROJ_MODE_MOVE) { + reader.next(); continue; + } tok = new TextToken(createNextTokenId(Type.NOTATION, null), reader.getText()); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: - if (curProjMode == PROJ_MODE_SKIP || curProjMode == PROJ_MODE_MOVE) + if (curProjMode == PROJ_MODE_SKIP || curProjMode == PROJ_MODE_MOVE) { + reader.next(); continue; + } tok = new ProcessingInstrToken(createNextTokenId(Type.PROCESSING_INSTRUCTION, null), reader.getPIData(), reader.getPITarget(),curNsScope); break; case XMLStreamConstants.START_DOCUMENT: @@ -402,7 +433,12 @@ // else stay in MOVE } else { // otherwise remove from set of active paths - lastActiveStep[pathPos] = level; + // only assign new last active +// if (lastActiveStep[pathPos]<0) + lastActiveStep[pathPos] = level; +// else { +// lastActiveStep[pathPos] = lastActiveStep[pathPos]; // dummy for debugging +// } activePaths.remove(new Integer(pathPos)); //curProjMode = PROJ_MODE_SKIP; } @@ -560,6 +596,7 @@ reader.next(); else { endOfSeq = true; + tok = Token.END_SEQUENCE_TOKEN; } return tok; } catch (XMLStreamException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 08:56:28
|
Revision: 4522 http://mxquery.svn.sourceforge.net/mxquery/?rev=4522&view=rev Author: pm_fischer Date: 2012-02-07 08:56:21 +0000 (Tue, 07 Feb 2012) Log Message: ----------- Introduced code to handle multiple paths, working for a single path Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 08:55:10 UTC (rev 4521) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 08:56:21 UTC (rev 4522) @@ -24,7 +24,7 @@ * * We keep track of the level on which we switched to SKIP/SUB_KEEP: top skip, top keep node => skipKeepLevel * - * Transitions: + * Transitions (on a single path): * * Driven by opening tags * MOVE->KEEP: We reach the end of a projection path, match the name and do not keep descendants => produce @@ -42,7 +42,39 @@ * KEEP_SUB->MOVE: reached skipKeepLevel * MOVE->MOVE: on a projection path, match name close * SKIP->SKIP: any closing tag greater than skipKeepLevel - * KEEP_SUB->KEEP_SUB: any closing tag greater than skipKeepLevel + * KEEP_SUB->KEEP_SUB: any closing tag greater than skipKeepLevel + * + * Handling multiple projection paths: + * For each path, we record + * - the step that should be considered, creating the active suffix: projPathPos + * + * In general, we keep track of + * - the set of currently active paths: activePaths + * - the last step on which an in-active path was active: lastActiveStep + * - the "stack" of kept nodes: keptNodes -> pointers to seen opening nodes + * + * active/inactive tracking: + * - all paths start off active + * when opening an element, check if name matches + * if not, remove from set of active paths, set lastActiveLevel to current level + * when closing an element, go through the non-active paths and check if one of them is at lastActiveLevel. If yes, add back to active paths + * + * active paths vs modes: + * opening: + * if any active path goes to KEEP_SUB, go to KEEP_SUB. Ignore all the suffixes until the output has been produced, + * if no paths are active any more, go to SKIP + * if a path goes to KEEP: if other paths are active/MOVE, add to the set of kept paths (as these path might not produce). Otherwise, go to KEEP, emit + * otherwise, stay in MOVE + * + * if emit, produce path to this point, set produced level and clean up kept nodes + * + * closing: + * KEEP_SUB -> KEEP_SUB, SKIP->SKIP: as before + * KEEP_SUB: -> MOVE, all info should be fine + * SKIP-> MOVE/KEEP: + * MOVE-> MOVE: add previously closed paths to active if lastLevel is OK + * check + * */ package ch.ethz.mxquery.xdmio.xmlAdapters; @@ -50,18 +82,20 @@ import java.util.LinkedList; import java.util.Vector; import java.util.Stack; +import java.util.HashSet; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import sun.dc.pr.PathStroker; + import ch.ethz.mxquery.contextConfig.Context; import ch.ethz.mxquery.datamodel.QName; import ch.ethz.mxquery.datamodel.XQName; import ch.ethz.mxquery.datamodel.types.Type; import ch.ethz.mxquery.datamodel.xdm.CommentToken; import ch.ethz.mxquery.datamodel.xdm.ElementToken; -import ch.ethz.mxquery.datamodel.xdm.NamedToken; import ch.ethz.mxquery.datamodel.xdm.ProcessingInstrToken; import ch.ethz.mxquery.datamodel.xdm.TextToken; import ch.ethz.mxquery.datamodel.xdm.Token; @@ -85,6 +119,11 @@ private Stack bufferedPathName; private Stack bufferedAttributes; + private HashSet activePaths; + private int [] lastActiveStep; + + private Stack keptNodes; // level?, pointer to bufferPathName + private int pathProducedLevel = 0; int skipKeepLevel = -1; @@ -112,7 +151,7 @@ int event = reader.getEventType(); switch (event) { case XMLStreamConstants.ATTRIBUTE: - break; + break; case XMLStreamConstants.DTD: break; case XMLStreamConstants.CDATA: @@ -150,6 +189,7 @@ if (skipKeepLevel == level) { curProjMode = PROJ_MODE_MOVE; skipKeepLevel = -1; + bufferedPathName.pop(); pathProducedLevel--; } emitTag = true; @@ -158,6 +198,7 @@ // go to "KEEP", check later if we keep or move if (skipKeepLevel == level+1) { + restoreDroppedPaths(); curProjMode = PROJ_MODE_MOVE; if (pathProducedLevel >= level) { emitTag = true; @@ -168,15 +209,31 @@ else if (skipKeepLevel == level) { javax.xml.namespace.QName name = reader.getName(); + boolean foundKeep = false; + for (int pathPos=0;pathPos<projectionPaths.size();pathPos++) { + // check those paths that we active before we started skipping + // last state was MOVE + if (lastActiveStep[pathPos]==level) { + // they will become active again + activePaths.add(new Integer(pathPos)); + } + // last step was KEEP + if (lastActiveStep[pathPos]+1==level) { + // they will become active again + activePaths.add(new Integer(pathPos)); + // decide if we go to KEEP + Vector path = (Vector)projectionPaths.get(pathPos); + XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[pathPos])).getNodeTest().getXQName(); + if (equalsQNames(curPathCheck,name) || /*FIXME*/ level != projPathPos[pathPos]) { + foundKeep = true; + } + } + } + if (foundKeep) + curProjMode = PROJ_MODE_KEEP; + else + curProjMode = PROJ_MODE_MOVE; - Vector path = (Vector)projectionPaths.get(0); - - XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[0])).getNodeTest().getXQName(); - if (equalsQNames(curPathCheck,name) || level != projPathPos[0]) { - curProjMode = PROJ_MODE_KEEP; - } else { - curProjMode = PROJ_MODE_MOVE; - } skipKeepLevel = -1; } else { @@ -186,11 +243,20 @@ } break; case PROJ_MODE_MOVE: { - javax.xml.namespace.QName name = reader.getName(); + restoreDroppedPaths(); + javax.xml.namespace.QName name = reader.getName(); + //TODO: remove this consistency check - only trivially possible for a single path XQName curPathCheck = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0]-1)).getNodeTest().getXQName(); if (!equalsQNames(curPathCheck,name)) throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck+" saw "+name, loc); - + + // if kept nodes are on the path, i.e. we had "KEEP" for them but did not produce any lower + // output them + if (!keptNodes.empty()&&((Integer)keptNodes.peek()).intValue() == level ) { + tok = extractPendingElements(); + // TODO: extract+emit! + } + if (pathProducedLevel >= level) { emitTag = true; pathProducedLevel--; @@ -199,29 +265,29 @@ bufferedPathName.pop(); } break; case PROJ_MODE_KEEP: { - + bufferedPathName.pop(); //decide if keep or move directly, when we came from SKIP //SKIP->KEEP: reached skipKeepLevel, level above matched // SKIP->MOVE: reached skipKeepLevel, level above did not match javax.xml.namespace.QName name = reader.getName(); - Vector path = (Vector)projectionPaths.get(0); +// Vector path = (Vector)projectionPaths.get(0); - if (path.size() == projPathPos[0]+1) {// last element in path, and not a "KEEP" +// if (path.size() == projPathPos[0]+1) {// last element in path, and not a "KEEP" // really keep emitTag = true; - } else { - curProjMode = PROJ_MODE_MOVE; - if (bufferedPathName.size() > level && bufferedPathName.get(level).equals(name)) { - emitTag = true; - - } - bufferedPathName.pop(); - projPathPos[0]--; - } - XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[0])).getNodeTest().getXQName(); - if (!equalsQNames(curPathCheck,name)) - throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck+" saw "+name, loc); +// } else { +// curProjMode = PROJ_MODE_MOVE; +// if (bufferedPathName.size() > level && bufferedPathName.get(level).equals(name)) { +// emitTag = true; +// +// } +// bufferedPathName.pop(); +// projPathPos[0]--; +// } +// XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[0])).getNodeTest().getXQName(); +// if (!equalsQNames(curPathCheck,name)) +// throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck+" saw "+name, loc); //projPathPos[0]--; curProjMode = PROJ_MODE_MOVE; @@ -292,57 +358,64 @@ boolean createdNSScope = false; javax.xml.namespace.QName name = reader.getName(); -// String ns_uri = reader.getNamespaceURI(); -// String prefix = reader.getPrefix(); -// if (prefix != null && prefix.length() == 0) -// prefix = null; // projection: boolean emitTag = false; + int oldMode = curProjMode; + boolean keepNode = false; + // check if node name fits with currently active paths switch (curProjMode) { - case PROJ_MODE_KEEP_SUB: - emitTag = true; // no check, just output - break; + case PROJ_MODE_MOVE: + boolean bufferNode = false; - case PROJ_MODE_MOVE: - as = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0])); + java.util.Iterator pathIt = activePaths.iterator(); + while (pathIt.hasNext()) { + int pathPos = ((Integer)pathIt.next()).intValue(); + as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(projPathPos[pathPos])); + // if any path goes to keep, we need to keep everything below if (as == AbstractStep.KEEP_SUBTREE) { curProjMode = PROJ_MODE_KEEP_SUB; skipKeepLevel = level; emitTag = true; + // no need to cover individual paths any more? + // break? } else { XQName curPathCheck = as.getNodeTest().getXQName(); - if (equalsQNames(curPathCheck,name)) { + if (equalsQNames(curPathCheck,name)) { + // possibly relevant path, so buffer the path + bufferNode = true; // check name: if true, then either keep or move - Vector path = ((Vector)projectionPaths.get(0)); - if (path.size() <= projPathPos[0]+1) { - tok = extractPendingElements(name); - curProjMode = PROJ_MODE_KEEP; - skipKeepLevel = level+1; + Vector path = ((Vector)projectionPaths.get(pathPos)); + if (path.size() <= projPathPos[pathPos]+1) { + //curProjMode = PROJ_MODE_KEEP; + // mark that we may have to keep this node + keepNode = true; + lastActiveStep[pathPos] = level; + activePaths.remove(new Integer(pathPos)); } - else if (path.elementAt(path.size()-1)==AbstractStep.KEEP_SUBTREE && path.size() <= projPathPos[0]+2) { - tok = extractPendingElements(name); + else if (path.elementAt(path.size()-1)==AbstractStep.KEEP_SUBTREE && path.size() <= projPathPos[pathPos]+2) { curProjMode = PROJ_MODE_KEEP_SUB; - skipKeepLevel = level; } - else { - projPathPos[0]++; - curProjMode = PROJ_MODE_MOVE; - bufferedPathName.push(name); - reader.next(); - continue; //buffer contents until we find a projection result - } + // else stay in MOVE - } else { // otherwise go to skip - skipKeepLevel = level; - curProjMode = PROJ_MODE_SKIP; + } else { // otherwise remove from set of active paths + lastActiveStep[pathPos] = level; + activePaths.remove(new Integer(pathPos)); + //curProjMode = PROJ_MODE_SKIP; } } - + } + if (bufferNode) + bufferedPathName.push(name); + break; + case PROJ_MODE_KEEP_SUB: + emitTag = true; // no check, just output + break; + case PROJ_MODE_KEEP: { //emitTag = true; skipKeepLevel = level; @@ -351,6 +424,53 @@ break; // we handled SKIP already above } + + // Global Check + // determine new mode by checking old state, active nodes etc + // MOVE, activePaths empty => SKIP + + if (curProjMode==PROJ_MODE_MOVE && activePaths.isEmpty()) { + if (!keepNode) + curProjMode = PROJ_MODE_SKIP; + else + curProjMode = PROJ_MODE_KEEP; + skipKeepLevel = level; + } + + + // TODO: set up/sort things out according to state transitions + + if (oldMode == PROJ_MODE_MOVE && curProjMode == PROJ_MODE_MOVE) { + // advance all active paths + java.util.Iterator pathIt = activePaths.iterator(); + while (pathIt.hasNext()) { + int pathPos = ((Integer)pathIt.next()).intValue(); + + projPathPos[pathPos]++; + } + if (keepNode) + // put this node on the "keep" list + // if we move on + keptNodes.push(new Integer(level)); + reader.next(); + continue; //buffer contents until we find a projection result + } + + if (oldMode == PROJ_MODE_MOVE && (curProjMode == PROJ_MODE_KEEP || curProjMode == PROJ_MODE_KEEP_SUB)) { + // once we found a element to keep, push out the pending ones + tok = extractPendingElements(); + + // for keep, we will skip (and resume) below + if (curProjMode == PROJ_MODE_KEEP) { + skipKeepLevel = level+1; + } + else // keep_sub, we start here + skipKeepLevel = level; + + } + + oldMode = curProjMode; + if (curProjMode == PROJ_MODE_SKIP) { reader.next(); continue; @@ -457,16 +577,27 @@ return Token.END_SEQUENCE_TOKEN; } - private TokenInterface extractPendingElements(javax.xml.namespace.QName qn) { + private void restoreDroppedPaths() { + // add back paths that have become inactive + for (int pathPos = 0;pathPos<projectionPaths.size();pathPos++) { + if (lastActiveStep[pathPos] == level) { + activePaths.add(new Integer(pathPos)); + lastActiveStep[pathPos] = -1; + } + //AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(projPathPos[pathPos])); + } + } + + private TokenInterface extractPendingElements() { // we have reached the end of the path, and no subtree is needed: KEEP // emit all the pending element nodes for (int i=pathProducedLevel; i<bufferedPathName.size();i++) { XQName tName = transformQName((javax.xml.namespace.QName)bufferedPathName.elementAt(i)); tokensList.add(new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope)); } - XQName tName = transformQName(qn); - tokensList.add(new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope)); pathProducedLevel = level; + // clean up the kept nodes, as we now produce along the path on which they are + keptNodes.clear(); return (TokenInterface)tokensList.removeFirst(); } @@ -490,8 +621,14 @@ projectionPaths = new ArrayList(); projectionPaths.addAll(paths); projPathPos = new int[projectionPaths.size()]; - for (int i=0;i<projPathPos.length;i++) + activePaths = new HashSet(); + lastActiveStep = new int[projectionPaths.size()]; + for (int i=0;i<projPathPos.length;i++) { projPathPos[i] = 0; + activePaths.add(new Integer(i)); + lastActiveStep[i] = -1; + } + keptNodes = new Stack(); } QName transformQName(javax.xml.namespace.QName qn) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 08:55:16
|
Revision: 4521 http://mxquery.svn.sourceforge.net/mxquery/?rev=4521&view=rev Author: pm_fischer Date: 2012-02-07 08:55:10 +0000 (Tue, 07 Feb 2012) Log Message: ----------- Namespace support for projection Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 08:53:50 UTC (rev 4520) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 08:55:10 UTC (rev 4521) @@ -83,8 +83,6 @@ private int [] projPathPos; private Stack bufferedPathName; - private Stack bufferedPathURI; - private Stack bufferedPathPrefix; private Stack bufferedAttributes; private int pathProducedLevel = 0; @@ -144,7 +142,7 @@ break; case XMLStreamConstants.END_ELEMENT: { boolean emitTag = false; - String name_debug = reader.getLocalName(); + javax.xml.namespace.QName name_debug = reader.getName(); switch (curProjMode) { case PROJ_MODE_KEEP_SUB: //KEEP_SUB->MOVE: reached skipKeepLevel @@ -169,12 +167,12 @@ } else if (skipKeepLevel == level) { - String name = reader.getLocalName(); + javax.xml.namespace.QName name = reader.getName(); Vector path = (Vector)projectionPaths.get(0); XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[0])).getNodeTest().getXQName(); - if (curPathCheck.getLocalPart().equals(name) || level != projPathPos[0]) { + if (equalsQNames(curPathCheck,name) || level != projPathPos[0]) { curProjMode = PROJ_MODE_KEEP; } else { curProjMode = PROJ_MODE_MOVE; @@ -188,10 +186,10 @@ } break; case PROJ_MODE_MOVE: { - String name = reader.getLocalName(); + javax.xml.namespace.QName name = reader.getName(); XQName curPathCheck = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0]-1)).getNodeTest().getXQName(); - if (!curPathCheck.getLocalPart().equals(name)) - throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck.getLocalPart()+" saw "+name, loc); + if (!equalsQNames(curPathCheck,name)) + throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck+" saw "+name, loc); if (pathProducedLevel >= level) { emitTag = true; @@ -205,7 +203,7 @@ //decide if keep or move directly, when we came from SKIP //SKIP->KEEP: reached skipKeepLevel, level above matched // SKIP->MOVE: reached skipKeepLevel, level above did not match - String name = reader.getLocalName(); + javax.xml.namespace.QName name = reader.getName(); Vector path = (Vector)projectionPaths.get(0); @@ -222,8 +220,8 @@ projPathPos[0]--; } XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[0])).getNodeTest().getXQName(); - if (!curPathCheck.getLocalPart().equals(name)) - throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck.getLocalPart()+" saw "+name, loc); + if (!equalsQNames(curPathCheck,name)) + throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck+" saw "+name, loc); //projPathPos[0]--; curProjMode = PROJ_MODE_MOVE; @@ -240,12 +238,8 @@ // if (emitTag) { - String name = reader.getLocalName(); - String ns_uri = reader.getNamespaceURI(); - String prefix = reader.getPrefix(); - if (prefix != null && prefix.length() == 0) - prefix = null; - XQName tName = new QName(ns_uri, prefix, name); + javax.xml.namespace.QName name = reader.getName(); + XQName tName = transformQName(name); tok = new ElementToken(Type.END_TAG, null, tName, curNsScope); checkCloseNsScope(); level--; @@ -297,11 +291,11 @@ String [] xmlIdREFS = null; boolean createdNSScope = false; - String name = reader.getLocalName(); - String ns_uri = reader.getNamespaceURI(); - String prefix = reader.getPrefix(); - if (prefix != null && prefix.length() == 0) - prefix = null; + javax.xml.namespace.QName name = reader.getName(); +// String ns_uri = reader.getNamespaceURI(); +// String prefix = reader.getPrefix(); +// if (prefix != null && prefix.length() == 0) +// prefix = null; // projection: @@ -321,22 +315,16 @@ emitTag = true; } else { XQName curPathCheck = as.getNodeTest().getXQName(); - if (curPathCheck.getLocalPart().equals(name)) { //TODO: Handle namespaces + if (equalsQNames(curPathCheck,name)) { // check name: if true, then either keep or move Vector path = ((Vector)projectionPaths.get(0)); if (path.size() <= projPathPos[0]+1) { - tok = extractPendingElements( - name, - ns_uri, - prefix); + tok = extractPendingElements(name); curProjMode = PROJ_MODE_KEEP; skipKeepLevel = level+1; } else if (path.elementAt(path.size()-1)==AbstractStep.KEEP_SUBTREE && path.size() <= projPathPos[0]+2) { - tok = extractPendingElements( - name, - ns_uri, - prefix); + tok = extractPendingElements(name); curProjMode = PROJ_MODE_KEEP_SUB; skipKeepLevel = level; } @@ -368,9 +356,9 @@ continue; } if (emitTag) { - if (prefix != null && prefix.length() == 0) - prefix = null; - XQName tName = new QName(ns_uri, prefix, name); +// if (prefix != null && prefix.length() == 0) +// prefix = null; + XQName tName = transformQName(name); tok = new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope); } if (curProjMode == PROJ_MODE_KEEP) @@ -469,15 +457,14 @@ return Token.END_SEQUENCE_TOKEN; } - private TokenInterface extractPendingElements(String name, String ns_uri, - String prefix) { + private TokenInterface extractPendingElements(javax.xml.namespace.QName qn) { // we have reached the end of the path, and no subtree is needed: KEEP // emit all the pending element nodes for (int i=pathProducedLevel; i<bufferedPathName.size();i++) { - XQName tName = new QName(null, null, (String)bufferedPathName.elementAt(i)); + XQName tName = transformQName((javax.xml.namespace.QName)bufferedPathName.elementAt(i)); tokensList.add(new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope)); } - XQName tName = new QName(ns_uri, prefix, name); + XQName tName = transformQName(qn); tokensList.add(new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope)); pathProducedLevel = level; return (TokenInterface)tokensList.removeFirst(); @@ -506,4 +493,26 @@ for (int i=0;i<projPathPos.length;i++) projPathPos[i] = 0; } + + QName transformQName(javax.xml.namespace.QName qn) { + //TODO: We might create a pool/cache of QNames + String prefix = qn.getPrefix(); + if (prefix != null && prefix.length() == 0) + prefix = null; + return new QName(qn.getNamespaceURI(),prefix,qn.getLocalPart()); + } + + boolean equalsQNames(XQName mxqQName, javax.xml.namespace.QName jQName) { + if (!mxqQName.getLocalPart().equals(jQName.getLocalPart())) + return false; + if (mxqQName.getNamespaceURI()==null) { + if (!jQName.getNamespaceURI().equals(javax.xml.XMLConstants.NULL_NS_URI)) + return false; + else return true; + } + if (!mxqQName.getNamespaceURI().equals(jQName.getNamespaceURI())) + return false; + return true; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 08:53:57
|
Revision: 4520 http://mxquery.svn.sourceforge.net/mxquery/?rev=4520&view=rev Author: pm_fischer Date: 2012-02-07 08:53:50 +0000 (Tue, 07 Feb 2012) Log Message: ----------- - Use AbstractStep objects throughout the plan - Properly implement projection for count() and data() - Loading should work for a single, child-only path, local names Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/CountIterator.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java trunk/MXQuery/src/ch/ethz/mxquery/model/AbstractStep.java trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/CountIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/CountIterator.java 2012-02-07 08:51:38 UTC (rev 4519) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/CountIterator.java 2012-02-07 08:53:50 UTC (rev 4520) @@ -27,10 +27,13 @@ import ch.ethz.mxquery.datamodel.xdm.LongToken; import ch.ethz.mxquery.datamodel.xdm.TokenInterface; import ch.ethz.mxquery.exceptions.MXQueryException; +import ch.ethz.mxquery.exceptions.StaticException; import ch.ethz.mxquery.iterators.VariableIterator; import ch.ethz.mxquery.model.IndexIterator; import ch.ethz.mxquery.model.TokenBasedIterator; import ch.ethz.mxquery.model.XDMIterator; +import ch.ethz.mxquery.util.ObjectObjectPair; +import ch.ethz.mxquery.util.Set; public class CountIterator extends TokenBasedIterator { private IndexIterator indexIter; @@ -107,4 +110,15 @@ copy.setSubIters(subIters); return copy; } + + public ObjectObjectPair getProjectionPaths() throws StaticException { + Set returned = new Set(); + Set used = new Set(); + ObjectObjectPair cur = subIters[0].getProjectionPaths(); + // Conditionals used and returned go to to used + used.addAll((Set)cur.getFirst()); + used.addAll((Set)cur.getSecond()); + return new ObjectObjectPair(returned, used); + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java 2012-02-07 08:51:38 UTC (rev 4519) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java 2012-02-07 08:53:50 UTC (rev 4520) @@ -15,6 +15,7 @@ package ch.ethz.mxquery.functions.fn; +import java.util.Enumeration; import java.util.Vector; import org.apache.xerces.xs.ShortList; @@ -35,15 +36,19 @@ import ch.ethz.mxquery.exceptions.ErrorCodes; import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.QueryLocation; +import ch.ethz.mxquery.exceptions.StaticException; import ch.ethz.mxquery.exceptions.TypeException; import ch.ethz.mxquery.functions.Function; import ch.ethz.mxquery.functions.xs.XSConstructorIterator; import ch.ethz.mxquery.functions.xs.XSQName; import ch.ethz.mxquery.iterators.SequenceIterator; import ch.ethz.mxquery.iterators.TokenIterator; +import ch.ethz.mxquery.model.AbstractStep; import ch.ethz.mxquery.model.CurrentBasedIterator; import ch.ethz.mxquery.model.EmptySequenceIterator; import ch.ethz.mxquery.model.XDMIterator; +import ch.ethz.mxquery.util.ObjectObjectPair; +import ch.ethz.mxquery.util.Set; import ch.ethz.mxquery.util.Utils; public class DataValuesIterator extends CurrentBasedIterator { @@ -743,4 +748,26 @@ copy.setContext(context, false); return copy; } + + public ObjectObjectPair getProjectionPaths() throws StaticException { + Set returned = new Set(); + Set used = new Set(); + + if (subIters != null) + for (int i=0;i<subIters.length;i++){ + ObjectObjectPair cur = subIters[i].getProjectionPaths(); + Enumeration returnedPaths = ((Set)cur.getFirst()).elements(); + while (returnedPaths.hasMoreElements()) { + Vector curRetPath = (Vector)returnedPaths.nextElement(); + Vector res = new Vector(); + res.addAll(curRetPath); + res.addElement(AbstractStep.KEEP_SUBTREE); + used.add(res); + } + used.addAll((Set)cur.getSecond()); + } + return new ObjectObjectPair(returned, used); + + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java 2012-02-07 08:51:38 UTC (rev 4519) +++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/Doc.java 2012-02-07 08:53:50 UTC (rev 4520) @@ -30,6 +30,7 @@ import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.functions.RequestTypeMulti; import ch.ethz.mxquery.iterators.TokenIterator; +import ch.ethz.mxquery.model.AbstractStep; import ch.ethz.mxquery.model.CurrentBasedIterator; import ch.ethz.mxquery.model.EmptySequenceIterator; import ch.ethz.mxquery.model.TokenSequenceIterator; @@ -256,7 +257,9 @@ public ObjectObjectPair getProjectionPaths() { Set returned = new Set(); - returned.add("/"); + Vector rPath = new Vector(); + rPath.addElement(AbstractStep.ROOT_STEP); + returned.add(rPath); return new ObjectObjectPair(returned, new Set()); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java 2012-02-07 08:51:38 UTC (rev 4519) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java 2012-02-07 08:53:50 UTC (rev 4520) @@ -30,6 +30,7 @@ import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.StaticException; import ch.ethz.mxquery.exceptions.TypeException; +import ch.ethz.mxquery.model.AbstractStep; import ch.ethz.mxquery.model.StepInformation; import ch.ethz.mxquery.model.CheckNodeType; import ch.ethz.mxquery.model.CurrentBasedIterator; @@ -181,16 +182,10 @@ Set returned = new Set(); Enumeration pathEnum = returnedBelow.elements(); while (pathEnum.hasMoreElements()) { - String res = (String) pathEnum.nextElement(); - if (res.endsWith("/")) - res = res.substring(0, res.length()-1); - if (namespace != null) - res = res+"/@{"+namespace+"}:"; - if (local != null) { - if (namespace == null) - res = res+"/@"; - res = res+local; - } + Vector prev = (Vector) pathEnum.nextElement(); + Vector res = new Vector(); + res.addAll(prev); + res.addElement(new AbstractStep(AXIS_ATTRIBUTE, stepData)); returned.add(res); } return new ObjectObjectPair(returned, paths.getSecond()); Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-02-07 08:51:38 UTC (rev 4519) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-02-07 08:53:50 UTC (rev 4520) @@ -39,6 +39,7 @@ import ch.ethz.mxquery.model.Window; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.KXmlSerializer; +import ch.ethz.mxquery.util.LogLevel; import ch.ethz.mxquery.util.ObjectObjectPair; import ch.ethz.mxquery.util.Set; @@ -271,8 +272,13 @@ Set returned = new Set(); Enumeration pathEnum = returnedBelow.elements(); while (pathEnum.hasMoreElements()) { - Vector res = (Vector) pathEnum.nextElement(); - res.addElement(new AbstractStep(AXIS_CHILD, stepData)); + Vector res = new Vector(); + Vector prev = (Vector) pathEnum.nextElement(); + res.addAll(prev); + if (stepData.getXQName() != null) + res.addElement(new AbstractStep(AXIS_CHILD, stepData)); + else + logger.log(LogLevel.FINE, "Projection Paths for non-named nodetests currently not supported"); returned.add(res); } return new ObjectObjectPair(returned, paths.getSecond()); Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java 2012-02-07 08:51:38 UTC (rev 4519) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java 2012-02-07 08:53:50 UTC (rev 4520) @@ -462,7 +462,9 @@ Set returned = new Set(); Enumeration pathEnum = returnedBelow.elements(); while (pathEnum.hasMoreElements()) { - Vector res = (Vector) pathEnum.nextElement(); + Vector prev = (Vector) pathEnum.nextElement(); + Vector res = new Vector(); + res.addAll(prev); res.addElement(new AbstractStep(descAxis, stepData)); returned.add(res); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java 2012-02-07 08:51:38 UTC (rev 4519) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java 2012-02-07 08:53:50 UTC (rev 4520) @@ -42,6 +42,7 @@ import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.StaticException; import ch.ethz.mxquery.exceptions.TypeException; +import ch.ethz.mxquery.model.AbstractStep; import ch.ethz.mxquery.model.Iterator; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.KXmlSerializer; @@ -618,8 +619,11 @@ ObjectObjectPair cur = subIters[i].getProjectionPaths(); Enumeration returnedPaths = ((Set)cur.getFirst()).elements(); while (returnedPaths.hasMoreElements()) { - String curRetPath = (String)returnedPaths.nextElement(); - used.add(curRetPath+" #"); + Vector curRetPath = (Vector)returnedPaths.nextElement(); + Vector res = new Vector(); + res.addAll(curRetPath); + res.addElement(AbstractStep.KEEP_SUBTREE); + used.add(res); } used.addAll((Set)cur.getSecond()); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/model/AbstractStep.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/model/AbstractStep.java 2012-02-07 08:51:38 UTC (rev 4519) +++ trunk/MXQuery/src/ch/ethz/mxquery/model/AbstractStep.java 2012-02-07 08:53:50 UTC (rev 4520) @@ -49,6 +49,10 @@ else return "attribute::"; + case AXIS_DESCENDANT: + return "descendant::"; + case 99: + return "#"; default: throw new RuntimeException(); } Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 08:51:38 UTC (rev 4519) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 08:53:50 UTC (rev 4520) @@ -13,11 +13,43 @@ * limitations under the License. */ + +/* + * Contains the document projection logic outlined in the Marian/Simeon paper: + * Automaton to express what to do with the current event + * KEEP: this node (but not its descendants) should be kept + * KEEP_SUB: this node and its descendants should be kept + * SKIP: the current node/event should be discarded + * MOVE: the current node/event is on a projection path, but not at its end. It may have to be kept if we match a KEEP/KEEP_SUB node at the end of this path + * + * We keep track of the level on which we switched to SKIP/SUB_KEEP: top skip, top keep node => skipKeepLevel + * + * Transitions: + * + * Driven by opening tags + * MOVE->KEEP: We reach the end of a projection path, match the name and do not keep descendants => produce + * MOVE->KEEP_SUB: end of projection path with + * MOVE->SKIP: At some of the projection path, we do not match the name + * KEEP->SKIP: produced the kept node, go "deeper" + * MOVE->MOVE: on a projection path, match name + * SKIP->SKIP: any opening tag + * KEEP_SUB->KEEP_SUB: any opening tag + * + * Driven by closing tags + * SKIP->KEEP: reached skipKeepLevel, level above matched + * SKIP->MOVE: reached skipKeepLevel, level above did not match + * KEEP->MOVE: produced the closing tag of kept node + * KEEP_SUB->MOVE: reached skipKeepLevel + * MOVE->MOVE: on a projection path, match name close + * SKIP->SKIP: any closing tag greater than skipKeepLevel + * KEEP_SUB->KEEP_SUB: any closing tag greater than skipKeepLevel + */ package ch.ethz.mxquery.xdmio.xmlAdapters; import java.util.ArrayList; import java.util.LinkedList; import java.util.Vector; +import java.util.Stack; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; @@ -39,8 +71,8 @@ import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.model.AbstractStep; import ch.ethz.mxquery.model.XDMIterator; -import ch.ethz.mxquery.util.Utils; + public class NonValidatingStaxAdapterProjection extends XDMImportAdapter { private XMLStreamReader reader; @@ -50,20 +82,27 @@ private int [] projPathPos; + private Stack bufferedPathName; + private Stack bufferedPathURI; + private Stack bufferedPathPrefix; + private Stack bufferedAttributes; + + private int pathProducedLevel = 0; + int skipKeepLevel = -1; - private int PROJ_MODE_NORMAL = 0; - private int PROJ_MODE_SKIP = 1; - private int PROJ_MODE_KEEP_SUB = 2; - private int PROJ_MODE_KEEP = 3; - private int PROJ_MODE_MOVE = 4; + private final int PROJ_MODE_SKIP = 1; + private final int PROJ_MODE_KEEP_SUB = 2; + private final int PROJ_MODE_KEEP = 3; + private final int PROJ_MODE_MOVE = 4; - int curProjMode = PROJ_MODE_NORMAL; + int curProjMode = PROJ_MODE_MOVE; public NonValidatingStaxAdapterProjection(Context ctx, QueryLocation loc, XMLStreamReader reader) { super(ctx, loc); this.reader = reader; this.tokensList = new LinkedList(); + this.bufferedPathName = new Stack(); } private TokenInterface getNext() { @@ -82,11 +121,10 @@ case XMLStreamConstants.CHARACTERS: case XMLStreamConstants.SPACE: { - if (curProjMode == PROJ_MODE_SKIP) { + if (curProjMode == PROJ_MODE_SKIP || curProjMode == PROJ_MODE_MOVE) { reader.next(); continue; } - StringBuffer mergedText = new StringBuffer(); while (event == XMLStreamConstants.CDATA || event == XMLStreamConstants.SPACE || event == XMLStreamConstants.CHARACTERS) { mergedText.append(reader.getText()); @@ -96,7 +134,7 @@ return new TextToken(Type.TEXT_NODE_UNTYPED_ATOMIC, createNextTokenId(Type.TEXT_NODE_UNTYPED_ATOMIC, null), mergedText.toString(),curNsScope); } case XMLStreamConstants.COMMENT: - if (curProjMode == PROJ_MODE_SKIP) + if (curProjMode == PROJ_MODE_SKIP || curProjMode == PROJ_MODE_MOVE) continue; tok = new CommentToken(createNextTokenId(Type.COMMENT, null), reader.getText(),curNsScope); @@ -104,54 +142,120 @@ case XMLStreamConstants.END_DOCUMENT: tok = new Token(Type.END_DOCUMENT,null,curNsScope); break; - case XMLStreamConstants.END_ELEMENT: - String name = reader.getLocalName(); - String ns_uri = reader.getNamespaceURI(); - String prefix = reader.getPrefix(); - if (prefix != null && prefix.length() == 0) - prefix = null; - // - boolean stillSkip = false; - if (curProjMode == PROJ_MODE_SKIP && level == skipKeepLevel) { - curProjMode = PROJ_MODE_KEEP; - skipKeepLevel = -1; - stillSkip = true; - } - if (curProjMode == PROJ_MODE_KEEP && projPathPos[0] > 0) { - XQName curPathCheck = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0])).getNodeTest().getXQName(); - if (curPathCheck.getLocalPart().equals(name)) { //TODO: Handle namespaces - projPathPos[0]--; + case XMLStreamConstants.END_ELEMENT: { + boolean emitTag = false; + String name_debug = reader.getLocalName(); + switch (curProjMode) { + case PROJ_MODE_KEEP_SUB: + //KEEP_SUB->MOVE: reached skipKeepLevel + //KEEP_SUB->KEEP_SUB: any closing tag greater than skipKeepLevel + if (skipKeepLevel == level) { + curProjMode = PROJ_MODE_MOVE; + skipKeepLevel = -1; + pathProducedLevel--; + } + emitTag = true; + break; + case PROJ_MODE_SKIP: + // go to "KEEP", check later if we keep or move + + if (skipKeepLevel == level+1) { + curProjMode = PROJ_MODE_MOVE; + if (pathProducedLevel >= level) { + emitTag = true; + pathProducedLevel--; } - if (projPathPos[0]+2 >= ((Vector)projectionPaths.get(0)).size()) - stillSkip = false; - } + skipKeepLevel = -1; + } + else + if (skipKeepLevel == level) { + String name = reader.getLocalName(); + + Vector path = (Vector)projectionPaths.get(0); - if (curProjMode == PROJ_MODE_MOVE && projPathPos[0] > 0) { + XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[0])).getNodeTest().getXQName(); + if (curPathCheck.getLocalPart().equals(name) || level != projPathPos[0]) { + curProjMode = PROJ_MODE_KEEP; + } else { + curProjMode = PROJ_MODE_MOVE; + } + skipKeepLevel = -1; + } + else { + reader.next(); + level--; + continue; + } + break; + case PROJ_MODE_MOVE: { + String name = reader.getLocalName(); XQName curPathCheck = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0]-1)).getNodeTest().getXQName(); - if (curPathCheck.getLocalPart().equals(name)) { //TODO: Handle namespaces - projPathPos[0]--; - } - } - - if (curProjMode == PROJ_MODE_KEEP_SUB && level == skipKeepLevel-1) { - XQName curPathCheck = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0]-1)).getNodeTest().getXQName(); if (!curPathCheck.getLocalPart().equals(name)) throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck.getLocalPart()+" saw "+name, loc); - curProjMode = PROJ_MODE_MOVE; - skipKeepLevel = -1; - projPathPos[0]-=2; // go back from the "keep" pseudo node + + if (pathProducedLevel >= level) { + emitTag = true; + pathProducedLevel--; + } + projPathPos[0]--; + bufferedPathName.pop(); + } break; + case PROJ_MODE_KEEP: { + + //decide if keep or move directly, when we came from SKIP + //SKIP->KEEP: reached skipKeepLevel, level above matched + // SKIP->MOVE: reached skipKeepLevel, level above did not match + String name = reader.getLocalName(); + + Vector path = (Vector)projectionPaths.get(0); + + if (path.size() == projPathPos[0]+1) {// last element in path, and not a "KEEP" + // really keep + emitTag = true; + } else { + curProjMode = PROJ_MODE_MOVE; + if (bufferedPathName.size() > level && bufferedPathName.get(level).equals(name)) { + emitTag = true; + + } + bufferedPathName.pop(); + projPathPos[0]--; + } + XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[0])).getNodeTest().getXQName(); + if (!curPathCheck.getLocalPart().equals(name)) + throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck.getLocalPart()+" saw "+name, loc); + //projPathPos[0]--; + curProjMode = PROJ_MODE_MOVE; + + pathProducedLevel--; } - if (curProjMode != PROJ_MODE_SKIP && !stillSkip) { + + /* + * KEEP->MOVE: produced the closing tag of kept node + * MOVE->MOVE: on a projection path, match name close + * SKIP->SKIP: any closing tag greater than skipKeepLevel + */ + } + + + // + if (emitTag) { + String name = reader.getLocalName(); + String ns_uri = reader.getNamespaceURI(); + String prefix = reader.getPrefix(); + if (prefix != null && prefix.length() == 0) + prefix = null; XQName tName = new QName(ns_uri, prefix, name); tok = new ElementToken(Type.END_TAG, null, tName, curNsScope); checkCloseNsScope(); - stillSkip = false; - } - level--; - if (curProjMode == PROJ_MODE_SKIP || stillSkip) { + level--; + } else { reader.next(); + level--; continue; } + + } break; case XMLStreamConstants.ENTITY_DECLARATION: // not used break; @@ -160,12 +264,12 @@ case XMLStreamConstants.NAMESPACE: break; case XMLStreamConstants.NOTATION_DECLARATION: - if (curProjMode == PROJ_MODE_SKIP) + if (curProjMode == PROJ_MODE_SKIP || curProjMode == PROJ_MODE_MOVE) continue; tok = new TextToken(createNextTokenId(Type.NOTATION, null), reader.getText()); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: - if (curProjMode == PROJ_MODE_SKIP) + if (curProjMode == PROJ_MODE_SKIP || curProjMode == PROJ_MODE_MOVE) continue; tok = new ProcessingInstrToken(createNextTokenId(Type.PROCESSING_INSTRUCTION, null), reader.getPIData(), reader.getPITarget(),curNsScope); break; @@ -180,7 +284,7 @@ break; case XMLStreamConstants.START_ELEMENT: level++; - + // "shortcut": if we skip, we do not even have to retrieve names etc if (curProjMode == PROJ_MODE_SKIP) { reader.next(); continue; @@ -193,112 +297,151 @@ String [] xmlIdREFS = null; boolean createdNSScope = false; - name = reader.getLocalName(); - ns_uri = reader.getNamespaceURI(); - prefix = reader.getPrefix(); - + String name = reader.getLocalName(); + String ns_uri = reader.getNamespaceURI(); + String prefix = reader.getPrefix(); + if (prefix != null && prefix.length() == 0) + prefix = null; + // projection: + boolean emitTag = false; + // check if node name fits with currently active paths - boolean skipOnNext = false; - as = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0])); - if (as == AbstractStep.KEEP_SUBTREE) { - curProjMode = PROJ_MODE_KEEP_SUB; - skipKeepLevel = level; - } - else { - XQName curPathCheck = as.getNodeTest().getXQName(); - if (curPathCheck.getLocalPart().equals(name)) { //TODO: Handle namespaces - if (((Vector)projectionPaths.get(0)).size() <= projPathPos[0]+1) { - curProjMode = PROJ_MODE_SKIP; - skipOnNext = true; - skipKeepLevel = level; - } - else { - projPathPos[0]++; - curProjMode = PROJ_MODE_MOVE; - } + switch (curProjMode) { + case PROJ_MODE_KEEP_SUB: + emitTag = true; // no check, just output + break; - } else { - curProjMode = PROJ_MODE_SKIP; - skipKeepLevel = level; + case PROJ_MODE_MOVE: + as = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0])); + if (as == AbstractStep.KEEP_SUBTREE) { + curProjMode = PROJ_MODE_KEEP_SUB; + skipKeepLevel = level; + emitTag = true; + } else { + XQName curPathCheck = as.getNodeTest().getXQName(); + if (curPathCheck.getLocalPart().equals(name)) { //TODO: Handle namespaces + // check name: if true, then either keep or move + Vector path = ((Vector)projectionPaths.get(0)); + if (path.size() <= projPathPos[0]+1) { + tok = extractPendingElements( + name, + ns_uri, + prefix); + curProjMode = PROJ_MODE_KEEP; + skipKeepLevel = level+1; + } + else if (path.elementAt(path.size()-1)==AbstractStep.KEEP_SUBTREE && path.size() <= projPathPos[0]+2) { + tok = extractPendingElements( + name, + ns_uri, + prefix); + curProjMode = PROJ_MODE_KEEP_SUB; + skipKeepLevel = level; + } + else { + projPathPos[0]++; + curProjMode = PROJ_MODE_MOVE; + bufferedPathName.push(name); + reader.next(); + continue; //buffer contents until we find a projection result + } + + } else { // otherwise go to skip + skipKeepLevel = level; + curProjMode = PROJ_MODE_SKIP; + } + } + + break; + case PROJ_MODE_KEEP: { + //emitTag = true; + skipKeepLevel = level; + curProjMode = PROJ_MODE_SKIP; + } + break; + // we handled SKIP already above } - } - if (curProjMode == PROJ_MODE_SKIP && !skipOnNext) { + if (curProjMode == PROJ_MODE_SKIP) { reader.next(); continue; } - if (prefix != null && prefix.length() == 0) + if (emitTag) { + if (prefix != null && prefix.length() == 0) prefix = null; - XQName tName = new QName(ns_uri, prefix, name); - tok = new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope); - - for (int i = 0; i < reader.getNamespaceCount(); i++) { - String namespacePrefix = reader.getNamespacePrefix(i); - String namespaceUri = reader.getNamespaceURI(i); - XQName q; - if (namespacePrefix == null) - q = new QName(null, "xmlns"); - else - q = new QName("xmlns", namespacePrefix); - boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, q, namespaceUri); - if (newOpened && !createdNSScope) - tok = new ElementToken(Type.START_TAG, tok.getNodeId(), tName, curNsScope); + XQName tName = new QName(ns_uri, prefix, name); + tok = new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope); } + if (curProjMode == PROJ_MODE_KEEP) + curProjMode = PROJ_MODE_SKIP; +// TODO: restore namespace and attribute processing +// for (int i = 0; i < reader.getNamespaceCount(); i++) { +// String namespacePrefix = reader.getNamespacePrefix(i); +// String namespaceUri = reader.getNamespaceURI(i); +// XQName q; +// if (namespacePrefix == null) +// q = new QName(null, "xmlns"); +// else +// q = new QName("xmlns", namespacePrefix); +// boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, q, namespaceUri); +// if (newOpened && !createdNSScope) +// tok = new ElementToken(Type.START_TAG, tok.getNodeId(), tName, curNsScope); +// } - for (int i = 0, n = reader.getAttributeCount(); i < n; ++i) { - javax.xml.namespace.QName qName = reader.getAttributeName(i); - name = qName.getLocalPart(); - ns_uri = qName.getNamespaceURI(); - prefix = qName.getPrefix(); - - - - if (prefix.length() == 0) - prefix = null; - XQName q = new QName(ns_uri, prefix, name); - String value = reader.getAttributeValue(i); - - String attType = reader.getAttributeType(i); - - if (!foundId && (attType.equals("ID") || isXMLId(tName,q))) { - foundId = true; - xmlId = value; - } - if (!foundIdREFS && (attType.equals("IDREF") || isIDREF(tName,q))) { - foundIdREFS = true; - xmlIdREFS = new String[]{value}; - } - - if (!foundIdREFS && (attType.equals("IDREFS") || isIDREFS(tName,q))) { - foundIdREFS = true; - xmlIdREFS = Utils.split(value," ", false); - } - - - boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, q, value); - if (newOpened && !createdNSScope) - tok = new ElementToken(Type.START_TAG, tok.getNodeId(), tName, curNsScope); - - if (q.getNamespacePrefix() == null || q.getNamespacePrefix().equals("")) { - if (q.getLocalPart().equals("xmlns")) - continue; - } else if (q.getNamespacePrefix().equals("xmlns")) - continue; - NamedToken attToken = createAttributeToken(Type.UNTYPED_ATOMIC, value, q, curNsScope); - tokensList.add(attToken); - - if (foundId) { - NamedToken nmToken = (NamedToken) tok ; - nmToken.setID(xmlId); - } - if (foundIdREFS) { - NamedToken nmToken = (NamedToken) tok; - nmToken.setIDREFS(xmlIdREFS); - } - - - } +// for (int i = 0, n = reader.getAttributeCount(); i < n; ++i) { +// javax.xml.namespace.QName qName = reader.getAttributeName(i); +// name = qName.getLocalPart(); +// ns_uri = qName.getNamespaceURI(); +// prefix = qName.getPrefix(); +// +// +// +// if (prefix.length() == 0) +// prefix = null; +// XQName q = new QName(ns_uri, prefix, name); +// String value = reader.getAttributeValue(i); +// +// String attType = reader.getAttributeType(i); +// +// if (!foundId && (attType.equals("ID") || isXMLId(tName,q))) { +// foundId = true; +// xmlId = value; +// } +// if (!foundIdREFS && (attType.equals("IDREF") || isIDREF(tName,q))) { +// foundIdREFS = true; +// xmlIdREFS = new String[]{value}; +// } +// +// if (!foundIdREFS && (attType.equals("IDREFS") || isIDREFS(tName,q))) { +// foundIdREFS = true; +// xmlIdREFS = Utils.split(value," ", false); +// } +// +// +// boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, q, value); +// if (newOpened && !createdNSScope) +// tok = new ElementToken(Type.START_TAG, tok.getNodeId(), tName, curNsScope); +// +// if (q.getNamespacePrefix() == null || q.getNamespacePrefix().equals("")) { +// if (q.getLocalPart().equals("xmlns")) +// continue; +// } else if (q.getNamespacePrefix().equals("xmlns")) +// continue; +// NamedToken attToken = createAttributeToken(Type.UNTYPED_ATOMIC, value, q, curNsScope); +// tokensList.add(attToken); +// +// if (foundId) { +// NamedToken nmToken = (NamedToken) tok ; +// nmToken.setID(xmlId); +// } +// if (foundIdREFS) { +// NamedToken nmToken = (NamedToken) tok; +// nmToken.setIDREFS(xmlIdREFS); +// } +// +// +// } break; default: } @@ -326,6 +469,20 @@ return Token.END_SEQUENCE_TOKEN; } + private TokenInterface extractPendingElements(String name, String ns_uri, + String prefix) { + // we have reached the end of the path, and no subtree is needed: KEEP + // emit all the pending element nodes + for (int i=pathProducedLevel; i<bufferedPathName.size();i++) { + XQName tName = new QName(null, null, (String)bufferedPathName.elementAt(i)); + tokensList.add(new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope)); + } + XQName tName = new QName(ns_uri, prefix, name); + tokensList.add(new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope)); + pathProducedLevel = level; + return (TokenInterface)tokensList.removeFirst(); + } + public TokenInterface next() throws MXQueryException { if (!tokensList.isEmpty()) { TokenInterface tok = (TokenInterface) tokensList.removeFirst(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 08:51:47
|
Revision: 4519 http://mxquery.svn.sourceforge.net/mxquery/?rev=4519&view=rev Author: pm_fischer Date: 2012-02-07 08:51:38 +0000 (Tue, 07 Feb 2012) Log Message: ----------- Single path works for keep/keep sub Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 08:50:27 UTC (rev 4518) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 08:51:38 UTC (rev 4519) @@ -34,8 +34,10 @@ import ch.ethz.mxquery.datamodel.xdm.TextToken; import ch.ethz.mxquery.datamodel.xdm.Token; import ch.ethz.mxquery.datamodel.xdm.TokenInterface; +import ch.ethz.mxquery.exceptions.ErrorCodes; import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.QueryLocation; +import ch.ethz.mxquery.model.AbstractStep; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.util.Utils; @@ -48,8 +50,8 @@ private int [] projPathPos; + int skipKeepLevel = -1; - private int PROJ_MODE_NORMAL = 0; private int PROJ_MODE_SKIP = 1; private int PROJ_MODE_KEEP_SUB = 2; @@ -69,6 +71,7 @@ if (endOfSeq) return tok; try { + while (reader.hasNext()) { int event = reader.getEventType(); switch (event) { case XMLStreamConstants.ATTRIBUTE: @@ -79,6 +82,11 @@ case XMLStreamConstants.CHARACTERS: case XMLStreamConstants.SPACE: { + if (curProjMode == PROJ_MODE_SKIP) { + reader.next(); + continue; + } + StringBuffer mergedText = new StringBuffer(); while (event == XMLStreamConstants.CDATA || event == XMLStreamConstants.SPACE || event == XMLStreamConstants.CHARACTERS) { mergedText.append(reader.getText()); @@ -88,6 +96,9 @@ return new TextToken(Type.TEXT_NODE_UNTYPED_ATOMIC, createNextTokenId(Type.TEXT_NODE_UNTYPED_ATOMIC, null), mergedText.toString(),curNsScope); } case XMLStreamConstants.COMMENT: + if (curProjMode == PROJ_MODE_SKIP) + continue; + tok = new CommentToken(createNextTokenId(Type.COMMENT, null), reader.getText(),curNsScope); break; case XMLStreamConstants.END_DOCUMENT: @@ -99,10 +110,48 @@ String prefix = reader.getPrefix(); if (prefix != null && prefix.length() == 0) prefix = null; - XQName tName = new QName(ns_uri, prefix, name); - tok = new ElementToken(Type.END_TAG, null, tName, curNsScope); - checkCloseNsScope(); + // + boolean stillSkip = false; + if (curProjMode == PROJ_MODE_SKIP && level == skipKeepLevel) { + curProjMode = PROJ_MODE_KEEP; + skipKeepLevel = -1; + stillSkip = true; + } + if (curProjMode == PROJ_MODE_KEEP && projPathPos[0] > 0) { + XQName curPathCheck = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0])).getNodeTest().getXQName(); + if (curPathCheck.getLocalPart().equals(name)) { //TODO: Handle namespaces + projPathPos[0]--; + } + if (projPathPos[0]+2 >= ((Vector)projectionPaths.get(0)).size()) + stillSkip = false; + } + + if (curProjMode == PROJ_MODE_MOVE && projPathPos[0] > 0) { + XQName curPathCheck = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0]-1)).getNodeTest().getXQName(); + if (curPathCheck.getLocalPart().equals(name)) { //TODO: Handle namespaces + projPathPos[0]--; + } + } + + if (curProjMode == PROJ_MODE_KEEP_SUB && level == skipKeepLevel-1) { + XQName curPathCheck = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0]-1)).getNodeTest().getXQName(); + if (!curPathCheck.getLocalPart().equals(name)) + throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck.getLocalPart()+" saw "+name, loc); + curProjMode = PROJ_MODE_MOVE; + skipKeepLevel = -1; + projPathPos[0]-=2; // go back from the "keep" pseudo node + } + if (curProjMode != PROJ_MODE_SKIP && !stillSkip) { + XQName tName = new QName(ns_uri, prefix, name); + tok = new ElementToken(Type.END_TAG, null, tName, curNsScope); + checkCloseNsScope(); + stillSkip = false; + } level--; + if (curProjMode == PROJ_MODE_SKIP || stillSkip) { + reader.next(); + continue; + } break; case XMLStreamConstants.ENTITY_DECLARATION: // not used break; @@ -111,17 +160,32 @@ case XMLStreamConstants.NAMESPACE: break; case XMLStreamConstants.NOTATION_DECLARATION: + if (curProjMode == PROJ_MODE_SKIP) + continue; tok = new TextToken(createNextTokenId(Type.NOTATION, null), reader.getText()); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: + if (curProjMode == PROJ_MODE_SKIP) + continue; tok = new ProcessingInstrToken(createNextTokenId(Type.PROCESSING_INSTRUCTION, null), reader.getPIData(), reader.getPITarget(),curNsScope); break; case XMLStreamConstants.START_DOCUMENT: + AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0])); + if (as == AbstractStep.ROOT_STEP) { + projPathPos[0]++; + curProjMode = PROJ_MODE_MOVE; + } + tok = new Token(Type.START_DOCUMENT,createNextTokenId(Type.START_DOCUMENT, null),curNsScope); break; case XMLStreamConstants.START_ELEMENT: level++; + if (curProjMode == PROJ_MODE_SKIP) { + reader.next(); + continue; + } + boolean foundId = false; boolean foundIdREFS = false; @@ -136,11 +200,37 @@ // projection: // check if node name fits with currently active paths - - + boolean skipOnNext = false; + as = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0])); + if (as == AbstractStep.KEEP_SUBTREE) { + curProjMode = PROJ_MODE_KEEP_SUB; + skipKeepLevel = level; + } + else { + XQName curPathCheck = as.getNodeTest().getXQName(); + if (curPathCheck.getLocalPart().equals(name)) { //TODO: Handle namespaces + if (((Vector)projectionPaths.get(0)).size() <= projPathPos[0]+1) { + curProjMode = PROJ_MODE_SKIP; + skipOnNext = true; + skipKeepLevel = level; + } + else { + projPathPos[0]++; + curProjMode = PROJ_MODE_MOVE; + } + + } else { + curProjMode = PROJ_MODE_SKIP; + skipKeepLevel = level; + } + } + if (curProjMode == PROJ_MODE_SKIP && !skipOnNext) { + reader.next(); + continue; + } if (prefix != null && prefix.length() == 0) prefix = null; - tName = new QName(ns_uri, prefix, name); + XQName tName = new QName(ns_uri, prefix, name); tok = new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope); for (int i = 0; i < reader.getNamespaceCount(); i++) { @@ -212,6 +302,9 @@ break; default: } + if (tok != null) + break; + } if (reader.hasNext()) reader.next(); else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 08:50:37
|
Revision: 4518 http://mxquery.svn.sourceforge.net/mxquery/?rev=4518&view=rev Author: pm_fischer Date: 2012-02-07 08:50:27 +0000 (Tue, 07 Feb 2012) Log Message: ----------- Some refactoring to generalize axis/node test Represent projection paths as vectors of abstract node test instead of strings Introduce STAX projection adapter Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/FullAxisIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/SelfAxisIterator.java trunk/MXQuery/src/ch/ethz/mxquery/iterators/scripting/WSFunction.java trunk/MXQuery/src/ch/ethz/mxquery/query/optimizer/TermVisitor.java trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XMLSource.java trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java Added Paths: ----------- trunk/MXQuery/src/ch/ethz/mxquery/model/AbstractStep.java trunk/MXQuery/src/ch/ethz/mxquery/model/StepInformation.java trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java Removed Paths: ------------- trunk/MXQuery/src/ch/ethz/mxquery/iterators/AxisIterator.java Modified: trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/contextConfig/Context.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -185,6 +185,8 @@ public static final int NONVALIDATED_INPUT_MODE_SAX = 2; public static final int NONVALIDATED_INPUT_MODE_DOM = 3; public static final int NONVALIDATED_INPUT_MODE_SAX_TIDY = 4; + public static final int NONVALIDATED_INPUT_MODE_STAX_PROJECTION = 5; + public static final int NO_VALIDATION = 0; public static final int IGNORE_DTD = 1; Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -30,6 +30,7 @@ import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.StaticException; import ch.ethz.mxquery.exceptions.TypeException; +import ch.ethz.mxquery.model.StepInformation; import ch.ethz.mxquery.model.CheckNodeType; import ch.ethz.mxquery.model.CurrentBasedIterator; import ch.ethz.mxquery.model.XDMIterator; @@ -43,7 +44,7 @@ * @author Matthias Braun * */ -public class AttributeIterator extends CurrentBasedIterator implements AxisIterator{ +public class AttributeIterator extends CurrentBasedIterator implements StepInformation{ private String local = null; @@ -195,6 +196,10 @@ return new ObjectObjectPair(returned, paths.getSecond()); } + public TypeInfo getNodeTest() { + return stepData; + } + } Deleted: trunk/MXQuery/src/ch/ethz/mxquery/iterators/AxisIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/AxisIterator.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/AxisIterator.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -1,21 +0,0 @@ -package ch.ethz.mxquery.iterators; - -public interface AxisIterator { - - public static final int AXIS_SELF = 1; - public static final int AXIS_CHILD = 2; - public static final int AXIS_DESCENDANT = 4; - public static final int AXIS_SELF_DESCENDANT = 5; - public static final int AXIS_PARENT = 18; - public static final int AXIS_ANCESTOR = 20; - public static final int AXIS_SELF_ANCESTOR = 21; - public static final int AXIS_FOLLOWING = 6; - public static final int AXIS_PRECEDING = 22; - public static final int AXIS_FOLLOWING_SIBLING = 8; - public static final int AXIS_PRECEDING_SIBLING = 24; - public static final int BACKWARD_AXIS_MASK = 16; - public static final int SELF_AXIS_MASK = 1; - public static final int AXIS_ATTRIBUTE = 10; - public abstract int getDirection(); - -} \ No newline at end of file Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -31,6 +31,8 @@ import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.StaticException; import ch.ethz.mxquery.exceptions.TypeException; +import ch.ethz.mxquery.model.AbstractStep; +import ch.ethz.mxquery.model.StepInformation; import ch.ethz.mxquery.model.CheckNodeType; import ch.ethz.mxquery.model.CurrentBasedIterator; import ch.ethz.mxquery.model.VariableHolder; @@ -45,7 +47,7 @@ * @author Matthias Braun * */ -public class ChildIterator extends CurrentBasedIterator implements AxisIterator { +public class ChildIterator extends CurrentBasedIterator implements StepInformation { protected String lastStep; @@ -78,11 +80,6 @@ } - public String getStepName() { - return stepData.getXQName().toString(); - } - - public XDMIterator staticInit() throws MXQueryException{ if (subIters != null) { this.current = subIters[0]; @@ -274,19 +271,15 @@ Set returned = new Set(); Enumeration pathEnum = returnedBelow.elements(); while (pathEnum.hasMoreElements()) { - String res = (String) pathEnum.nextElement(); - if (res.endsWith("/")) - res = res.substring(0, res.length()-1); - if (step_uri != null) - res = res+"/{"+step_uri+"}:"; - if (step_local != null) { - if (step_uri == null) - res = res+"/"; - res = res+step_local; - } + Vector res = (Vector) pathEnum.nextElement(); + res.addElement(new AbstractStep(AXIS_CHILD, stepData)); returned.add(res); } return new ObjectObjectPair(returned, paths.getSecond()); + } + + public TypeInfo getNodeTest() { + return stepData; } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -33,6 +33,8 @@ import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.StaticException; import ch.ethz.mxquery.exceptions.TypeException; +import ch.ethz.mxquery.model.AbstractStep; +import ch.ethz.mxquery.model.StepInformation; import ch.ethz.mxquery.model.CheckNodeType; import ch.ethz.mxquery.model.CurrentBasedIterator; import ch.ethz.mxquery.model.VariableHolder; @@ -49,7 +51,7 @@ * @author Matthias Braun * */ -public class DescendantOrSelfIterator extends CurrentBasedIterator implements AxisIterator{ +public class DescendantOrSelfIterator extends CurrentBasedIterator implements StepInformation{ private boolean match = false; @@ -460,20 +462,17 @@ Set returned = new Set(); Enumeration pathEnum = returnedBelow.elements(); while (pathEnum.hasMoreElements()) { - String res = (String) pathEnum.nextElement(); - if (res.endsWith("/")) - res = res.substring(0, res.length()-1); - if (step_uri != null) - res = res+"//{"+step_uri+"}:"; - if (step_local != null) { - if (step_uri == null) - res = res+"//"; - res = res+step_local; - } + Vector res = (Vector) pathEnum.nextElement(); + res.addElement(new AbstractStep(descAxis, stepData)); returned.add(res); } return new ObjectObjectPair(returned, paths.getSecond()); } + + + public TypeInfo getNodeTest() { + return stepData; + } } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/FullAxisIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/FullAxisIterator.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/FullAxisIterator.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -31,6 +31,7 @@ import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.TypeException; +import ch.ethz.mxquery.model.StepInformation; import ch.ethz.mxquery.model.CheckNodeType; import ch.ethz.mxquery.model.CurrentBasedIterator; import ch.ethz.mxquery.model.DataflowAnalysis; @@ -40,7 +41,7 @@ import ch.ethz.mxquery.model.updatePrimitives.ExtendedAxisStore; import ch.ethz.mxquery.util.Set; -public class FullAxisIterator extends CurrentBasedIterator implements AxisIterator { +public class FullAxisIterator extends CurrentBasedIterator implements StepInformation { private TypeInfo stepData = null; private String step_local = null; @@ -292,5 +293,9 @@ return super.staticInit(); } + public TypeInfo getNodeTest() { + return stepData; + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/SelfAxisIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/SelfAxisIterator.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/SelfAxisIterator.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -29,12 +29,13 @@ import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.QueryLocation; import ch.ethz.mxquery.exceptions.TypeException; +import ch.ethz.mxquery.model.StepInformation; import ch.ethz.mxquery.model.CheckNodeType; import ch.ethz.mxquery.model.CurrentBasedIterator; import ch.ethz.mxquery.model.Window; import ch.ethz.mxquery.model.XDMIterator; -public class SelfAxisIterator extends CurrentBasedIterator implements AxisIterator { +public class SelfAxisIterator extends CurrentBasedIterator implements StepInformation { private TypeInfo stepData = null; private String step_local = null; @@ -147,7 +148,7 @@ } public int getDirection() { - return AxisIterator.AXIS_SELF; + return StepInformation.AXIS_SELF; } protected void checkExpressionTypes() throws MXQueryException { if (!isScripting || context.getScriptingQueryMode() == XQStaticContext.SCRIPTING_MODE_SIMPLE) { @@ -170,5 +171,9 @@ return super.staticInit(); } + public TypeInfo getNodeTest() { + return stepData; + } + } Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/scripting/WSFunction.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/scripting/WSFunction.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/scripting/WSFunction.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -29,10 +29,10 @@ import ch.ethz.mxquery.exceptions.ErrorCodes; import ch.ethz.mxquery.exceptions.MXQueryException; import ch.ethz.mxquery.exceptions.QueryLocation; -import ch.ethz.mxquery.iterators.AxisIterator; import ch.ethz.mxquery.iterators.ChildIterator; import ch.ethz.mxquery.iterators.DescendantOrSelfIterator; import ch.ethz.mxquery.iterators.NodeIterator; +import ch.ethz.mxquery.model.StepInformation; import ch.ethz.mxquery.model.CurrentBasedIterator; import ch.ethz.mxquery.model.Iterator; import ch.ethz.mxquery.model.Wildcard; @@ -242,7 +242,7 @@ if (this.returnType == null || this.returnType.equals("")){//the return 'part' is an element TypeInfo stepInfo = new TypeInfo(Type.START_TAG,Type.OCCURRENCE_IND_EXACTLY_ONE,this.returnName); - current = new DescendantOrSelfIterator(context, stepInfo, AxisIterator.AXIS_SELF_DESCENDANT, new XDMIterator[] {xmlIt},loc); + current = new DescendantOrSelfIterator(context, stepInfo, StepInformation.AXIS_SELF_DESCENDANT, new XDMIterator[] {xmlIt},loc); // current = new NodeIterator(context, xmlIt,loc); }else if (this.returnType.equals("multiple-result")){//the return message has more than one 'part' //TODO: possible merging? Added: trunk/MXQuery/src/ch/ethz/mxquery/model/AbstractStep.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/model/AbstractStep.java (rev 0) +++ trunk/MXQuery/src/ch/ethz/mxquery/model/AbstractStep.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -0,0 +1,58 @@ +package ch.ethz.mxquery.model; + +import ch.ethz.mxquery.datamodel.XQName; +import ch.ethz.mxquery.datamodel.types.TypeInfo; + +public class AbstractStep implements StepInformation { + + public static final AbstractStep ROOT_STEP = new AbstractStep(0,(TypeInfo)null); + public static final AbstractStep KEEP_SUBTREE = new AbstractStep(99,(TypeInfo)null); + + public AbstractStep(int dir, TypeInfo ti) { + direction = dir; + nodeTestInfo = ti; + } + + public AbstractStep(int dir, XQName qn) { + direction = dir; + nodeTestInfo = new TypeInfo(); + nodeTestInfo.setXQName(qn); + } + + + private int direction = StepInformation.AXIS_SELF; + private TypeInfo nodeTestInfo = null; + public int getDirection() { + return direction; + } + + public TypeInfo getNodeTest() { + return nodeTestInfo; + } + + public String getDirectionString(boolean abbrv) { + switch (direction) { + case AXIS_CHILD: + if (abbrv) + return ""; + else + return "child::"; + case AXIS_PARENT: + if (abbrv) + return ".."; + else + return "parent::"; + + case AXIS_ATTRIBUTE: + if (abbrv) + return "@"; + else + return "attribute::"; + + default: + throw new RuntimeException(); + } + + } + +} Copied: trunk/MXQuery/src/ch/ethz/mxquery/model/StepInformation.java (from rev 4517, trunk/MXQuery/src/ch/ethz/mxquery/iterators/AxisIterator.java) =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/model/StepInformation.java (rev 0) +++ trunk/MXQuery/src/ch/ethz/mxquery/model/StepInformation.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -0,0 +1,25 @@ +package ch.ethz.mxquery.model; + +import ch.ethz.mxquery.datamodel.types.TypeInfo; + +public interface StepInformation { + + public static final int AXIS_SELF = 1; + public static final int AXIS_CHILD = 2; + public static final int AXIS_DESCENDANT = 4; + public static final int AXIS_SELF_DESCENDANT = 5; + public static final int AXIS_PARENT = 18; + public static final int AXIS_ANCESTOR = 20; + public static final int AXIS_SELF_ANCESTOR = 21; + public static final int AXIS_FOLLOWING = 6; + public static final int AXIS_PRECEDING = 22; + public static final int AXIS_FOLLOWING_SIBLING = 8; + public static final int AXIS_PRECEDING_SIBLING = 24; + public static final int BACKWARD_AXIS_MASK = 16; + public static final int SELF_AXIS_MASK = 1; + public static final int AXIS_ATTRIBUTE = 10; + public abstract int getDirection(); + + public abstract TypeInfo getNodeTest(); + +} \ No newline at end of file Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/optimizer/TermVisitor.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/query/optimizer/TermVisitor.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/query/optimizer/TermVisitor.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -16,10 +16,12 @@ import java.util.List; +import ch.ethz.mxquery.datamodel.types.TypeInfo; import ch.ethz.mxquery.functions.fn.DataValuesIterator; import ch.ethz.mxquery.iterators.AttributeIterator; import ch.ethz.mxquery.iterators.ChildIterator; import ch.ethz.mxquery.iterators.VariableIterator; +import ch.ethz.mxquery.model.StepInformation; import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.opt.expr.Literal; import ch.ethz.mxquery.opt.expr.LogicalUnit; @@ -100,20 +102,15 @@ */ private String getColumnName(XDMIterator expr){ XDMIterator iter = removeDataValuesIterator(expr); - String stepName = null; - ChildIterator childIter = getChildIterator(iter); XDMIterator nextIter=null; - if (childIter != null) { - stepName = childIter.getStepName(); - nextIter = childIter.getAllSubIters()[0]; + + if (iter instanceof StepInformation) { + TypeInfo ti = ((StepInformation)iter).getNodeTest(); + stepName = ti.getXQName().toString(); + nextIter = iter.getAllSubIters()[0]; } - AttributeIterator attrIter = getAttributeIterator(iter); - if (attrIter != null) { - stepName = attrIter.getAttrStep(); - nextIter = attrIter.getAllSubIters()[0]; - } - + if (stepName != null) { String nextStep = getColumnName(nextIter); if (nextStep != null) { Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMInputFactory.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -46,6 +46,7 @@ import ch.ethz.mxquery.xdmio.xmlAdapters.NonSchemaValidatingSaxImportAdapter; import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingDOMAdapter; import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingStaxAdapter; +import ch.ethz.mxquery.xdmio.xmlAdapters.NonValidatingStaxAdapterProjection; import ch.ethz.mxquery.xdmio.xmlAdapters.ValidatedSaxImportAdapter; import ch.ethz.mxquery.xdmio.xmlAdapters.XPPImportAdapter; @@ -71,7 +72,7 @@ return new NonSchemaValidatingSaxImportAdapter(ctx,location,new InputSource(xml), valMode, false); case Context.NONVALIDATED_INPUT_MODE_SAX_TIDY: return new NonSchemaValidatingSaxImportAdapter(ctx,location,new InputSource(xml), Context.NO_VALIDATION, true); - case Context.NONVALIDATED_INPUT_MODE_STAX: + case Context.NONVALIDATED_INPUT_MODE_STAX: { XMLInputFactory factory = XMLInputFactory.newInstance(); if (valMode == Context.NO_VALIDATION || valMode == Context.IGNORE_DTD) factory.setProperty("javax.xml.stream.supportDTD", Boolean.FALSE); @@ -83,6 +84,20 @@ } catch (XMLStreamException e) { throw new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing",location); } + } + case Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION: { + XMLInputFactory factory = XMLInputFactory.newInstance(); + if (valMode == Context.NO_VALIDATION || valMode == Context.IGNORE_DTD) + factory.setProperty("javax.xml.stream.supportDTD", Boolean.FALSE); + else + factory.setProperty("javax.xml.stream.supportDTD", Boolean.TRUE); + try { + XMLStreamReader reader = factory.createXMLStreamReader(xml); + return new NonValidatingStaxAdapterProjection(ctx,location,reader); + } catch (XMLStreamException e) { + throw new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing",location); + } + } case Context.NONVALIDATED_INPUT_MODE_DOM: DocumentBuilder parser; try { @@ -158,18 +173,32 @@ return new NonSchemaValidatingSaxImportAdapter(ctx,location,new InputSource(uri), valMode, false); case Context.NONVALIDATED_INPUT_MODE_SAX_TIDY: return new NonSchemaValidatingSaxImportAdapter(ctx,location,new InputSource(uri), Context.NO_VALIDATION, true); - case Context.NONVALIDATED_INPUT_MODE_STAX: + case Context.NONVALIDATED_INPUT_MODE_STAX: { XMLInputFactory factory = XMLInputFactory.newInstance(); - if (valMode == Context.NO_VALIDATION) - factory.setProperty("javax.xml.stream.supportDTD", "false"); + if (valMode == Context.NO_VALIDATION || valMode == Context.IGNORE_DTD) + factory.setProperty("javax.xml.stream.supportDTD", Boolean.FALSE); else - factory.setProperty("javax.xml.stream.supportDTD", "true"); + factory.setProperty("javax.xml.stream.supportDTD", Boolean.TRUE); try { XMLStreamReader reader = factory.createXMLStreamReader(new StreamSource(new File(uri))); return new NonValidatingStaxAdapter(ctx,location,reader); } catch (XMLStreamException e) { throw new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing",location); } + } + case Context.NONVALIDATED_INPUT_MODE_STAX_PROJECTION: { + XMLInputFactory factory = XMLInputFactory.newInstance(); + if (valMode == Context.NO_VALIDATION || valMode == Context.IGNORE_DTD) + factory.setProperty("javax.xml.stream.supportDTD", Boolean.FALSE); + else + factory.setProperty("javax.xml.stream.supportDTD", Boolean.TRUE); + try { + XMLStreamReader reader = factory.createXMLStreamReader(new StreamSource(new File(uri))); + return new NonValidatingStaxAdapterProjection(ctx,location,reader); + } catch (XMLStreamException e) { + throw new MXQueryException(ErrorCodes.A0007_EC_IO,"I/O Error while parsing",location); + } + } case Context.NONVALIDATED_INPUT_MODE_DOM: DocumentBuilder parser; try { Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XMLSource.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XMLSource.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XMLSource.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -15,6 +15,8 @@ package ch.ethz.mxquery.xdmio; +import java.util.Vector; + import ch.ethz.mxquery.model.XDMIterator; import ch.ethz.mxquery.datamodel.Source; @@ -36,5 +38,10 @@ * @return the root element name if the source was validated against a DTD */ public abstract String getRootElemDTD(); + /** + * Inform the source about the projection information + * @param paths + */ + public void setProjectionPaths(Vector paths); } Added: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java (rev 0) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -0,0 +1,259 @@ +/* Copyright 2006 - 2009 ETH Zurich + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.mxquery.xdmio.xmlAdapters; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.Vector; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import ch.ethz.mxquery.contextConfig.Context; +import ch.ethz.mxquery.datamodel.QName; +import ch.ethz.mxquery.datamodel.XQName; +import ch.ethz.mxquery.datamodel.types.Type; +import ch.ethz.mxquery.datamodel.xdm.CommentToken; +import ch.ethz.mxquery.datamodel.xdm.ElementToken; +import ch.ethz.mxquery.datamodel.xdm.NamedToken; +import ch.ethz.mxquery.datamodel.xdm.ProcessingInstrToken; +import ch.ethz.mxquery.datamodel.xdm.TextToken; +import ch.ethz.mxquery.datamodel.xdm.Token; +import ch.ethz.mxquery.datamodel.xdm.TokenInterface; +import ch.ethz.mxquery.exceptions.MXQueryException; +import ch.ethz.mxquery.exceptions.QueryLocation; +import ch.ethz.mxquery.model.XDMIterator; +import ch.ethz.mxquery.util.Utils; + +public class NonValidatingStaxAdapterProjection extends XDMImportAdapter { + private XMLStreamReader reader; + + private LinkedList tokensList; + + private ArrayList projectionPaths; + + private int [] projPathPos; + + + + private int PROJ_MODE_NORMAL = 0; + private int PROJ_MODE_SKIP = 1; + private int PROJ_MODE_KEEP_SUB = 2; + private int PROJ_MODE_KEEP = 3; + private int PROJ_MODE_MOVE = 4; + + int curProjMode = PROJ_MODE_NORMAL; + + public NonValidatingStaxAdapterProjection(Context ctx, QueryLocation loc, XMLStreamReader reader) { + super(ctx, loc); + this.reader = reader; + this.tokensList = new LinkedList(); + } + + private TokenInterface getNext() { + TokenInterface tok = Token.END_SEQUENCE_TOKEN; + if (endOfSeq) + return tok; + try { + int event = reader.getEventType(); + switch (event) { + case XMLStreamConstants.ATTRIBUTE: + break; + case XMLStreamConstants.DTD: + break; + case XMLStreamConstants.CDATA: + case XMLStreamConstants.CHARACTERS: + case XMLStreamConstants.SPACE: + { + StringBuffer mergedText = new StringBuffer(); + while (event == XMLStreamConstants.CDATA || event == XMLStreamConstants.SPACE || event == XMLStreamConstants.CHARACTERS) { + mergedText.append(reader.getText()); + reader.next(); + event = reader.getEventType(); + } + return new TextToken(Type.TEXT_NODE_UNTYPED_ATOMIC, createNextTokenId(Type.TEXT_NODE_UNTYPED_ATOMIC, null), mergedText.toString(),curNsScope); + } + case XMLStreamConstants.COMMENT: + tok = new CommentToken(createNextTokenId(Type.COMMENT, null), reader.getText(),curNsScope); + break; + case XMLStreamConstants.END_DOCUMENT: + tok = new Token(Type.END_DOCUMENT,null,curNsScope); + break; + case XMLStreamConstants.END_ELEMENT: + String name = reader.getLocalName(); + String ns_uri = reader.getNamespaceURI(); + String prefix = reader.getPrefix(); + if (prefix != null && prefix.length() == 0) + prefix = null; + XQName tName = new QName(ns_uri, prefix, name); + tok = new ElementToken(Type.END_TAG, null, tName, curNsScope); + checkCloseNsScope(); + level--; + break; + case XMLStreamConstants.ENTITY_DECLARATION: // not used + break; + case XMLStreamConstants.ENTITY_REFERENCE: + break; + case XMLStreamConstants.NAMESPACE: + break; + case XMLStreamConstants.NOTATION_DECLARATION: + tok = new TextToken(createNextTokenId(Type.NOTATION, null), reader.getText()); + break; + case XMLStreamConstants.PROCESSING_INSTRUCTION: + tok = new ProcessingInstrToken(createNextTokenId(Type.PROCESSING_INSTRUCTION, null), reader.getPIData(), reader.getPITarget(),curNsScope); + break; + case XMLStreamConstants.START_DOCUMENT: + tok = new Token(Type.START_DOCUMENT,createNextTokenId(Type.START_DOCUMENT, null),curNsScope); + break; + case XMLStreamConstants.START_ELEMENT: + level++; + + boolean foundId = false; + boolean foundIdREFS = false; + + String xmlId = null; + String [] xmlIdREFS = null; + + boolean createdNSScope = false; + name = reader.getLocalName(); + ns_uri = reader.getNamespaceURI(); + prefix = reader.getPrefix(); + + // projection: + + // check if node name fits with currently active paths + + + if (prefix != null && prefix.length() == 0) + prefix = null; + tName = new QName(ns_uri, prefix, name); + tok = new ElementToken(Type.START_TAG, createNextTokenId(Type.START_TAG, tName.toString()), tName, curNsScope); + + for (int i = 0; i < reader.getNamespaceCount(); i++) { + String namespacePrefix = reader.getNamespacePrefix(i); + String namespaceUri = reader.getNamespaceURI(i); + XQName q; + if (namespacePrefix == null) + q = new QName(null, "xmlns"); + else + q = new QName("xmlns", namespacePrefix); + boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, q, namespaceUri); + if (newOpened && !createdNSScope) + tok = new ElementToken(Type.START_TAG, tok.getNodeId(), tName, curNsScope); + } + + for (int i = 0, n = reader.getAttributeCount(); i < n; ++i) { + javax.xml.namespace.QName qName = reader.getAttributeName(i); + name = qName.getLocalPart(); + ns_uri = qName.getNamespaceURI(); + prefix = qName.getPrefix(); + + + + if (prefix.length() == 0) + prefix = null; + XQName q = new QName(ns_uri, prefix, name); + String value = reader.getAttributeValue(i); + + String attType = reader.getAttributeType(i); + + if (!foundId && (attType.equals("ID") || isXMLId(tName,q))) { + foundId = true; + xmlId = value; + } + if (!foundIdREFS && (attType.equals("IDREF") || isIDREF(tName,q))) { + foundIdREFS = true; + xmlIdREFS = new String[]{value}; + } + + if (!foundIdREFS && (attType.equals("IDREFS") || isIDREFS(tName,q))) { + foundIdREFS = true; + xmlIdREFS = Utils.split(value," ", false); + } + + + boolean newOpened = checkOpenNsScopeAddNs(createdNSScope, q, value); + if (newOpened && !createdNSScope) + tok = new ElementToken(Type.START_TAG, tok.getNodeId(), tName, curNsScope); + + if (q.getNamespacePrefix() == null || q.getNamespacePrefix().equals("")) { + if (q.getLocalPart().equals("xmlns")) + continue; + } else if (q.getNamespacePrefix().equals("xmlns")) + continue; + NamedToken attToken = createAttributeToken(Type.UNTYPED_ATOMIC, value, q, curNsScope); + tokensList.add(attToken); + + if (foundId) { + NamedToken nmToken = (NamedToken) tok ; + nmToken.setID(xmlId); + } + if (foundIdREFS) { + NamedToken nmToken = (NamedToken) tok; + nmToken.setIDREFS(xmlIdREFS); + } + + + } + break; + default: + } + if (reader.hasNext()) + reader.next(); + else { + endOfSeq = true; + } + return tok; + } catch (XMLStreamException e) { + e.printStackTrace(); + } catch (MXQueryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + try { + reader.close(); + } catch (XMLStreamException se) { + // TODO Auto-generated catch block + se.printStackTrace(); + } + } + return Token.END_SEQUENCE_TOKEN; + } + + public TokenInterface next() throws MXQueryException { + if (!tokensList.isEmpty()) { + TokenInterface tok = (TokenInterface) tokensList.removeFirst(); + return tok;//(Token) tokensList.remove(); + } + else { + TokenInterface tok = getNext(); + return tok; + } + } + + protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException { + XDMImportAdapter res = new NonValidatingStaxAdapter(context, loc, reader); + res.uri = uri; + return res; + } + public void setProjectionPaths(Vector paths) { + projectionPaths = new ArrayList(); + projectionPaths.addAll(paths); + projPathPos = new int[projectionPaths.size()]; + for (int i=0;i<projPathPos.length;i++) + projPathPos[i] = 0; + } +} Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2012-02-07 08:47:38 UTC (rev 4517) +++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/XDMImportAdapter.java 2012-02-07 08:50:27 UTC (rev 4518) @@ -15,6 +15,7 @@ package ch.ethz.mxquery.xdmio.xmlAdapters; +import java.util.ArrayList; import java.util.Vector; import ch.ethz.mxquery.bindings.WindowFactory; @@ -304,4 +305,7 @@ return false; } + + public void setProjectionPaths(Vector paths) { + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 08:47:47
|
Revision: 4517 http://mxquery.svn.sourceforge.net/mxquery/?rev=4517&view=rev Author: pm_fischer Date: 2012-02-07 08:47:38 +0000 (Tue, 07 Feb 2012) Log Message: ----------- continue merging Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2012-02-07 08:46:05 UTC (rev 4516) +++ trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2012-02-07 08:47:38 UTC (rev 4517) @@ -3916,6 +3916,7 @@ // orderedVars[i].setResettable(true); } extendCurrentContextScope(); + for (int i = 0; i < inscopevars.length; i++) { getCurrentContext().registerVariable(inscopevars[i], true); } Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq 2012-02-07 08:46:05 UTC (rev 4516) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq 2012-02-07 08:47:38 UTC (rev 4517) @@ -1,3 +1,4 @@ +let $auction := doc() let $auction := doc("xmark.xml") return for $b in $auction/site/people/person where $b/@id = 'person0' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 08:46:15
|
Revision: 4516 http://mxquery.svn.sourceforge.net/mxquery/?rev=4516&view=rev Author: pm_fischer Date: 2012-02-07 08:46:05 +0000 (Tue, 07 Feb 2012) Log Message: ----------- yet more merging Modified Paths: -------------- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java Modified: trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java =================================================================== --- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java 2012-02-07 08:44:57 UTC (rev 4515) +++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/ProjectionTests.java 2012-02-07 08:46:05 UTC (rev 4516) @@ -40,6 +40,53 @@ //assertEquals(resultBuffer.toString().trim(), "false"); } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public void test_Path3() throws Exception{ String query = UriToString(TEST_PROJECTION_QUERY_PREFIX+"Path3.xq"); PreparedStatement pi = prepareQuery(query, false,false, false, false, false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pm_...@us...> - 2012-02-07 08:45:03
|
Revision: 4515 http://mxquery.svn.sourceforge.net/mxquery/?rev=4515&view=rev Author: pm_fischer Date: 2012-02-07 08:44:57 +0000 (Tue, 07 Feb 2012) Log Message: ----------- more merge resolving Modified Paths: -------------- trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java trunk/MXQuery_Testing/ProjectionTests/queries/Cond1.xq trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java =================================================================== --- trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-02-07 08:43:19 UTC (rev 4514) +++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-02-07 08:44:57 UTC (rev 4515) @@ -288,4 +288,6 @@ } return new ObjectObjectPair(returned, paths.getSecond()); } + + } Modified: trunk/MXQuery_Testing/ProjectionTests/queries/Cond1.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/Cond1.xq 2012-02-07 08:43:19 UTC (rev 4514) +++ trunk/MXQuery_Testing/ProjectionTests/queries/Cond1.xq 2012-02-07 08:44:57 UTC (rev 4515) @@ -1,3 +1,3 @@ if(true()) then doc("xmark.xml")/site/people/person -else doc("xmark.xml")/site/open_auctions/open_auction \ No newline at end of file +else doc("xmark.xml")/site/open_auctions/open_auction Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq =================================================================== --- trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq 2012-02-07 08:43:19 UTC (rev 4514) +++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq 2012-02-07 08:44:57 UTC (rev 4515) @@ -1,4 +1,4 @@ let $auction := doc("xmark.xml") return for $b in $auction/site/people/person where $b/@id = 'person0' -return $b/name/text() \ No newline at end of file +return $b/name/text() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |