├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── README.MD ├── pom.xml └── src ├── assemble └── dist.xml ├── examples └── java │ └── org │ └── brackit │ └── examples │ ├── LibraryModules.java │ ├── LoadAndQuery.java │ ├── Simple.java │ └── StoreAndQuery.java ├── main ├── java │ └── org │ │ └── brackit │ │ └── xquery │ │ ├── ErrorCode.java │ │ ├── Main.java │ │ ├── QueryContext.java │ │ ├── QueryException.java │ │ ├── Tuple.java │ │ ├── XQuery.java │ │ ├── array │ │ ├── AbstractArray.java │ │ ├── DArray.java │ │ └── DRArray.java │ │ ├── atomic │ │ ├── AbstractAtomic.java │ │ ├── AbstractDuration.java │ │ ├── AbstractNumeric.java │ │ ├── AbstractTimeInstant.java │ │ ├── AnyURI.java │ │ ├── Atomic.java │ │ ├── B64.java │ │ ├── Bool.java │ │ ├── Counter.java │ │ ├── DTD.java │ │ ├── Date.java │ │ ├── DateTime.java │ │ ├── Dbl.java │ │ ├── DblNumeric.java │ │ ├── Dec.java │ │ ├── DecNumeric.java │ │ ├── Dur.java │ │ ├── Duration.java │ │ ├── Flt.java │ │ ├── FltNumeric.java │ │ ├── GDay.java │ │ ├── GMD.java │ │ ├── GMon.java │ │ ├── GYE.java │ │ ├── GYM.java │ │ ├── Hex.java │ │ ├── Int.java │ │ ├── Int32.java │ │ ├── Int64.java │ │ ├── IntNumeric.java │ │ ├── LonNumeric.java │ │ ├── Numeric.java │ │ ├── QNm.java │ │ ├── Str.java │ │ ├── Time.java │ │ ├── TimeInstant.java │ │ ├── Una.java │ │ └── YMD.java │ │ ├── compiler │ │ ├── AST.java │ │ ├── BaseResolver.java │ │ ├── Bits.java │ │ ├── CompileChain.java │ │ ├── ModuleResolver.java │ │ ├── Target.java │ │ ├── Unit.java │ │ ├── XQ.java │ │ ├── analyzer │ │ │ ├── AbstractAnalyzer.java │ │ │ ├── Analyzer.java │ │ │ ├── BodyDecl.java │ │ │ ├── CtxItemDecl.java │ │ │ ├── Dependencies.java │ │ │ ├── ExprAnalyzer.java │ │ │ ├── ForwardDeclaration.java │ │ │ ├── FunctionDecl.java │ │ │ ├── NestedContext.java │ │ │ ├── PrologAnalyzer.java │ │ │ ├── VarScopes.java │ │ │ └── VariableDecl.java │ │ ├── optimizer │ │ │ ├── DefaultOptimizer.java │ │ │ ├── Optimizer.java │ │ │ ├── Stage.java │ │ │ ├── TopDownOptimizer.java │ │ │ └── walker │ │ │ │ ├── DoSNStepMerger.java │ │ │ │ ├── OrderForGroupBy.java │ │ │ │ ├── PathDDOElimination.java │ │ │ │ ├── Walker.java │ │ │ │ └── topdown │ │ │ │ ├── AggFunChecker.java │ │ │ │ ├── CmpUtil.java │ │ │ │ ├── GroupByAggregates.java │ │ │ │ ├── JoinGroupDemarcation.java │ │ │ │ ├── JoinRewriter.java │ │ │ │ ├── JoinToSelectConversion.java │ │ │ │ ├── LeftJoinLifting.java │ │ │ │ ├── LeftJoinRemoval.java │ │ │ │ ├── LeftJoinUnnesting.java │ │ │ │ ├── LetBindToLeftJoin.java │ │ │ │ ├── PredicateMerge.java │ │ │ │ ├── PredicateSplit.java │ │ │ │ ├── PullEvaluation.java │ │ │ │ ├── ScopeWalker.java │ │ │ │ ├── SelectPullup.java │ │ │ │ ├── TopDownPipeline.java │ │ │ │ └── TrivialLeftJoinRemoval.java │ │ ├── parser │ │ │ ├── Parser.java │ │ │ ├── Tokenizer.java │ │ │ └── XQParser.java │ │ ├── profiler │ │ │ ├── ProfileExpr.java │ │ │ ├── ProfileOperator.java │ │ │ ├── ProfilingCompiler.java │ │ │ └── ProfilingNode.java │ │ └── translator │ │ │ ├── Binding.java │ │ │ ├── Compiler.java │ │ │ ├── Reference.java │ │ │ ├── TopDownTranslator.java │ │ │ ├── Translator.java │ │ │ └── VariableTable.java │ │ ├── expr │ │ ├── Accessor.java │ │ ├── AndExpr.java │ │ ├── ArithmeticExpr.java │ │ ├── ArrayAccessExpr.java │ │ ├── ArrayExpr.java │ │ ├── AttributeExpr.java │ │ ├── BoundVariable.java │ │ ├── Cast.java │ │ ├── Castable.java │ │ ├── CommentExpr.java │ │ ├── ConstructedNodeBuilder.java │ │ ├── DeclVariable.java │ │ ├── DefaultCtxItem.java │ │ ├── DefaultCtxPos.java │ │ ├── DefaultCtxSize.java │ │ ├── DerefExpr.java │ │ ├── DocumentExpr.java │ │ ├── ElementExpr.java │ │ ├── EmptyExpr.java │ │ ├── ExceptExpr.java │ │ ├── FilterExpr.java │ │ ├── GCmpExpr.java │ │ ├── IfExpr.java │ │ ├── InstanceOf.java │ │ ├── IntersectExpr.java │ │ ├── NodeCmpExpr.java │ │ ├── OrExpr.java │ │ ├── PIExpr.java │ │ ├── PathStepExpr.java │ │ ├── PipeExpr.java │ │ ├── PredicateExpr.java │ │ ├── ProjectionExpr.java │ │ ├── RangeExpr.java │ │ ├── RecordExpr.java │ │ ├── SequenceExpr.java │ │ ├── StepExpr.java │ │ ├── SwitchExpr.java │ │ ├── TextExpr.java │ │ ├── Treat.java │ │ ├── TryCatchExpr.java │ │ ├── TypeswitchExpr.java │ │ ├── UnionExpr.java │ │ ├── VCmpExpr.java │ │ └── Variable.java │ │ ├── function │ │ ├── AbstractFunction.java │ │ ├── ConstructorFunction.java │ │ ├── FunctionExpr.java │ │ ├── UDF.java │ │ ├── bit │ │ │ ├── BitFun.java │ │ │ ├── Create.java │ │ │ ├── Drop.java │ │ │ ├── Eval.java │ │ │ ├── Every.java │ │ │ ├── Exists.java │ │ │ ├── Fields.java │ │ │ ├── Len.java │ │ │ ├── Load.java │ │ │ ├── Mkdir.java │ │ │ ├── Now.java │ │ │ ├── Parse.java │ │ │ ├── Serialize.java │ │ │ ├── Silent.java │ │ │ ├── Some.java │ │ │ ├── Store.java │ │ │ └── Values.java │ │ ├── fn │ │ │ ├── Abs.java │ │ │ ├── AdjustToTimezone.java │ │ │ ├── BaseURI.java │ │ │ ├── BooleanValue.java │ │ │ ├── CardinalityTest.java │ │ │ ├── Ceiling.java │ │ │ ├── CodepointEqual.java │ │ │ ├── CodepointsToString.java │ │ │ ├── Collection.java │ │ │ ├── Compare.java │ │ │ ├── Concat.java │ │ │ ├── Count.java │ │ │ ├── CurrentDate.java │ │ │ ├── CurrentDateTime.java │ │ │ ├── CurrentTime.java │ │ │ ├── Data.java │ │ │ ├── DateTime.java │ │ │ ├── DeepEqual.java │ │ │ ├── DefaultCollation.java │ │ │ ├── Distinct.java │ │ │ ├── Doc.java │ │ │ ├── DocumentURI.java │ │ │ ├── EmptySequence.java │ │ │ ├── Encode.java │ │ │ ├── Error.java │ │ │ ├── ExtractFromDateTime.java │ │ │ ├── ExtractFromDuration.java │ │ │ ├── Floor.java │ │ │ ├── ImplicitTimezone.java │ │ │ ├── IndexOf.java │ │ │ ├── InsertBefore.java │ │ │ ├── MinMax.java │ │ │ ├── Name.java │ │ │ ├── Nilled.java │ │ │ ├── NodeName.java │ │ │ ├── NormalizeSpace.java │ │ │ ├── Number.java │ │ │ ├── QName.java │ │ │ ├── RegEx.java │ │ │ ├── Remove.java │ │ │ ├── ResolveURI.java │ │ │ ├── Reverse.java │ │ │ ├── Root.java │ │ │ ├── Round.java │ │ │ ├── RoundHalfEven.java │ │ │ ├── StringCase.java │ │ │ ├── StringJoin.java │ │ │ ├── StringLength.java │ │ │ ├── StringNormalize.java │ │ │ ├── StringToCodepoints.java │ │ │ ├── StringTranslate.java │ │ │ ├── StringValue.java │ │ │ ├── Subsequence.java │ │ │ ├── Substring.java │ │ │ ├── SubstringMatch.java │ │ │ ├── SubstringRelative.java │ │ │ ├── SumAvg.java │ │ │ ├── Trace.java │ │ │ └── Unordered.java │ │ ├── io │ │ │ ├── IOFun.java │ │ │ ├── Ls.java │ │ │ ├── Read.java │ │ │ ├── Readline.java │ │ │ ├── Write.java │ │ │ └── Writeline.java │ │ └── json │ │ │ ├── JSONFun.java │ │ │ ├── JSONParse.java │ │ │ └── JSONParser.java │ │ ├── module │ │ ├── AbstractModule.java │ │ ├── DecimalFormat.java │ │ ├── Functions.java │ │ ├── LibraryModule.java │ │ ├── MainModule.java │ │ ├── Module.java │ │ ├── ModuleContext.java │ │ ├── NamespaceDecl.java │ │ ├── Namespaces.java │ │ ├── StaticContext.java │ │ ├── Types.java │ │ └── Variables.java │ │ ├── node │ │ ├── AbstractBuilder.java │ │ ├── AbstractCollection.java │ │ ├── AbstractNode.java │ │ ├── ArrayCollection.java │ │ ├── PathStackStream.java │ │ ├── SimpleStore.java │ │ ├── d2linked │ │ │ ├── AttributeD2Node.java │ │ │ ├── CommentD2Node.java │ │ │ ├── D2Node.java │ │ │ ├── D2NodeBuilder.java │ │ │ ├── D2NodeCollection.java │ │ │ ├── D2NodeFactory.java │ │ │ ├── D2NodeParser.java │ │ │ ├── DocumentD2Node.java │ │ │ ├── ElementD2Node.java │ │ │ ├── PID2Node.java │ │ │ ├── ParentD2Node.java │ │ │ └── TextD2Node.java │ │ ├── dom │ │ │ ├── AttrImpl.java │ │ │ ├── CharacterDataImpl.java │ │ │ ├── CommentImpl.java │ │ │ ├── DOMListener.java │ │ │ ├── DocumentImpl.java │ │ │ ├── ElementImpl.java │ │ │ ├── NamedNodeMapImpl.java │ │ │ ├── NodeImpl.java │ │ │ ├── NodeListImpl.java │ │ │ ├── ProcInstrImpl.java │ │ │ └── TextImpl.java │ │ ├── parser │ │ │ ├── CollectionParser.java │ │ │ ├── DefaultHandler.java │ │ │ ├── DefaultListener.java │ │ │ ├── DocumentParser.java │ │ │ ├── FragmentHelper.java │ │ │ ├── ListenMode.java │ │ │ ├── NavigationalSubtreeParser.java │ │ │ ├── NavigationalSubtreeProcessor.java │ │ │ ├── ParserStream.java │ │ │ ├── RelativeEntityResolver.java │ │ │ ├── SAX2SubtreeHandlerAdapter.java │ │ │ ├── StreamSubtreeParser.java │ │ │ ├── StreamSubtreeProcessor.java │ │ │ ├── SubtreeHandler.java │ │ │ ├── SubtreeListener.java │ │ │ ├── SubtreeListener2HandlerAdapter.java │ │ │ ├── SubtreeParser.java │ │ │ └── SubtreeProcessor.java │ │ └── stream │ │ │ ├── ArrayStream.java │ │ │ ├── AtomStream.java │ │ │ ├── EmptyStream.java │ │ │ ├── FlatteningStream.java │ │ │ ├── IteratorStream.java │ │ │ ├── ParallelArrayBlockStream.java │ │ │ ├── ParallelCLQStream.java │ │ │ ├── StreamUtil.java │ │ │ ├── TestParallelStream.java │ │ │ ├── TransformerStream.java │ │ │ └── filter │ │ │ ├── Filter.java │ │ │ └── FilteredStream.java │ │ ├── operator │ │ ├── BlockingParallelizer.java │ │ ├── Check.java │ │ ├── Count.java │ │ ├── Cursor.java │ │ ├── ForBind.java │ │ ├── GroupBy.java │ │ ├── LetBind.java │ │ ├── NLJoin.java │ │ ├── Operator.java │ │ ├── OrderBy.java │ │ ├── Parallelizer.java │ │ ├── Print.java │ │ ├── Select.java │ │ ├── Start.java │ │ ├── TableJoin.java │ │ └── TupleImpl.java │ │ ├── record │ │ ├── AbstractRecord.java │ │ └── ArrayRecord.java │ │ ├── sequence │ │ ├── AbstractSequence.java │ │ ├── AtomIter.java │ │ ├── BaseIter.java │ │ ├── CollectionSequence.java │ │ ├── FlatteningSequence.java │ │ ├── FunctionConversionSequence.java │ │ ├── ItemSequence.java │ │ ├── LazySequence.java │ │ ├── NestedSequence.java │ │ ├── SortedNodeSequence.java │ │ └── TypedSequence.java │ │ ├── update │ │ ├── Delete.java │ │ ├── Insert.java │ │ ├── Rename.java │ │ ├── ReplaceNode.java │ │ ├── ReplaceValue.java │ │ ├── Transform.java │ │ ├── UpdateList.java │ │ └── op │ │ │ ├── AbstractInsertOp.java │ │ │ ├── DeleteOp.java │ │ │ ├── InsertAfterOp.java │ │ │ ├── InsertAttributesOp.java │ │ │ ├── InsertBeforeOp.java │ │ │ ├── InsertIntoAsFirstOp.java │ │ │ ├── InsertIntoAsLastOp.java │ │ │ ├── InsertIntoOp.java │ │ │ ├── OpType.java │ │ │ ├── RenameOp.java │ │ │ ├── ReplaceElementContentOp.java │ │ │ ├── ReplaceNodeOp.java │ │ │ ├── ReplaceValueOp.java │ │ │ └── UpdateOp.java │ │ ├── util │ │ ├── Cfg.java │ │ ├── Cmp.java │ │ ├── ExprUtil.java │ │ ├── Regex.java │ │ ├── Whitespace.java │ │ ├── aggregator │ │ │ ├── Aggregate.java │ │ │ ├── Aggregator.java │ │ │ ├── CountAggregator.java │ │ │ ├── Grouping.java │ │ │ ├── MinMaxAggregator.java │ │ │ ├── SequenceAggregator.java │ │ │ ├── SingleAggregator.java │ │ │ └── SumAvgAggregator.java │ │ ├── annotation │ │ │ ├── FunctionAnnotation.java │ │ │ └── ModuleAnnotation.java │ │ ├── dot │ │ │ ├── DotContext.java │ │ │ ├── DotEdge.java │ │ │ ├── DotNode.java │ │ │ └── DotUtil.java │ │ ├── io │ │ │ ├── IOUtils.java │ │ │ ├── URIHandler.java │ │ │ ├── URLInputStream.java │ │ │ └── URLOutputStream.java │ │ ├── join │ │ │ ├── FastList.java │ │ │ ├── HashJoinTable.java │ │ │ ├── JoinTable.java │ │ │ ├── MultiTypeJoinTable.java │ │ │ ├── SingleTypeJoinTable.java │ │ │ └── SortedJoinTable.java │ │ ├── log │ │ │ ├── LogFactory.java │ │ │ ├── Logger.java │ │ │ ├── UtilLogFactory.java │ │ │ └── UtilLogger.java │ │ ├── path │ │ │ ├── Path.java │ │ │ ├── PathException.java │ │ │ └── PathParser.java │ │ ├── serialize │ │ │ ├── Serializer.java │ │ │ ├── StringSerializer.java │ │ │ └── SubtreePrinter.java │ │ └── sort │ │ │ ├── Ordering.java │ │ │ └── TupleSort.java │ │ └── xdm │ │ ├── AbstractItem.java │ │ ├── Array.java │ │ ├── Axis.java │ │ ├── Collection.java │ │ ├── DocumentException.java │ │ ├── Expr.java │ │ ├── Facets.java │ │ ├── Function.java │ │ ├── Item.java │ │ ├── Iter.java │ │ ├── Kind.java │ │ ├── ListOrUnion.java │ │ ├── Node.java │ │ ├── NodeFactory.java │ │ ├── OperationNotSupportedException.java │ │ ├── Record.java │ │ ├── Scope.java │ │ ├── Sequence.java │ │ ├── Signature.java │ │ ├── Store.java │ │ ├── Stream.java │ │ ├── Type.java │ │ ├── XMLChar.java │ │ └── type │ │ ├── AnyItemType.java │ │ ├── AnyNodeType.java │ │ ├── ArrayType.java │ │ ├── AtomicType.java │ │ ├── AttributeType.java │ │ ├── Cardinality.java │ │ ├── CommentType.java │ │ ├── DocumentType.java │ │ ├── ElementType.java │ │ ├── FunctionType.java │ │ ├── ItemType.java │ │ ├── ListOrUnionType.java │ │ ├── NSNameWildcardTest.java │ │ ├── NSWildcardNameTest.java │ │ ├── NodeType.java │ │ ├── NumericType.java │ │ ├── PIType.java │ │ ├── RecordType.java │ │ ├── SequenceType.java │ │ └── TextType.java └── resources │ └── logging.properties └── test ├── java └── org │ └── brackit │ └── xquery │ ├── ResultChecker.java │ ├── UpdateFacilityTest.java │ ├── XMarkFnDocTest.java │ ├── XMarkTest.java │ ├── XMarkTestNested.java │ ├── XMarkTestUnnested.java │ ├── XMarkTestUnnestedJoin.java │ ├── XQueryBaseTest.java │ ├── compiler │ ├── LibraryModulesTest.java │ ├── optimizer │ │ ├── ExtractFLWORTest.java │ │ ├── JoinTest.java │ │ └── LetBindLiftTest.java │ └── parser │ │ └── XQParserTest.java │ ├── expr │ ├── ArithmeticExprTest.java │ ├── CastTest.java │ ├── CmpExprTest.java │ ├── DirConstructorTest.java │ ├── FLWORTest.java │ ├── IfExprTest.java │ ├── PathExprTest.java │ ├── PrologDeclarationTest.java │ ├── QuantifiedBindingsTest.java │ └── SequenceExprTest.java │ ├── function │ └── fn │ │ └── FnTest.java │ ├── node │ ├── AxisTest.java │ ├── NodeTest.java │ └── d2linked │ │ ├── D2NodeAxisTest.java │ │ ├── D2NodeDivisionTest.java │ │ └── D2NodeTest.java │ ├── operator │ ├── IntegerSource.java │ └── TuplePrintOp.java │ └── util │ └── path │ └── PathTest.java └── resources ├── docs └── orga.xml ├── join ├── forNestedFor.xq ├── forNestedFor2JoinPredicates.xq ├── forNestedForWithOutsideRef.xq └── simpleForFor.xq ├── parser └── weird.xq └── xmark ├── auction.xml ├── mini.xml ├── queries ├── fndoc │ ├── q01.xq │ ├── q02.xq │ ├── q03.xq │ ├── q04.xq │ ├── q05.xq │ ├── q06.xq │ ├── q07.xq │ ├── q08.xq │ ├── q09.xq │ ├── q10.xq │ ├── q11.xq │ ├── q12.xq │ ├── q13.xq │ ├── q14.xq │ ├── q15.xq │ ├── q16.xq │ ├── q17.xq │ ├── q18.xq │ ├── q19.xq │ └── q20.xq └── orig │ ├── q01.xq │ ├── q02.xq │ ├── q03.xq │ ├── q04.xq │ ├── q05.xq │ ├── q06.xq │ ├── q07.xq │ ├── q08.xq │ ├── q09.xq │ ├── q10.xq │ ├── q11.xq │ ├── q12.xq │ ├── q13.xq │ ├── q14.xq │ ├── q15.xq │ ├── q16.xq │ ├── q17.xq │ ├── q18.xq │ ├── q19.xq │ └── q20.xq └── results ├── q01.out ├── q02.out ├── q03.out ├── q04.out ├── q05.out ├── q06.out ├── q07.out ├── q08.out ├── q09.out ├── q10.out ├── q11.out ├── q12.out ├── q13.out ├── q14.out ├── q15.out ├── q16.out ├── q17.out ├── q18.out ├── q19.out └── q20.out /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | .settings 4 | target 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: openjdk8 3 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | [New BSD License] 2 | Copyright (c) 2011-2012, Brackit Project Team 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Brackit Project Team nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.brackit 6 | brackit 7 | 0.1.3-SNAPSHOT 8 | Brackit Engine 9 | http://brackit.org 10 | 11 | UTF-8 12 | 13 | 14 | Brackit Project Team 15 | http://brackit.org 16 | 17 | 18 | 19 | 20 | org.apache.maven.plugins 21 | maven-assembly-plugin 22 | 2.2.1 23 | 24 | 25 | dist-assembly 26 | package 27 | 28 | single 29 | 30 | 31 | 32 | src/assemble/dist.xml 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.apache.maven.plugins 40 | maven-jar-plugin 41 | 2.3.1 42 | 43 | 44 | 45 | org.brackit.xquery.Main 46 | true 47 | lib 48 | 49 | 50 | 51 | 52 | 53 | 54 | test-jar 55 | 56 | 57 | 58 | 59 | 60 | org.apache.maven.plugins 61 | maven-compiler-plugin 62 | 2.3.2 63 | 64 | 1.6 65 | 1.6 66 | UTF-8 67 | 68 | 69 | 70 | 71 | 72 | 73 | junit 74 | junit 75 | 4.8.2 76 | jar 77 | test 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/assemble/dist.xml: -------------------------------------------------------------------------------- 1 | 4 | dist 5 | 6 | dir 7 | 8 | false 9 | 10 | 11 | 12 | true 13 | 14 | modules/${artifactId} 15 | false 16 | 17 | 18 | 19 | 20 | 21 | lib 22 | 23 | false 24 | runtime 25 | 26 | 27 | 31 | 32 | 33 | 34 | 35 | 36 | ${project.basedir} 37 | / 38 | 39 | README* 40 | LICENSE* 41 | NOTICE* 42 | 43 | 44 | 45 | ${project.build.directory} 46 | / 47 | 48 | *.jar 49 | 50 | 51 | 52 | ${project.build.directory}/site 53 | docs 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/atomic/DblNumeric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.atomic; 29 | 30 | /** 31 | * 32 | * @author Sebastian Baechle 33 | * 34 | */ 35 | public interface DblNumeric extends Numeric { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/atomic/DecNumeric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.atomic; 29 | 30 | /** 31 | * 32 | * @author Sebastian Baechle 33 | * 34 | */ 35 | public interface DecNumeric extends Numeric { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/atomic/Duration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.atomic; 29 | 30 | /** 31 | * 32 | * @author Sebastian Baechle 33 | * 34 | */ 35 | public interface Duration { 36 | public short getYears(); 37 | 38 | public byte getMonths(); 39 | 40 | public short getDays(); 41 | 42 | public byte getHours(); 43 | 44 | public byte getMinutes(); 45 | 46 | public int getMicros(); 47 | 48 | public boolean isNegative(); 49 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/atomic/FltNumeric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.atomic; 29 | 30 | /** 31 | * 32 | * @author Sebastian Baechle 33 | * 34 | */ 35 | public interface FltNumeric extends Numeric { 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/atomic/IntNumeric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.atomic; 29 | 30 | /** 31 | * 32 | * @author Sebastian Baechle 33 | * 34 | */ 35 | public interface IntNumeric extends DecNumeric { 36 | public IntNumeric inc(); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/atomic/LonNumeric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.atomic; 29 | 30 | /** 31 | * 32 | * @author Sebastian Baechle 33 | * 34 | */ 35 | public interface LonNumeric extends IntNumeric { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/atomic/TimeInstant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.atomic; 29 | 30 | import org.brackit.xquery.QueryException; 31 | 32 | /** 33 | * 34 | * @author Sebastian Baechle 35 | * 36 | */ 37 | public interface TimeInstant extends Atomic { 38 | public short getYear(); 39 | 40 | public byte getMonth(); 41 | 42 | public byte getDay(); 43 | 44 | public byte getHours(); 45 | 46 | public byte getMinutes(); 47 | 48 | public int getMicros(); 49 | 50 | public DTD getTimezone(); 51 | 52 | public TimeInstant canonicalize() throws QueryException; 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/compiler/ModuleResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.compiler; 29 | 30 | import java.io.IOException; 31 | import java.util.List; 32 | 33 | import org.brackit.xquery.module.Module; 34 | 35 | /** 36 | * 37 | * @author Sebastian Baechle 38 | * 39 | */ 40 | public interface ModuleResolver { 41 | 42 | public void register(String targetNSUri, Module module); 43 | 44 | public void unregister(String targetNSUri); 45 | 46 | /** 47 | * Resolve the set of modules identified by the target namespace 48 | * targetNSUri 49 | */ 50 | public List resolve(String targetNSUri, String... locationUris); 51 | 52 | public List load(String uri, String[] locations) 53 | throws IOException; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/compiler/Unit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.compiler; 29 | 30 | import org.brackit.xquery.xdm.Expr; 31 | 32 | /** 33 | * A compilation unit, e.g. a main module or a function. 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public interface Unit { 39 | public void setExpr(Expr expr); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/compiler/analyzer/BodyDecl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.compiler.analyzer; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.compiler.AST; 32 | import org.brackit.xquery.compiler.Target; 33 | import org.brackit.xquery.module.MainModule; 34 | 35 | /** 36 | * 37 | * @author Sebastian Baechle 38 | * 39 | */ 40 | public class BodyDecl extends ForwardDeclaration { 41 | final AST body; 42 | 43 | public BodyDecl(MainModule module, AST body) { 44 | super(module, module); 45 | this.body = body; 46 | } 47 | 48 | @Override 49 | public Target process() throws QueryException { 50 | new ExprAnalyzer(module).expr(body); 51 | return new Target(module, sctx, body, (MainModule) module, true); 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/compiler/optimizer/Optimizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.compiler.optimizer; 29 | 30 | import java.util.List; 31 | 32 | import org.brackit.xquery.QueryException; 33 | import org.brackit.xquery.compiler.AST; 34 | import org.brackit.xquery.module.StaticContext; 35 | 36 | /** 37 | * @author Sebastian Baechle 38 | * 39 | */ 40 | public interface Optimizer { 41 | public AST optimize(StaticContext sctx, AST ast) throws QueryException; 42 | 43 | public List getStages(); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/compiler/optimizer/Stage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.compiler.optimizer; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.compiler.AST; 32 | import org.brackit.xquery.module.StaticContext; 33 | 34 | /** 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public interface Stage { 39 | public AST rewrite(StaticContext sctx, AST ast) throws QueryException; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/compiler/parser/Parser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.compiler.parser; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.compiler.AST; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public interface Parser { 39 | public AST parse(String query) throws QueryException; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/compiler/translator/Reference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.compiler.translator; 29 | 30 | /** 31 | * @author Sebastian Baechle 32 | * 33 | */ 34 | public interface Reference { 35 | /** 36 | * Initialize the reference to the variable's 37 | * position in a tuple. 38 | * @param pos 39 | */ 40 | public void setPos(int pos); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/compiler/translator/Translator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.compiler.translator; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.atomic.QNm; 32 | import org.brackit.xquery.compiler.AST; 33 | import org.brackit.xquery.function.UDF; 34 | import org.brackit.xquery.module.Module; 35 | import org.brackit.xquery.module.StaticContext; 36 | import org.brackit.xquery.xdm.Expr; 37 | 38 | /** 39 | * @author Sebastian Baechle 40 | * 41 | */ 42 | public interface Translator { 43 | public Expr expression(Module module, StaticContext ctx, AST expr, 44 | boolean allowUpdate) throws QueryException; 45 | 46 | public Expr function(Module module, StaticContext ctx, UDF udf, 47 | QNm[] params, AST expr, boolean allowUpdate) throws QueryException; 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/function/fn/Abs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.function.fn; 29 | 30 | import org.brackit.xquery.QueryContext; 31 | import org.brackit.xquery.QueryException; 32 | import org.brackit.xquery.atomic.Numeric; 33 | import org.brackit.xquery.atomic.QNm; 34 | import org.brackit.xquery.function.AbstractFunction; 35 | import org.brackit.xquery.module.StaticContext; 36 | import org.brackit.xquery.xdm.Sequence; 37 | import org.brackit.xquery.xdm.Signature; 38 | 39 | /** 40 | * 41 | * @author Sebastian Baechle 42 | * 43 | */ 44 | public class Abs extends AbstractFunction { 45 | public Abs(QNm name, Signature signature) { 46 | super(name, signature, true); 47 | } 48 | 49 | @Override 50 | public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) 51 | throws QueryException { 52 | return (args[0] == null) ? null : ((Numeric) args[0]).abs(); 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/function/fn/Count.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.function.fn; 29 | 30 | import org.brackit.xquery.QueryContext; 31 | import org.brackit.xquery.QueryException; 32 | import org.brackit.xquery.atomic.Int32; 33 | import org.brackit.xquery.atomic.QNm; 34 | import org.brackit.xquery.function.AbstractFunction; 35 | import org.brackit.xquery.module.StaticContext; 36 | import org.brackit.xquery.xdm.Sequence; 37 | import org.brackit.xquery.xdm.Signature; 38 | 39 | /** 40 | * 41 | * @author Sebastian Baechle 42 | * 43 | */ 44 | public class Count extends AbstractFunction { 45 | public Count(QNm name, Signature signature) { 46 | super(name, signature, true); 47 | } 48 | 49 | @Override 50 | public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) 51 | throws QueryException { 52 | return (args[0] != null) ? args[0].size() : Int32.ZERO; 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/function/fn/CurrentDate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.function.fn; 29 | 30 | import org.brackit.xquery.QueryContext; 31 | import org.brackit.xquery.QueryException; 32 | import org.brackit.xquery.atomic.QNm; 33 | import org.brackit.xquery.function.AbstractFunction; 34 | import org.brackit.xquery.module.StaticContext; 35 | import org.brackit.xquery.xdm.Sequence; 36 | import org.brackit.xquery.xdm.Signature; 37 | 38 | /** 39 | * 40 | * @author Sebastian Baechle 41 | * 42 | */ 43 | public class CurrentDate extends AbstractFunction { 44 | public CurrentDate(QNm name, Signature signature) { 45 | super(name, signature, true); 46 | } 47 | 48 | @Override 49 | public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) 50 | throws QueryException { 51 | return ctx.getDate(); 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/function/fn/CurrentDateTime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.function.fn; 29 | 30 | import org.brackit.xquery.QueryContext; 31 | import org.brackit.xquery.QueryException; 32 | import org.brackit.xquery.atomic.QNm; 33 | import org.brackit.xquery.function.AbstractFunction; 34 | import org.brackit.xquery.module.StaticContext; 35 | import org.brackit.xquery.xdm.Sequence; 36 | import org.brackit.xquery.xdm.Signature; 37 | 38 | /** 39 | * 40 | * @author Sebastian Baechle 41 | * 42 | */ 43 | public class CurrentDateTime extends AbstractFunction { 44 | public CurrentDateTime(QNm name, Signature signature) { 45 | super(name, signature, true); 46 | } 47 | 48 | @Override 49 | public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) 50 | throws QueryException { 51 | return ctx.getDateTime(); 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/function/fn/CurrentTime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.function.fn; 29 | 30 | import org.brackit.xquery.QueryContext; 31 | import org.brackit.xquery.QueryException; 32 | import org.brackit.xquery.atomic.QNm; 33 | import org.brackit.xquery.function.AbstractFunction; 34 | import org.brackit.xquery.module.StaticContext; 35 | import org.brackit.xquery.xdm.Sequence; 36 | import org.brackit.xquery.xdm.Signature; 37 | 38 | /** 39 | * 40 | * @author Sebastian Baechle 41 | * 42 | */ 43 | public class CurrentTime extends AbstractFunction { 44 | public CurrentTime(QNm name, Signature signature) { 45 | super(name, signature, true); 46 | } 47 | 48 | @Override 49 | public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) 50 | throws QueryException { 51 | return ctx.getTime(); 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/function/fn/Floor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.function.fn; 29 | 30 | import org.brackit.xquery.QueryContext; 31 | import org.brackit.xquery.QueryException; 32 | import org.brackit.xquery.atomic.Numeric; 33 | import org.brackit.xquery.atomic.QNm; 34 | import org.brackit.xquery.function.AbstractFunction; 35 | import org.brackit.xquery.module.StaticContext; 36 | import org.brackit.xquery.xdm.Sequence; 37 | import org.brackit.xquery.xdm.Signature; 38 | 39 | /** 40 | * 41 | * @author Sebastian Baechle 42 | * 43 | */ 44 | public class Floor extends AbstractFunction { 45 | public Floor(QNm name, Signature signature) { 46 | super(name, signature, true); 47 | } 48 | 49 | @Override 50 | public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) 51 | throws QueryException { 52 | return (args[0] == null) ? null : ((Numeric) args[0]).floor(); 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/function/fn/ImplicitTimezone.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.function.fn; 29 | 30 | import org.brackit.xquery.QueryContext; 31 | import org.brackit.xquery.QueryException; 32 | import org.brackit.xquery.atomic.QNm; 33 | import org.brackit.xquery.function.AbstractFunction; 34 | import org.brackit.xquery.module.StaticContext; 35 | import org.brackit.xquery.xdm.Sequence; 36 | import org.brackit.xquery.xdm.Signature; 37 | 38 | /** 39 | * 40 | * @author Sebastian Baechle 41 | * 42 | */ 43 | public class ImplicitTimezone extends AbstractFunction { 44 | public ImplicitTimezone(QNm name, Signature signature) { 45 | super(name, signature, true); 46 | } 47 | 48 | @Override 49 | public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) 50 | throws QueryException { 51 | return ctx.getImplicitTimezone(); 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/function/fn/Round.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.function.fn; 29 | 30 | import org.brackit.xquery.QueryContext; 31 | import org.brackit.xquery.QueryException; 32 | import org.brackit.xquery.atomic.Numeric; 33 | import org.brackit.xquery.atomic.QNm; 34 | import org.brackit.xquery.function.AbstractFunction; 35 | import org.brackit.xquery.module.StaticContext; 36 | import org.brackit.xquery.xdm.Sequence; 37 | import org.brackit.xquery.xdm.Signature; 38 | 39 | /** 40 | * 41 | * @author Sebastian Baechle 42 | * 43 | */ 44 | public class Round extends AbstractFunction { 45 | public Round(QNm name, Signature signature) { 46 | super(name, signature, true); 47 | } 48 | 49 | @Override 50 | public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) 51 | throws QueryException { 52 | return (args[0] == null) ? null : ((Numeric) args[0]).round(); 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/function/io/IOFun.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.function.io; 29 | 30 | import org.brackit.xquery.atomic.QNm; 31 | 32 | /** 33 | * @author Sebastian Baechle 34 | * 35 | */ 36 | public class IOFun { 37 | public static final String IO_NSURI = "http://brackit.org/ns/io"; 38 | 39 | public static final String IO_PREFIX = "io"; 40 | 41 | public static final QNm IO_LOADFILE_INT_ERROR = new QNm(IO_NSURI, 42 | IO_PREFIX, "BIIO0001"); 43 | 44 | public static final QNm IO_WRITEFILE_INT_ERROR = new QNm(IO_NSURI, 45 | IO_PREFIX, "BIIO002"); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/function/json/JSONFun.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.function.json; 29 | 30 | import org.brackit.xquery.atomic.QNm; 31 | 32 | /** 33 | * @author Sebastian Baechle 34 | * 35 | */ 36 | public class JSONFun { 37 | public static final String JSON_NSURI = "http://brackit.org/ns/json"; 38 | 39 | public static final String JSON_PREFIX = "json"; 40 | 41 | public static final QNm ERR_PARSING_ERROR = new QNm(JSON_NSURI, 42 | JSON_PREFIX, "BIJS0001"); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/module/LibraryModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.module; 29 | 30 | import org.brackit.xquery.xdm.Expr; 31 | 32 | /** 33 | * 34 | * @author Sebastian Baechle 35 | * 36 | */ 37 | public class LibraryModule extends AbstractModule { 38 | 39 | private String nsURI; 40 | 41 | public String getTargetNS() { 42 | return nsURI; 43 | } 44 | 45 | public void setTargetNS(String nsURI) { 46 | this.nsURI = nsURI; 47 | } 48 | 49 | @Override 50 | public Expr getBody() { 51 | return null; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/module/MainModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.module; 29 | 30 | import org.brackit.xquery.compiler.Unit; 31 | import org.brackit.xquery.xdm.Expr; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public class MainModule extends AbstractModule implements Unit { 39 | private Expr body; 40 | 41 | @Override 42 | public Expr getBody() { 43 | return body; 44 | } 45 | 46 | @Override 47 | public void setExpr(Expr body) { 48 | this.body = body; 49 | } 50 | 51 | @Override 52 | public String getTargetNS() { 53 | return null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/module/Module.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.module; 29 | 30 | import java.util.List; 31 | import java.util.Map; 32 | 33 | import org.brackit.xquery.QueryException; 34 | import org.brackit.xquery.atomic.QNm; 35 | import org.brackit.xquery.atomic.Str; 36 | import org.brackit.xquery.xdm.Expr; 37 | 38 | /** 39 | * 40 | * @author Sebastian Baechle 41 | * 42 | */ 43 | public interface Module { 44 | 45 | public String getTargetNS(); 46 | 47 | public Expr getBody(); 48 | 49 | public void importModule(Module module) throws QueryException; 50 | 51 | public List getImportedModules(); 52 | 53 | public void addOption(QNm name, Str value); 54 | 55 | public Map getOptions(); 56 | 57 | public StaticContext getStaticContext(); 58 | 59 | public Variables getVariables(); 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/module/NamespaceDecl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.module; 29 | 30 | /** 31 | * @author Sebastian Baechle 32 | * 33 | */ 34 | public class NamespaceDecl { 35 | 36 | private final String prefix; 37 | private final String nsUri; 38 | 39 | public NamespaceDecl(String prefix, String nsUri) { 40 | super(); 41 | this.prefix = prefix; 42 | this.nsUri = nsUri; 43 | } 44 | 45 | public String getPrefix() { 46 | return prefix; 47 | } 48 | 49 | public String getUri() { 50 | return nsUri; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/d2linked/D2NodeCollection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.d2linked; 29 | 30 | import org.brackit.xquery.node.ArrayCollection; 31 | 32 | public class D2NodeCollection extends ArrayCollection { 33 | public D2NodeCollection(String name, DocumentD2Node document) { 34 | super(name, document); 35 | } 36 | 37 | public D2NodeCollection(String name) { 38 | super(name); 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/dom/NodeListImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.dom; 29 | 30 | import java.util.List; 31 | 32 | import org.w3c.dom.Node; 33 | 34 | /** 35 | * 36 | * @author Sebastian Baechle 37 | * 38 | */ 39 | public class NodeListImpl implements org.w3c.dom.NodeList { 40 | private final List children; 41 | 42 | public NodeListImpl(List children) { 43 | this.children = children; 44 | } 45 | 46 | @Override 47 | public int getLength() { 48 | return (children != null) ? children.size() : 0; 49 | } 50 | 51 | @Override 52 | public Node item(int index) { 53 | return ((children != null) && (index >= 0) && (index < children.size())) ? children 54 | .get(index) 55 | : null; 56 | } 57 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/parser/ListenMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.parser; 29 | 30 | /** 31 | * Different Modes for {@link SubtreeListener SubtreeListeners}. 32 | * 33 | * @author Sebastian Baechle 34 | * 35 | */ 36 | public enum ListenMode { 37 | INSERT, DELETE; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/parser/NavigationalSubtreeParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.parser; 29 | 30 | import org.brackit.xquery.xdm.DocumentException; 31 | import org.brackit.xquery.xdm.Node; 32 | 33 | /** 34 | * @author Sebastian Baechle 35 | * 36 | */ 37 | public class NavigationalSubtreeParser implements SubtreeParser { 38 | private final Node root; 39 | 40 | public NavigationalSubtreeParser(Node root) { 41 | super(); 42 | this.root = root; 43 | } 44 | 45 | @Override 46 | public void parse(SubtreeHandler handler) throws DocumentException { 47 | SubtreeListener>[] listener = new SubtreeListener[] { 48 | new SubtreeListener2HandlerAdapter(handler) }; 49 | NavigationalSubtreeProcessor processor = 50 | new NavigationalSubtreeProcessor(root, listener); 51 | processor.process(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/parser/SubtreeParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.parser; 29 | 30 | import org.brackit.xquery.xdm.DocumentException; 31 | 32 | /** 33 | * Adapter-Interface to support any subtree source as a SAX-compatible source. 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public interface SubtreeParser { 39 | public void parse(SubtreeHandler handler) throws DocumentException; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/stream/ArrayStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.stream; 29 | 30 | import org.brackit.xquery.xdm.DocumentException; 31 | import org.brackit.xquery.xdm.Stream; 32 | 33 | /** 34 | * @author Sebastian Baechle 35 | * 36 | */ 37 | public class ArrayStream implements Stream { 38 | 39 | private final E[] v; 40 | private int pos; 41 | 42 | public ArrayStream(E[] v) { 43 | this.v = v; 44 | } 45 | 46 | @Override 47 | public void close() { 48 | } 49 | 50 | @Override 51 | public E next() throws DocumentException { 52 | return (pos < v.length) ? v[pos++] : null; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/stream/AtomStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.stream; 29 | 30 | import org.brackit.xquery.xdm.DocumentException; 31 | import org.brackit.xquery.xdm.Stream; 32 | 33 | /** 34 | * Thin wrapper bridging a single object to the {@link Stream} interface. 35 | * 36 | * @author Sebastian Baechle 37 | * 38 | */ 39 | public class AtomStream implements Stream { 40 | 41 | private E atom; 42 | 43 | public AtomStream(E atom) { 44 | this.atom = atom; 45 | } 46 | 47 | @Override 48 | public void close() { 49 | atom = null; 50 | } 51 | 52 | @Override 53 | public E next() throws DocumentException { 54 | E deliver = atom; 55 | atom = null; 56 | return deliver; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/stream/EmptyStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.stream; 29 | 30 | import org.brackit.xquery.xdm.DocumentException; 31 | import org.brackit.xquery.xdm.Stream; 32 | 33 | /** 34 | * Thin wrapper bridging representing an empty sequence to the {@link Stream} 35 | * interface. 36 | * 37 | * @author Sebastian Baechle 38 | * 39 | * @param 40 | */ 41 | public class EmptyStream implements Stream { 42 | private boolean closed = false; 43 | 44 | public EmptyStream() { 45 | } 46 | 47 | @Override 48 | public void close() { 49 | closed = true; 50 | } 51 | 52 | @Override 53 | public E next() throws DocumentException { 54 | if (closed) { 55 | throw new DocumentException("Stream already closed."); 56 | } 57 | 58 | return null; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/stream/IteratorStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.stream; 29 | 30 | import java.util.Iterator; 31 | 32 | import org.brackit.xquery.xdm.DocumentException; 33 | import org.brackit.xquery.xdm.Stream; 34 | 35 | /** 36 | * Thin wrapper bridging standard {@link Iterator} to the {@link Stream} 37 | * interface. 38 | * 39 | * @author Sebastian Baechle 40 | * 41 | * @param 42 | */ 43 | public class IteratorStream implements Stream { 44 | private Iterator it; 45 | 46 | public IteratorStream(Iterable iterable) { 47 | this.it = iterable.iterator(); 48 | } 49 | 50 | public IteratorStream(Iterator it) { 51 | this.it = it; 52 | } 53 | 54 | @Override 55 | public void close() { 56 | it = null; 57 | } 58 | 59 | @Override 60 | public E next() throws DocumentException { 61 | return (it.hasNext()) ? it.next() : null; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/stream/StreamUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.stream; 29 | 30 | import java.util.ArrayList; 31 | import java.util.List; 32 | 33 | import org.brackit.xquery.xdm.DocumentException; 34 | import org.brackit.xquery.xdm.Stream; 35 | 36 | /** 37 | * Utility class for {@link Stream Streams}. 38 | * 39 | * @author Sebastian Baechle 40 | * 41 | */ 42 | public class StreamUtil { 43 | public static List asList(Stream stream) throws DocumentException { 44 | List list = new ArrayList(); 45 | 46 | try { 47 | E e; 48 | while ((e = stream.next()) != null) { 49 | list.add(e); 50 | } 51 | } finally { 52 | stream.close(); 53 | } 54 | 55 | return list; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/stream/TransformerStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.stream; 29 | 30 | import org.brackit.xquery.xdm.DocumentException; 31 | import org.brackit.xquery.xdm.Stream; 32 | 33 | /** 34 | * Transforms the input of a given stream. 35 | * 36 | * @author Sebastian Baechle 37 | * 38 | * @param 39 | * @param 40 | */ 41 | public abstract class TransformerStream implements Stream { 42 | private final Stream in; 43 | 44 | public TransformerStream(Stream in) { 45 | super(); 46 | this.in = in; 47 | } 48 | 49 | @Override 50 | public void close() { 51 | in.close(); 52 | } 53 | 54 | @Override 55 | public E next() throws DocumentException { 56 | K k = in.next(); 57 | return (k != null) ? transform(k) : null; 58 | } 59 | 60 | protected abstract E transform(K next) throws DocumentException; 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/node/stream/filter/Filter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.stream.filter; 29 | 30 | import org.brackit.xquery.xdm.DocumentException; 31 | 32 | /** 33 | * @author Sebastian Baechle 34 | * 35 | * @param 36 | */ 37 | public interface Filter { 38 | /** 39 | * Returns true iff the given element does NOT fulfill 40 | * the filter predicate 41 | * 42 | * @param element 43 | * @return 44 | * @throws DocumentException 45 | * if an error occurs 46 | */ 47 | public boolean filter(T element) throws DocumentException; 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/operator/Cursor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.operator; 29 | 30 | import org.brackit.xquery.QueryContext; 31 | import org.brackit.xquery.QueryException; 32 | import org.brackit.xquery.Tuple; 33 | 34 | /** 35 | * 36 | * @author Sebastian Baechle 37 | */ 38 | public interface Cursor { 39 | public void open(QueryContext ctx) throws QueryException; 40 | 41 | public Tuple next(QueryContext ctx) throws QueryException; 42 | 43 | public void close(QueryContext ctx); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/operator/Operator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.operator; 29 | 30 | import org.brackit.xquery.QueryContext; 31 | import org.brackit.xquery.QueryException; 32 | import org.brackit.xquery.Tuple; 33 | 34 | /** 35 | * 36 | * @author Sebastian Baechle 37 | * 38 | */ 39 | public interface Operator { 40 | Cursor create(QueryContext ctx, Tuple tuple) throws QueryException; 41 | 42 | Cursor create(QueryContext ctx, Tuple[] t, int len) throws QueryException; 43 | 44 | int tupleWidth(int initSize); 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/sequence/BaseIter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.sequence; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.atomic.Counter; 32 | import org.brackit.xquery.atomic.IntNumeric; 33 | import org.brackit.xquery.xdm.Iter; 34 | 35 | /** 36 | * @author Sebastian Baechle 37 | * 38 | */ 39 | public abstract class BaseIter implements Iter { 40 | 41 | @Override 42 | public void skip(IntNumeric i) throws QueryException { 43 | Counter skipped = new Counter(); 44 | if (skipped.cmp(i) < 0) { 45 | while ((next() != null) && (skipped.inc().cmp(i) < 0)) 46 | ; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/sequence/NestedSequence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.sequence; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Sequence; 32 | 33 | /** 34 | * @author Sebastian Baechle 35 | * 36 | */ 37 | public class NestedSequence extends FlatteningSequence { 38 | 39 | private final Sequence[] seqs; 40 | 41 | public NestedSequence(Sequence... seqs) { 42 | this.seqs = seqs; 43 | } 44 | 45 | @Override 46 | protected Sequence sequence(int pos) throws QueryException { 47 | return (pos < seqs.length) ? seqs[pos++] : null; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/update/op/DeleteOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.update.op; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Node; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public class DeleteOp implements UpdateOp { 39 | private final Node target; 40 | 41 | public DeleteOp(Node target) { 42 | this.target = target; 43 | } 44 | 45 | @Override 46 | public void apply() throws QueryException { 47 | target.delete(); 48 | } 49 | 50 | @Override 51 | public Node getTarget() { 52 | return target; 53 | } 54 | 55 | @Override 56 | public OpType getType() { 57 | return OpType.DELETE; 58 | } 59 | 60 | public String toString() { 61 | StringBuilder out = new StringBuilder(); 62 | out.append(getType()); 63 | out.append(" "); 64 | out.append(target); 65 | return out.toString(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/update/op/InsertAfterOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.update.op; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Node; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public class InsertAfterOp extends AbstractInsertOp { 39 | public InsertAfterOp(Node target) { 40 | super(target); 41 | } 42 | 43 | @Override 44 | protected void doInsert(Node target, Node content) 45 | throws QueryException { 46 | target.insertAfter(content); 47 | } 48 | 49 | @Override 50 | public OpType getType() { 51 | return OpType.INSERT_AFTER; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/update/op/InsertAttributesOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.update.op; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Node; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public class InsertAttributesOp extends AbstractInsertOp { 39 | public InsertAttributesOp(Node target) { 40 | super(target); 41 | } 42 | 43 | @Override 44 | protected void doInsert(Node target, Node content) 45 | throws QueryException { 46 | target.setAttribute(content); 47 | } 48 | 49 | @Override 50 | public OpType getType() { 51 | return OpType.INSERT_ATTRIBUTES; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/update/op/InsertBeforeOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.update.op; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Node; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public class InsertBeforeOp extends AbstractInsertOp { 39 | public InsertBeforeOp(Node target) { 40 | super(target); 41 | } 42 | 43 | @Override 44 | protected void doInsert(Node target, Node content) 45 | throws QueryException { 46 | target.insertBefore(content); 47 | } 48 | 49 | @Override 50 | public OpType getType() { 51 | return OpType.INSERT_BEFORE; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/update/op/InsertIntoAsFirstOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.update.op; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Node; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public class InsertIntoAsFirstOp extends AbstractInsertOp { 39 | public InsertIntoAsFirstOp(Node target) { 40 | super(target); 41 | } 42 | 43 | @Override 44 | protected void doInsert(Node target, Node content) 45 | throws QueryException { 46 | target.prepend(content); 47 | } 48 | 49 | @Override 50 | public OpType getType() { 51 | return OpType.INSERT_INTO_AS_FIRST; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/update/op/InsertIntoAsLastOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.update.op; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Node; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public class InsertIntoAsLastOp extends AbstractInsertOp { 39 | public InsertIntoAsLastOp(Node target) { 40 | super(target); 41 | } 42 | 43 | @Override 44 | protected void doInsert(Node target, Node content) 45 | throws QueryException { 46 | target.append(content); 47 | } 48 | 49 | @Override 50 | public OpType getType() { 51 | return OpType.INSERT_INTO_AS_LAST; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/update/op/InsertIntoOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.update.op; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Node; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public class InsertIntoOp extends AbstractInsertOp { 39 | public InsertIntoOp(Node target) { 40 | super(target); 41 | } 42 | 43 | @Override 44 | protected void doInsert(Node target, Node content) 45 | throws QueryException { 46 | target.append(content); 47 | } 48 | 49 | @Override 50 | public OpType getType() { 51 | return OpType.INSERT_INTO; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/update/op/OpType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.update.op; 29 | 30 | /** 31 | * 32 | * @author Sebastian Baechle 33 | * 34 | */ 35 | public enum OpType { 36 | INSERT_INTO(0), 37 | 38 | INSERT_ATTRIBUTES(1), 39 | 40 | REPLACE_VALUE(2), 41 | 42 | RENAME(3), 43 | 44 | INSERT_BEFORE(4), 45 | 46 | INSERT_AFTER(5), 47 | 48 | INSERT_INTO_AS_FIRST(6), 49 | 50 | INSERT_INTO_AS_LAST(7), 51 | 52 | REPLACE_NODE(8), 53 | 54 | REPLACE_ELEMENT_CONTENT(9), 55 | 56 | DELETE(10); 57 | 58 | private final int priority; 59 | 60 | private OpType(int priority) { 61 | this.priority = priority; 62 | } 63 | 64 | public final int getPriority() { 65 | return priority; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/update/op/ReplaceValueOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.update.op; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.atomic.Atomic; 32 | import org.brackit.xquery.xdm.Node; 33 | 34 | /** 35 | * 36 | * @author Sebastian Baechle 37 | * 38 | */ 39 | public class ReplaceValueOp implements UpdateOp { 40 | private final Node target; 41 | 42 | private final Atomic value; 43 | 44 | public ReplaceValueOp(Node target, Atomic value) { 45 | this.target = target; 46 | this.value = value; 47 | } 48 | 49 | @Override 50 | public void apply() throws QueryException { 51 | target.setValue(value); 52 | } 53 | 54 | @Override 55 | public Node getTarget() { 56 | return target; 57 | } 58 | 59 | @Override 60 | public OpType getType() { 61 | return OpType.REPLACE_VALUE; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/update/op/UpdateOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.update.op; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Node; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public interface UpdateOp { 39 | public Node getTarget(); 40 | 41 | public void apply() throws QueryException; 42 | 43 | public OpType getType(); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/util/aggregator/Aggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.util.aggregator; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Sequence; 32 | 33 | /** 34 | * @author Sebastian Baechle 35 | * 36 | */ 37 | public interface Aggregator { 38 | public Sequence getAggregate() throws QueryException; 39 | 40 | public void add(Sequence seq) throws QueryException; 41 | 42 | public void clear(); 43 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/util/aggregator/SingleAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.util.aggregator; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Sequence; 32 | 33 | /** 34 | * @author Sebastian Baechle 35 | * 36 | */ 37 | public class SingleAggregator implements Aggregator { 38 | 39 | private Sequence s; 40 | 41 | @Override 42 | public Sequence getAggregate() throws QueryException { 43 | return s; 44 | } 45 | 46 | @Override 47 | public void add(Sequence seq) throws QueryException { 48 | if (s == null) { 49 | s = seq; 50 | } 51 | } 52 | 53 | @Override 54 | public void clear() { 55 | s = null; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/util/annotation/FunctionAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.util.annotation; 29 | 30 | import java.lang.annotation.Documented; 31 | import java.lang.annotation.ElementType; 32 | import java.lang.annotation.Retention; 33 | import java.lang.annotation.RetentionPolicy; 34 | import java.lang.annotation.Target; 35 | 36 | /** 37 | * @author Roxana Zapata 38 | * 39 | */ 40 | @Documented 41 | @Retention(RetentionPolicy.RUNTIME) 42 | @Target(value = { ElementType.TYPE }) 43 | public @interface FunctionAnnotation { 44 | String description(); 45 | String[] parameters(); 46 | String example() default "unimplemented"; 47 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/util/annotation/ModuleAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.util.annotation; 29 | 30 | import java.lang.annotation.Documented; 31 | import java.lang.annotation.ElementType; 32 | import java.lang.annotation.Retention; 33 | import java.lang.annotation.RetentionPolicy; 34 | import java.lang.annotation.Target; 35 | 36 | /** 37 | * @author Roxana Zapata 38 | * 39 | */ 40 | @Documented 41 | @Retention(RetentionPolicy.RUNTIME) 42 | @Target(value = { ElementType.TYPE }) 43 | public @interface ModuleAnnotation { 44 | String description(); 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/util/dot/DotEdge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.util.dot; 29 | 30 | /** 31 | * 32 | * @author Sebastian Baechle 33 | * 34 | */ 35 | public class DotEdge { 36 | final String src; 37 | final String dest; 38 | 39 | DotEdge(String src, String dest) { 40 | this.src = src; 41 | this.dest = dest; 42 | } 43 | 44 | public String toDotString() { 45 | return DotContext.maskHTML(src) + ":port -> " 46 | + DotContext.maskHTML(dest) + ":port;"; 47 | } 48 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/util/log/LogFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.util.log; 29 | 30 | /** 31 | * 32 | * @author Sebastian Baechle 33 | * 34 | */ 35 | public interface LogFactory { 36 | public Logger getLogger(String name); 37 | 38 | public Logger getRootLogger(); 39 | } -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/util/path/PathException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.util.path; 29 | 30 | import org.brackit.xquery.xdm.DocumentException; 31 | 32 | /** 33 | * 34 | * @author Sebastian Baechle 35 | * 36 | */ 37 | public class PathException extends DocumentException { 38 | public PathException() { 39 | } 40 | 41 | public PathException(String message, Object... args) { 42 | super(message, args); 43 | } 44 | 45 | public PathException(Throwable cause, String message, Object... args) { 46 | super(cause, message, args); 47 | } 48 | 49 | public PathException(Throwable cause) { 50 | super(cause); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/util/serialize/Serializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.util.serialize; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Sequence; 32 | 33 | /** 34 | * @author Sebastian Baechle 35 | * 36 | */ 37 | public interface Serializer { 38 | public void serialize(Sequence s) throws QueryException; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/xdm/Collection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.xdm; 29 | 30 | import org.brackit.xquery.atomic.AnyURI; 31 | import org.brackit.xquery.node.parser.SubtreeParser; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | * @param 38 | */ 39 | public interface Collection> extends Sequence { 40 | 41 | public AnyURI getDocumentURI(); 42 | 43 | public String getName(); 44 | 45 | public void delete() throws DocumentException; 46 | 47 | public void remove(long documentID) throws OperationNotSupportedException, 48 | DocumentException; 49 | 50 | public E getDocument() throws DocumentException; 51 | 52 | public Stream getDocuments() throws DocumentException; 53 | 54 | public E add(SubtreeParser parser) throws OperationNotSupportedException, 55 | DocumentException; 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/xdm/DocumentException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.xdm; 29 | 30 | import org.brackit.xquery.ErrorCode; 31 | import org.brackit.xquery.QueryException; 32 | 33 | /** 34 | * Indicates an access error to a document. 35 | * 36 | * @author Sebastian Baechle 37 | * 38 | */ 39 | public class DocumentException extends QueryException { 40 | public DocumentException() { 41 | super(ErrorCode.BIT_DYN_DOCUMENT_ACCESS_ERROR); 42 | } 43 | 44 | public DocumentException(Throwable cause) { 45 | super(cause, ErrorCode.BIT_DYN_DOCUMENT_ACCESS_ERROR); 46 | } 47 | 48 | public DocumentException(Throwable cause, String message, Object... args) { 49 | super(cause, ErrorCode.BIT_DYN_DOCUMENT_ACCESS_ERROR, message, args); 50 | } 51 | 52 | public DocumentException(String message, Object... args) { 53 | super(ErrorCode.BIT_DYN_DOCUMENT_ACCESS_ERROR, message, args); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/xdm/Function.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.xdm; 29 | 30 | import org.brackit.xquery.QueryContext; 31 | import org.brackit.xquery.QueryException; 32 | import org.brackit.xquery.atomic.QNm; 33 | import org.brackit.xquery.module.StaticContext; 34 | 35 | /** 36 | * 37 | * @author Sebastian Baechle 38 | * 39 | */ 40 | public interface Function extends Item { 41 | public QNm getName(); 42 | 43 | public Signature getSignature(); 44 | 45 | public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) 46 | throws QueryException; 47 | 48 | public boolean isUpdating(); 49 | 50 | public boolean isBuiltIn(); 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/xdm/Item.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.xdm; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.atomic.Atomic; 32 | import org.brackit.xquery.xdm.type.ItemType; 33 | 34 | /** 35 | * Item as defined in {@linkplain http://www.w3.org/TR/xpath-datamodel}. 36 | * 37 | * @author Sebastian Baechle 38 | * 39 | */ 40 | public interface Item extends Sequence { 41 | 42 | /** 43 | * Returns the {@link ItemType] of this item. 44 | */ 45 | public ItemType itemType() throws QueryException; 46 | 47 | /** 48 | * Returns the atomized value of this item. 49 | * 50 | * @see http://www.w3.org/TR/xquery/#dt-atomization 51 | * @see http://www.w3.org/TR/xquery-operators/#func-data 52 | */ 53 | public Atomic atomize() throws QueryException; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/xdm/Kind.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.xdm; 29 | 30 | /** 31 | * 32 | * @author Sebastian Baechle 33 | * 34 | */ 35 | public enum Kind { 36 | DOCUMENT((byte) 0), ELEMENT((byte) 1), ATTRIBUTE((byte) 2), TEXT((byte) 3), PROCESSING_INSTRUCTION( 37 | (byte) 4), COMMENT((byte) 5), NAMESPACE((byte) 6); 38 | 39 | public final byte ID; 40 | 41 | public static final Kind[] map = Kind.values(); 42 | 43 | private Kind(byte id) { 44 | this.ID = id; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/xdm/ListOrUnion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.xdm; 29 | 30 | /** 31 | * @author Sebastian Baechle 32 | * 33 | */ 34 | public interface ListOrUnion extends Item { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/xdm/OperationNotSupportedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.xdm; 29 | 30 | /** 31 | * This exception is thrown when the requested operation is not supported for a 32 | * node. 33 | * 34 | * This exception generally indicates a programming error leading to a misuse of 35 | * nodes. 36 | * 37 | * @author Sebastian Baechle 38 | * 39 | */ 40 | public class OperationNotSupportedException extends DocumentException { 41 | public OperationNotSupportedException() { 42 | super(); 43 | } 44 | 45 | public OperationNotSupportedException(String message, Object... args) { 46 | super(message, args); 47 | } 48 | 49 | public OperationNotSupportedException(Throwable cause, String message, 50 | Object... args) { 51 | super(cause, message, args); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/xdm/Store.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.xdm; 29 | 30 | import org.brackit.xquery.node.parser.SubtreeParser; 31 | 32 | /** 33 | * 34 | * @author Sebastian Baechle 35 | * 36 | */ 37 | public interface Store { 38 | public Collection lookup(String name) throws DocumentException; 39 | 40 | public Collection create(String name) throws DocumentException; 41 | 42 | public Collection create(String name, SubtreeParser parser) 43 | throws DocumentException; 44 | 45 | public Collection create(String name, Stream parsers) 46 | throws DocumentException; 47 | 48 | public void drop(String name) throws DocumentException; 49 | 50 | public void makeDir(String path) throws DocumentException; 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/xdm/type/AnyNodeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.xdm.type; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Item; 32 | import org.brackit.xquery.xdm.Node; 33 | 34 | /** 35 | * 36 | * @author Sebastian Baechle 37 | * 38 | */ 39 | public final class AnyNodeType extends NodeType { 40 | public static final AnyNodeType ANY_NODE = new AnyNodeType(); 41 | 42 | public AnyNodeType() { 43 | } 44 | 45 | @Override 46 | public boolean matches(Node node) 47 | throws QueryException { 48 | return true; 49 | } 50 | 51 | @Override 52 | public boolean matches(Item item) throws QueryException { 53 | return (item instanceof Node); 54 | } 55 | 56 | public String toString() { 57 | return "node()"; 58 | } 59 | 60 | public boolean equals(Object obj) { 61 | return ((obj == this) || (obj instanceof AnyNodeType)); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/xdm/type/Cardinality.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.xdm.type; 29 | 30 | /** 31 | * 32 | * @author Sebastian Baechle 33 | * 34 | */ 35 | public enum Cardinality { 36 | Zero, // empty-sequence() 37 | One, ZeroOrOne, // ? 38 | OneOrMany, // + 39 | ZeroOrMany; // * 40 | 41 | public final boolean moreThanZero() { 42 | return (this == One) || (this == OneOrMany); 43 | } 44 | 45 | public final boolean many() { 46 | return ((this == OneOrMany) || (this == ZeroOrMany)); 47 | } 48 | 49 | public final boolean atMostOne() { 50 | return ((this == ZeroOrOne) || (this == One)); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/brackit/xquery/xdm/type/ItemType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.xdm.type; 29 | 30 | import org.brackit.xquery.QueryException; 31 | import org.brackit.xquery.xdm.Item; 32 | 33 | /** 34 | * 35 | * @author Sebastian Baechle 36 | * 37 | */ 38 | public interface ItemType { 39 | 40 | public boolean matches(Item item) throws QueryException; 41 | 42 | public boolean isAnyItem(); 43 | 44 | public boolean isAtomic(); 45 | 46 | public boolean isNode(); 47 | 48 | public boolean isFunction(); 49 | 50 | public boolean isListOrUnion(); 51 | 52 | public boolean isRecord(); 53 | } 54 | -------------------------------------------------------------------------------- /src/main/resources/logging.properties: -------------------------------------------------------------------------------- 1 | # basic java.util.logging config 2 | handlers= java.util.logging.ConsoleHandler 3 | .level= WARNING 4 | java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter 5 | -------------------------------------------------------------------------------- /src/test/java/org/brackit/xquery/XMarkTestNested.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery; 29 | 30 | import java.io.FileNotFoundException; 31 | 32 | import org.brackit.xquery.compiler.optimizer.DefaultOptimizer; 33 | import org.brackit.xquery.util.Cfg; 34 | 35 | /** 36 | * @author Sebastian Baechle 37 | * 38 | */ 39 | public class XMarkTestNested extends XMarkTest { 40 | 41 | @Override 42 | public void setUp() throws Exception, FileNotFoundException { 43 | super.setUp(); 44 | Cfg.set(DefaultOptimizer.UNNEST_CFG, false); 45 | DefaultOptimizer.UNNEST = false; 46 | Cfg.set(DefaultOptimizer.JOIN_DETECTION_CFG, false); 47 | DefaultOptimizer.JOIN_DETECTION = false; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/org/brackit/xquery/XMarkTestUnnested.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery; 29 | 30 | import java.io.FileNotFoundException; 31 | 32 | import org.brackit.xquery.compiler.optimizer.DefaultOptimizer; 33 | import org.brackit.xquery.util.Cfg; 34 | 35 | /** 36 | * @author Sebastian Baechle 37 | * 38 | */ 39 | public class XMarkTestUnnested extends XMarkTest { 40 | 41 | @Override 42 | public void setUp() throws Exception, FileNotFoundException { 43 | super.setUp(); 44 | Cfg.set(DefaultOptimizer.UNNEST_CFG, true); 45 | DefaultOptimizer.UNNEST = true; 46 | Cfg.set(DefaultOptimizer.JOIN_DETECTION_CFG, false); 47 | DefaultOptimizer.JOIN_DETECTION = false; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/org/brackit/xquery/XMarkTestUnnestedJoin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery; 29 | 30 | import java.io.FileNotFoundException; 31 | 32 | import org.brackit.xquery.compiler.optimizer.DefaultOptimizer; 33 | import org.brackit.xquery.util.Cfg; 34 | 35 | /** 36 | * @author Sebastian Baechle 37 | * 38 | */ 39 | public class XMarkTestUnnestedJoin extends XMarkTest { 40 | 41 | @Override 42 | public void setUp() throws Exception, FileNotFoundException { 43 | super.setUp(); 44 | Cfg.set(DefaultOptimizer.UNNEST_CFG, true); 45 | DefaultOptimizer.UNNEST = true; 46 | Cfg.set(DefaultOptimizer.JOIN_DETECTION_CFG, true); 47 | DefaultOptimizer.JOIN_DETECTION = true; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/org/brackit/xquery/node/d2linked/D2NodeAxisTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.d2linked; 29 | 30 | import org.brackit.xquery.node.AxisTest; 31 | import org.brackit.xquery.node.SimpleStore; 32 | import org.brackit.xquery.xdm.NodeFactory; 33 | import org.brackit.xquery.xdm.Store; 34 | 35 | /** 36 | * 37 | * @author Sebastian Baechle 38 | * 39 | */ 40 | public class D2NodeAxisTest extends AxisTest { 41 | @Override 42 | protected Store createStore() throws Exception { 43 | return new SimpleStore() { 44 | @Override 45 | protected NodeFactory getNodeFactory() { 46 | return new D2NodeFactory(); 47 | } 48 | }; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/org/brackit/xquery/node/d2linked/D2NodeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * [New BSD License] 3 | * Copyright (c) 2011-2012, Brackit Project Team 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Brackit Project Team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.brackit.xquery.node.d2linked; 29 | 30 | import org.brackit.xquery.node.NodeTest; 31 | import org.brackit.xquery.node.parser.DocumentParser; 32 | import org.brackit.xquery.xdm.Collection; 33 | import org.brackit.xquery.xdm.DocumentException; 34 | 35 | /** 36 | * 37 | * @author Sebastian Baechle 38 | * 39 | */ 40 | public class D2NodeTest extends NodeTest { 41 | 42 | @Override 43 | protected Collection createDocument(DocumentParser documentParser) 44 | throws DocumentException { 45 | return new D2NodeFactory().build(documentParser).getCollection(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/resources/docs/orga.xml: -------------------------------------------------------------------------------- 1 | KurtMayer1.4.1963Dr.-Ing.HansMettmann12.9.1974Dipl.-InfXML-DB10000DISS7000NativeXML-Databases -------------------------------------------------------------------------------- /src/test/resources/join/forNestedFor.xq: -------------------------------------------------------------------------------- 1 | for $a in (1 to 5) 2 | let $b:= for $c in ((2 to 3),(5 to 8)) 3 | where $a = $c 4 | return $c 5 | return $b -------------------------------------------------------------------------------- /src/test/resources/join/forNestedFor2JoinPredicates.xq: -------------------------------------------------------------------------------- 1 | for $a in (1 to 5) 2 | let $b:= for $c in ((2 to 3),(5 to 8)) 3 | where $a = $c 4 | where $c = $a 5 | let $d:= $c+1 6 | return $d 7 | return $b -------------------------------------------------------------------------------- /src/test/resources/join/forNestedForWithOutsideRef.xq: -------------------------------------------------------------------------------- 1 | let $x := 1 2 | let $y := 1 3 | let $z := ( 4 | for $a in ($x to 5) 5 | for $b in (1 to 2) 6 | let $c:= for $d in (($x+1 to 3),(5 to 8)) 7 | where $a = $d 8 | let $e := $y 9 | return $d 10 | return $c + $x 11 | ) 12 | return $z -------------------------------------------------------------------------------- /src/test/resources/join/simpleForFor.xq: -------------------------------------------------------------------------------- 1 | for $a in (1 to 5) 2 | for $b in ((2 to 3),(5 to 8)) 3 | where $a = $b 4 | return $a -------------------------------------------------------------------------------- /src/test/resources/parser/weird.xq: -------------------------------------------------------------------------------- 1 | declare namespace namespace = "http://example.com"; 2 | declare union for gibberish { 3 | for $for in for return ***div div 4 | }, 5 | if(if) then then else else- +-++-**-* instance 6 | of element(*)* * * **---++div- div -div 7 | -------------------------------------------------------------------------------- /src/test/resources/xmark/mini.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | United States 6 | 1 7 | duteous nine eighteen 8 | Creditcard 9 | 10 | 11 | 12 | 13 | page rous lady idle authority capt professes stabs monster 14 | petition heave humbly removes rescue runs shady peace most 15 | piteous worser oak assembly holes patience but malice whoreson 16 | mirrors master tenants smocks yielded 17 | officer embrace such fears distinction attires 18 | 19 | 20 | 21 | 22 | 23 | shepherd noble supposed dotage humble servilius bitch theirs venus 24 | dismal wounds gum merely raise red breaks earth god folds closet 25 | captain dying reek 26 | 27 | 28 | 29 | 30 | Will ship internationally, See description for charges 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | Libero Rive mailto:Rive@hitachi.com 40 | Benedikte Glew mailto:Glew@sds.no 41 | 07/05/2000 42 | 43 | virgin preventions half logotype weapons granted factious already 44 | carved fretted impress pestilent 45 | girdles deserts flood george nobility reprieve 46 | 47 | discomfort sinful conceiv corn preventions greatly suit observe 48 | sinews enforcement 49 | armed 50 | gold gazing set almost catesby turned servilius cook doublet 51 | preventions shrunk smooth great choice enemy disguis tender might 52 | deceit ros dreadful stabbing fold unjustly ruffian life hamlet 53 | containing leaves 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q01.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $b in $auction/site/people/person[@id = "person0"] return $b/name/text() 3 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q02.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $b in $auction/site/open_auctions/open_auction 3 | return {$b/bidder[1]/increase/text()} 4 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q03.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $b in $auction/site/open_auctions/open_auction 3 | where zero-or-one($b/bidder[1]/increase/text()) * 2 <= $b/bidder[last()]/increase/text() 4 | return 5 | 8 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q04.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $b in $auction/site/open_auctions/open_auction 3 | where 4 | some $pr1 in $b/bidder/personref[@person = "person20"], 5 | $pr2 in $b/bidder/personref[@person = "person51"] 6 | satisfies $pr1 << $pr2 7 | return {$b/reserve/text()} 8 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q05.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | count( 3 | for $i in $auction/site/closed_auctions/closed_auction 4 | where $i/price/text() >= 40 5 | return $i/price 6 | ) 7 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q06.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $b in $auction//site/regions return count($b//item) 3 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q07.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $p in $auction/site 3 | return 4 | count($p//description) + count($p//annotation) + count($p//emailaddress) 5 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q08.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $p in $auction/site/people/person 3 | let $a := 4 | for $t in $auction/site/closed_auctions/closed_auction 5 | where $t/buyer/@person = $p/@id 6 | return $t 7 | return {count($a)} 8 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q09.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | let $ca := $auction/site/closed_auctions/closed_auction return 3 | let 4 | $ei := $auction/site/regions/europe/item 5 | for $p in $auction/site/people/person 6 | let $a := 7 | for $t in $ca 8 | where $p/@id = $t/buyer/@person 9 | return 10 | let $n := for $t2 in $ei where $t/itemref/@item = $t2/@id return $t2 11 | return {$n/name/text()} 12 | return {$a} 13 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q10.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $i in 3 | distinct-values($auction/site/people/person/profile/interest/@category) 4 | let $p := 5 | for $t in $auction/site/people/person 6 | where $t/profile/interest/@category = $i 7 | return 8 | 9 | 10 | {$t/profile/gender/text()} 11 | {$t/profile/age/text()} 12 | {$t/profile/education/text()} 13 | {fn:data($t/profile/@income)} 14 | 15 | 16 | {$t/name/text()} 17 | {$t/address/street/text()} 18 | {$t/address/city/text()} 19 | {$t/address/country/text()} 20 | 21 | {$t/emailaddress/text()} 22 | {$t/homepage/text()} 23 | 24 | 25 | {$t/creditcard/text()} 26 | 27 | return {{$i}, $p} 28 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q11.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $p in $auction/site/people/person 3 | let $l := 4 | for $i in $auction/site/open_auctions/open_auction/initial 5 | where $p/profile/@income > 5000 * exactly-one($i/text()) 6 | return $i 7 | return {count($l)} 8 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q12.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $p in $auction/site/people/person 3 | let $l := 4 | for $i in $auction/site/open_auctions/open_auction/initial 5 | where $p/profile/@income > 5000 * exactly-one($i/text()) 6 | return $i 7 | where $p/profile/@income > 50000 8 | return {count($l)} 9 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q13.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $i in $auction/site/regions/australia/item 3 | return {$i/description} 4 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q14.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $i in $auction/site//item 3 | where contains(string(exactly-one($i/description)), "gold") 4 | return $i/name/text() 5 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q15.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $a in 3 | $auction/site/closed_auctions/closed_auction/annotation/description/parlist/ 4 | listitem/ 5 | parlist/ 6 | listitem/ 7 | text/ 8 | emph/ 9 | keyword/ 10 | text() 11 | return {$a} 12 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q16.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $a in $auction/site/closed_auctions/closed_auction 3 | where 4 | not( 5 | empty( 6 | $a/annotation/description/parlist/listitem/parlist/listitem/text/emph/ 7 | keyword/ 8 | text() 9 | ) 10 | ) 11 | return 12 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q17.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $p in $auction/site/people/person 3 | where empty($p/homepage/text()) 4 | return 5 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q18.xq: -------------------------------------------------------------------------------- 1 | declare namespace local = "http://www.foobar.org"; 2 | declare function local:convert($v as xs:decimal?) as xs:decimal? 3 | { 4 | 2.20371 * $v (: convert Dfl to Euro :) 5 | }; 6 | let $auction := doc('auction.xml') return 7 | for $i in $auction/site/open_auctions/open_auction 8 | return local:convert(zero-or-one($i/reserve)) -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q19.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | for $b in $auction/site/regions//item 3 | let $k := $b/name/text() 4 | order by zero-or-one($b/location) ascending 5 | return {$b/location/text()} 6 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/fndoc/q20.xq: -------------------------------------------------------------------------------- 1 | let $auction := doc("auction.xml") return 2 | 3 | 4 | {count($auction/site/people/person/profile[@income >= 100000])} 5 | 6 | 7 | { 8 | count( 9 | $auction/site/people/person/ 10 | profile[@income < 100000 and @income >= 30000] 11 | ) 12 | } 13 | 14 | 15 | {count($auction/site/people/person/profile[@income < 30000])} 16 | 17 | 18 | { 19 | count( 20 | for $p in $auction/site/people/person 21 | where empty($p/profile/@income) 22 | return $p 23 | ) 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q01.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $b in $auction/site/people/person[@id = "person0"] return $b/name/text() 3 | 4 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q02.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $b in $auction/site/open_auctions/open_auction 3 | return {$b/bidder[1]/increase/text()} 4 | 5 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q03.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $b in $auction/site/open_auctions/open_auction 3 | where zero-or-one($b/bidder[1]/increase/text()) * 2 <= $b/bidder[last()]/increase/text() 4 | return 5 | 8 | 9 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q04.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $b in $auction/site/open_auctions/open_auction 3 | where 4 | some $pr1 in $b/bidder/personref[@person = "person20"], 5 | $pr2 in $b/bidder/personref[@person = "person51"] 6 | satisfies $pr1 << $pr2 7 | return {$b/reserve/text()} 8 | 9 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q05.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | count( 3 | for $i in $auction/site/closed_auctions/closed_auction 4 | where $i/price/text() >= 40 5 | return $i/price 6 | ) 7 | 8 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q06.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $b in $auction//site/regions return count($b//item) 3 | 4 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q07.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $p in $auction/site 3 | return 4 | count($p//description) + count($p//annotation) + count($p//emailaddress) 5 | 6 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q08.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $p in $auction/site/people/person 3 | let $a := 4 | for $t in $auction/site/closed_auctions/closed_auction 5 | where $t/buyer/@person = $p/@id 6 | return $t 7 | return {count($a)} 8 | 9 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q09.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | let $ca := $auction/site/closed_auctions/closed_auction return 3 | let 4 | $ei := $auction/site/regions/europe/item 5 | for $p in $auction/site/people/person 6 | let $a := 7 | for $t in $ca 8 | where $p/@id = $t/buyer/@person 9 | return 10 | let $n := for $t2 in $ei where $t/itemref/@item = $t2/@id return $t2 11 | return {$n/name/text()} 12 | return {$a} 13 | 14 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q10.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $i in 3 | distinct-values($auction/site/people/person/profile/interest/@category) 4 | let $p := 5 | for $t in $auction/site/people/person 6 | where $t/profile/interest/@category = $i 7 | return 8 | 9 | 10 | {$t/profile/gender/text()} 11 | {$t/profile/age/text()} 12 | {$t/profile/education/text()} 13 | {fn:data($t/profile/@income)} 14 | 15 | 16 | {$t/name/text()} 17 | {$t/address/street/text()} 18 | {$t/address/city/text()} 19 | {$t/address/country/text()} 20 | 21 | {$t/emailaddress/text()} 22 | {$t/homepage/text()} 23 | 24 | 25 | {$t/creditcard/text()} 26 | 27 | return {{$i}, $p} 28 | 29 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q11.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $p in $auction/site/people/person 3 | let $l := 4 | for $i in $auction/site/open_auctions/open_auction/initial 5 | where $p/profile/@income > 5000 * exactly-one($i/text()) 6 | return $i 7 | return {count($l)} 8 | 9 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q12.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $p in $auction/site/people/person 3 | let $l := 4 | for $i in $auction/site/open_auctions/open_auction/initial 5 | where $p/profile/@income > 5000 * exactly-one($i/text()) 6 | return $i 7 | where $p/profile/@income > 50000 8 | return {count($l)} 9 | 10 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q13.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $i in $auction/site/regions/australia/item 3 | return {$i/description} 4 | 5 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q14.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $i in $auction/site//item 3 | where contains(string(exactly-one($i/description)), "gold") 4 | return $i/name/text() 5 | 6 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q15.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $a in 3 | $auction/site/closed_auctions/closed_auction/annotation/description/parlist/ 4 | listitem/ 5 | parlist/ 6 | listitem/ 7 | text/ 8 | emph/ 9 | keyword/ 10 | text() 11 | return {$a} 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q16.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $a in $auction/site/closed_auctions/closed_auction 3 | where 4 | not( 5 | empty( 6 | $a/annotation/description/parlist/listitem/parlist/listitem/text/emph/ 7 | keyword/ 8 | text() 9 | ) 10 | ) 11 | return 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q17.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $p in $auction/site/people/person 3 | where empty($p/homepage/text()) 4 | return 5 | 6 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q18.xq: -------------------------------------------------------------------------------- 1 | declare namespace local = "http://www.foobar.org"; 2 | declare function local:convert($v as xs:decimal?) as xs:decimal? 3 | { 4 | 2.20371 * $v (: convert Dfl to Euro :) 5 | }; 6 | 7 | let $auction := . return 8 | for $i in $auction/site/open_auctions/open_auction 9 | return local:convert(zero-or-one($i/reserve)) 10 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q19.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | for $b in $auction/site/regions//item 3 | let $k := $b/name/text() 4 | order by zero-or-one($b/location) ascending empty greatest 5 | return {$b/location/text()} 6 | 7 | -------------------------------------------------------------------------------- /src/test/resources/xmark/queries/orig/q20.xq: -------------------------------------------------------------------------------- 1 | let $auction := . return 2 | 3 | 4 | {count($auction/site/people/person/profile[@income >= 100000])} 5 | 6 | 7 | { 8 | count( 9 | $auction/site/people/person/ 10 | profile[@income < 100000 and @income >= 30000] 11 | ) 12 | } 13 | 14 | 15 | {count($auction/site/people/person/profile[@income < 30000])} 16 | 17 | 18 | { 19 | count( 20 | for $p in $auction/site/people/person 21 | where empty($p/profile/@income) 22 | return $p 23 | ) 24 | } 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q01.out: -------------------------------------------------------------------------------- 1 | Sinisa Farrel 2 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q03.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q04.out: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q05.out: -------------------------------------------------------------------------------- 1 | 75 2 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q06.out: -------------------------------------------------------------------------------- 1 | 217 2 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q07.out: -------------------------------------------------------------------------------- 1 | 916 2 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q12.out: -------------------------------------------------------------------------------- 1 | 1913131913131419122019141813151313131220141920132619181317191729192017132212121720131313131320191913221820131321191317 2 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q14.out: -------------------------------------------------------------------------------- 1 | condemn answer misdoubt nearest sighs wronged revels swell coz house tougher stayed surly ready fight troyan conscience licence spain dare following england sing editions gets falcon tells henry mocks sadness wrought sentence fall mournings hovel towards utter revenged news 2 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q15.out: -------------------------------------------------------------------------------- 1 | fought enforce stare scant hence earthquake turns out yond knaves enemy claudio sink heal council intelligence made warlike gave alone mov shrewd fortune confirm outside polonius threatens flowers wisely summons mar wives banners strife knaves romeo oxford moral dearly mistrust health silent 2 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q16.out: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q18.out: -------------------------------------------------------------------------------- 1 | 862.9067247 177.9275454 257.2390683 309.0482904 676.1863764 675.3269295 84.0494994 431.5745664 1368.6361326 267.2218746 1349.4858927 1299.7701951 38.0580717 14.0596698 261.0955608 41.3856738 1711.3571118 738.683592 94.8476784 2240.7764022 320.2872114 347.525067 2985.2116773 5924.1454446 1905.8565564 87.5974725 479.6374815 651.2403792 343.4702406 9.0792852 237.8904945 186.5660886 78.5622615 225.9463863 100.0704711 142.7342967 93.4152669 945.832332 608.9952585 130.1951868 320.8381389 150.3370962 1174.8859494 1699.8757827 40.1515962 304.2662397 249.8346027 471.5057916 373.3745853 151.5050625 517.7175903 30.5654577 525.6509463 887.5442025 2244.8312286 621.3580716 897.9016395 225.6378669 489.0473232 17.8941252 330.1377951 1590.637878 5605.4008302 70.0339038 2 | -------------------------------------------------------------------------------- /src/test/resources/xmark/results/q20.out: -------------------------------------------------------------------------------- 1 | 29046117 2 | --------------------------------------------------------------------------------