JSONiq array parser, constructor, and printer with test cases.
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePoolFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePoolFactory.java
index 9ec9bab..9f440d4 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePoolFactory.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/PointablePoolFactory.java
@@ -24,6 +24,7 @@
import org.apache.vxquery.datamodel.accessors.atomic.XSDurationPointable;
import org.apache.vxquery.datamodel.accessors.atomic.XSQNamePointable;
import org.apache.vxquery.datamodel.accessors.atomic.XSTimePointable;
+import org.apache.vxquery.datamodel.accessors.jsonitem.ArrayPointable;
import org.apache.vxquery.datamodel.accessors.nodes.AttributeNodePointable;
import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
@@ -73,6 +74,7 @@
pp.register(NodeTreePointable.class, NodeTreePointable.FACTORY);
pp.register(DocumentNodePointable.class, DocumentNodePointable.FACTORY);
pp.register(ElementNodePointable.class, ElementNodePointable.FACTORY);
+ pp.register(ArrayPointable.class, ArrayPointable.FACTORY);
pp.register(AttributeNodePointable.class, AttributeNodePointable.FACTORY);
pp.register(TextOrCommentNodePointable.class, TextOrCommentNodePointable.FACTORY);
pp.register(PINodePointable.class, PINodePointable.FACTORY);
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml b/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
index c367725..05582e8 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
+++ b/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
@@ -852,6 +852,13 @@
<param name="content" type="node()"/>
<return type="node()"/>
</operator>
+
+ <!-- opext:array-constructor($expression as node()) as node() -->
+ <operator name="opext:array-constructor">
+ <param name="expession" type="node()"/>
+ <return type="item()"/>
+ <runtime type="scalar" class="org.apache.vxquery.runtime.functions.node.ArrayConstructorScalarEvaluatorFactory"/>
+ </operator>
<!-- opext:if-then-else($condition as xs:boolean, $then as item()*, $else as item()*) as item()* -->
<operator name="opext:if-then-else">
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluator.java
new file mode 100644
index 0000000..7386ce9
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluator.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.vxquery.runtime.functions.node;
+
+import java.io.IOException;
+
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.builders.jsonitem.ArrayBuilder;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
+
+public class ArrayConstructorScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
+ protected final IHyracksTaskContext ctx;
+
+ private final ArrayBackedValueStorage mvs;
+
+ private final ArrayBuilder ab;
+
+ private final SequencePointable sp;
+
+ public ArrayConstructorScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
+ super(args);
+ this.ctx = ctx;
+ ab = new ArrayBuilder();
+ sp = (SequencePointable) SequencePointable.FACTORY.createPointable();
+ mvs = new ArrayBackedValueStorage();
+ }
+
+ @Override
+ protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
+ mvs.reset();
+ try {
+ ab.reset(mvs);
+ TaggedValuePointable arg = args[0];
+ if (arg.getTag() == ValueTag.SEQUENCE_TAG) {
+ TaggedValuePointable tempTvp = ppool.takeOne(TaggedValuePointable.class);
+ try {
+ arg.getValue(sp);
+ for (int i = 0; i < sp.getEntryCount(); ++i) {
+ sp.getEntry(i, tempTvp);
+ ab.addItem(tempTvp);
+ }
+ } finally {
+ ppool.giveBack(tempTvp);
+ }
+ } else {
+ ab.addItem(arg);
+ }
+ ab.finish();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ result.set(mvs);
+ }
+
+}
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluatorFactory.java
new file mode 100644
index 0000000..c70a8e2
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluatorFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.vxquery.runtime.functions.node;
+
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
+
+public class ArrayConstructorScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory {
+ private static final long serialVersionUID = 1L;
+
+ public ArrayConstructorScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+ super(args);
+ }
+
+ @Override
+ protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
+ throws AlgebricksException {
+ return new ArrayConstructorScalarEvaluator(ctx, args);
+ }
+}
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java b/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java
index 5c55731..8b83995 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java
@@ -32,6 +32,7 @@
import org.apache.vxquery.datamodel.accessors.atomic.XSDurationPointable;
import org.apache.vxquery.datamodel.accessors.atomic.XSQNamePointable;
import org.apache.vxquery.datamodel.accessors.atomic.XSTimePointable;
+import org.apache.vxquery.datamodel.accessors.jsonitem.ArrayPointable;
import org.apache.vxquery.datamodel.accessors.nodes.AttributeNodePointable;
import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
@@ -220,6 +221,10 @@
printElementNode(ps, tvp);
break;
+ case ValueTag.ARRAY_TAG:
+ printArray(ps, tvp);
+ break;
+
case ValueTag.ATTRIBUTE_NODE_TAG:
printAttributeNode(ps, tvp);
break;
@@ -441,6 +446,28 @@
}
}
+ private void printArray(PrintStream ps, TaggedValuePointable tvp) {
+ ArrayPointable ap = pp.takeOne(ArrayPointable.class);
+ try {
+ tvp.getValue(ap);
+ int len = ap.getEntryCount();
+ ps.append('[');
+ ps.append(' ');
+ for (int i = 0; i < len; i++) {
+ ap.getEntry(i, tvp);
+ print(tvp.getByteArray(), tvp.getStartOffset(), tvp.getLength(), ps);
+ if (i != len - 1) {
+ ps.append(',');
+ }
+ ps.append(' ');
+ }
+ ps.append(']');
+ } finally {
+ pp.giveBack(ap);
+ pp.giveBack(tvp);
+ }
+ }
+
private void printBase64Binary(PrintStream ps, TaggedValuePointable tvp) {
XSBinaryPointable bp = pp.takeOne(XSBinaryPointable.class);
try {
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ASTTag.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ASTTag.java
index 65acb21..cd3f223 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ASTTag.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ASTTag.java
@@ -17,6 +17,96 @@
package org.apache.vxquery.xmlquery.ast;
public enum ASTTag {
- VERSION_DECL, PROLOG, LIBRARY_MODULE, MODULE_DECLARATION, MAIN_MODULE, QUERY_BODY, BOUNDARY_SPACE_DECLARATION, DEFAULT_ELEMENT_NAMESPACE_DECLARATION, DEFAULT_FUNCTION_NAMESPACE_DECLARATION, OPTION_DECLARATION, FT_OPTION_DECLARATION, ORDERING_MODE_DECLARATION, EMPTY_ORDER_DECLARATION, COPY_NAMESPACES_DECLARATION, DEFAULT_COLLATION_DECLARATION, BASE_URI_DECLARATION, SCHEMA_IMPORT, MODULE_IMPORT, VARIABLE_DECLARATION, TYPE_DECLARATION, SEQUENCE_TYPE, ITEM_TYPE, ATOMIC_TYPE, ANY_NODE_TEST, ITEM_TEST, DOCUMENT_TEST, QNAME, ELEMENT_TEST, SCHEMA_ELEMENT_TEST, ATTRIBUTE_TEST, SCHEMA_ATTRIBUTE_TEST, TEXT_TEST, COMMENT_TEST, PI_TEST, TYPE_NAME, CONSTRUCTION_DECLARATION, FUNCTION_DECLARATION, FUNCTION_PARAMETER, ENCLOSED_EXPRESSION, EXPRESSION, FLWOR_EXPRESSION, FOR_CLAUSE, FOR_VARIABLE_DECLARATION, LET_VARIABLE_DECLARATION, LET_CLAUSE, WHERE_CLAUSE, ORDERBY_CLAUSE, ORDER_SPECIFICATION, QUANTIFIED_EXPRESSION, QUANTIFIED_VARIABLE_DECLARATION, TYPESWITCH_EXPRESSION, CASE_CLAUSE, IF_EXPRESSION, INFIX_EXPRESSION, TYPE_EXPRESSION, UNARY_EXPRESSION, VALIDATE_EXPRESSION, EXTENSION_EXPRESSION, PRAGMA_NODE, PATH_EXPRESSION, AXIS_STEP, NAME_TEST, FILTER_EXPRESSION, LITERAL, VARIABLE_REFERENCE, PARENTHESIZED_EXPRESSION, CONTEXT_ITEM, ORDERED_EXPRESSION, UNORDERED_EXPRESSION, FUNCTION_EXPRESSION, DIRECT_ELEMENT_CONSTRUCTOR, DIRECT_ATTRIBUTE_CONSTRUCTOR, DQUOTED_ATTRIBUTE_CONTENT, SQUOTED_ATTRIBUTE_CONTENT, TEXTUAL_NODE_CONTENT, CDATA_SECTION, DIRECT_COMMENT_CONSTRUCTOR, DIRECT_PI_CONSTRUCTOR, COMPUTED_DOCUMENT_CONSTRUCTOR, COMPUTED_ATTRIBUTE_CONSTRUCTOR, COMPUTED_ELEMENT_CONSTRUCTOR, COMPUTED_TEXT_CONSTRUCTOR, COMPUTED_COMMENT_CONSTRUCTOR, EMPTY_SEQUENCE_TYPE, RELATIVE_PATH_EXPRESSION, COMPUTED_PI_CONSTRUCTOR, NCNAME, CONTENT_CHARS, NAMESPACE_DECLARATION, SINGLE_TYPE
+ VERSION_DECL,
+ PROLOG,
+ LIBRARY_MODULE,
+ MODULE_DECLARATION,
+ MAIN_MODULE,
+ QUERY_BODY,
+ BOUNDARY_SPACE_DECLARATION,
+ DEFAULT_ELEMENT_NAMESPACE_DECLARATION,
+ DEFAULT_FUNCTION_NAMESPACE_DECLARATION,
+ OPTION_DECLARATION,
+ FT_OPTION_DECLARATION,
+ ORDERING_MODE_DECLARATION,
+ EMPTY_ORDER_DECLARATION,
+ COPY_NAMESPACES_DECLARATION,
+ DEFAULT_COLLATION_DECLARATION,
+ BASE_URI_DECLARATION,
+ SCHEMA_IMPORT,
+ MODULE_IMPORT,
+ VARIABLE_DECLARATION,
+ TYPE_DECLARATION,
+ SEQUENCE_TYPE,
+ ITEM_TYPE,
+ ATOMIC_TYPE,
+ ANY_NODE_TEST,
+ ITEM_TEST,
+ DOCUMENT_TEST,
+ QNAME,
+ ELEMENT_TEST,
+ SCHEMA_ELEMENT_TEST,
+ ATTRIBUTE_TEST,
+ SCHEMA_ATTRIBUTE_TEST,
+ TEXT_TEST,
+ COMMENT_TEST,
+ PI_TEST,
+ TYPE_NAME,
+ CONSTRUCTION_DECLARATION,
+ FUNCTION_DECLARATION,
+ FUNCTION_PARAMETER,
+ ENCLOSED_EXPRESSION,
+ EXPRESSION,
+ FLWOR_EXPRESSION,
+ FOR_CLAUSE,
+ FOR_VARIABLE_DECLARATION,
+ LET_VARIABLE_DECLARATION,
+ LET_CLAUSE,
+ WHERE_CLAUSE,
+ ORDERBY_CLAUSE,
+ ORDER_SPECIFICATION,
+ QUANTIFIED_EXPRESSION,
+ QUANTIFIED_VARIABLE_DECLARATION,
+ TYPESWITCH_EXPRESSION,
+ CASE_CLAUSE,
+ IF_EXPRESSION,
+ INFIX_EXPRESSION,
+ TYPE_EXPRESSION,
+ UNARY_EXPRESSION,
+ VALIDATE_EXPRESSION,
+ EXTENSION_EXPRESSION,
+ PRAGMA_NODE,
+ PATH_EXPRESSION,
+ AXIS_STEP,
+ NAME_TEST,
+ FILTER_EXPRESSION,
+ LITERAL,
+ VARIABLE_REFERENCE,
+ PARENTHESIZED_EXPRESSION,
+ CONTEXT_ITEM,
+ ORDERED_EXPRESSION,
+ UNORDERED_EXPRESSION,
+ FUNCTION_EXPRESSION,
+ ARRAY_CONSTRUCTOR,
+ DIRECT_ELEMENT_CONSTRUCTOR,
+ DIRECT_ATTRIBUTE_CONSTRUCTOR,
+ DQUOTED_ATTRIBUTE_CONTENT,
+ SQUOTED_ATTRIBUTE_CONTENT,
+ TEXTUAL_NODE_CONTENT,
+ CDATA_SECTION,
+ DIRECT_COMMENT_CONSTRUCTOR,
+ DIRECT_PI_CONSTRUCTOR,
+ COMPUTED_DOCUMENT_CONSTRUCTOR,
+ COMPUTED_ATTRIBUTE_CONSTRUCTOR,
+ COMPUTED_ELEMENT_CONSTRUCTOR,
+ COMPUTED_TEXT_CONSTRUCTOR,
+ COMPUTED_COMMENT_CONSTRUCTOR,
+ EMPTY_SEQUENCE_TYPE,
+ RELATIVE_PATH_EXPRESSION,
+ COMPUTED_PI_CONSTRUCTOR,
+ NCNAME,
+ CONTENT_CHARS,
+ NAMESPACE_DECLARATION,
+ SINGLE_TYPE
}
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ArrayConstructor.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ArrayConstructor.java
new file mode 100644
index 0000000..65ec6b6
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ArrayConstructor.java
@@ -0,0 +1,40 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.vxquery.xmlquery.ast;
+
+import org.apache.vxquery.util.SourceLocation;
+
+public class ArrayConstructor extends ASTNode {
+ private ASTNode expression;
+
+ public ArrayConstructor(SourceLocation loc) {
+ super(loc);
+ }
+
+ @Override
+ public ASTTag getTag() {
+ return ASTTag.ARRAY_CONSTRUCTOR;
+ }
+
+ public ASTNode getExpression() {
+ return expression;
+ }
+
+ public void setExpression(ASTNode expression) {
+ this.expression = expression;
+ }
+}
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
index 19ba276..047ffc8 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
@@ -98,6 +98,7 @@
import org.apache.vxquery.types.TypeUtils;
import org.apache.vxquery.xmlquery.ast.ASTNode;
import org.apache.vxquery.xmlquery.ast.ASTTag;
+import org.apache.vxquery.xmlquery.ast.ArrayConstructor;
import org.apache.vxquery.xmlquery.ast.AtomicTypeNode;
import org.apache.vxquery.xmlquery.ast.AttributeTestNode;
import org.apache.vxquery.xmlquery.ast.AxisStepNode;
@@ -818,6 +819,11 @@
return translateComputedElementConstructorNode(tCtx, cNode);
}
+ case ARRAY_CONSTRUCTOR: {
+ ArrayConstructor aNode = (ArrayConstructor) value;
+ return translateArrayConstructor(tCtx, aNode);
+ }
+
case COMPUTED_ATTRIBUTE_CONSTRUCTOR: {
ComputedAttributeConstructorNode cNode = (ComputedAttributeConstructorNode) value;
return translateComputedAttributeConstructorNode(tCtx, cNode);
@@ -971,6 +977,15 @@
return lVar;
}
+ private LogicalVariable translateArrayConstructor(TranslationContext tCtx, ArrayConstructor aNode)
+ throws SystemException {
+ ASTNode expression = aNode.getExpression();
+ ILogicalExpression aExpr = expression == null ? sfce(BuiltinOperators.CONCATENATE)
+ : vre(translateExpression(expression, tCtx));
+ LogicalVariable lVar = createAssignment(sfce(BuiltinOperators.ARRAY_CONSTRUCTOR, aExpr), tCtx);
+ return lVar;
+ }
+
private LogicalVariable translateComputedDocumentConstructorNode(TranslationContext tCtx,
ComputedDocumentConstructorNode cNode) throws SystemException {
LogicalVariable lVar = createAssignment(
diff --git a/vxquery-core/src/main/javacc/xquery-grammar.jj b/vxquery-core/src/main/javacc/xquery-grammar.jj
index 7c0491a..6dc9865 100644
--- a/vxquery-core/src/main/javacc/xquery-grammar.jj
+++ b/vxquery-core/src/main/javacc/xquery-grammar.jj
@@ -97,7 +97,7 @@
PARSER_END(XMLQuery)
-
+
TOKEN_MGR_DECLS : {
public Stack<Integer> stateStack = new Stack<Integer>();
@@ -105,7 +105,7 @@
public int offset = 0;
- void CommonTokenAction(Token t) {}
+ void CommonTokenAction(Token t) {}
/**
@@ -148,13 +148,13 @@
*/
private boolean isState(int state)
{
- for (int i = 0; i < stateStack.size(); i++) {
+ for (int i = 0; i < stateStack.size(); i++) {
if(stateStack.elementAt(i) == state)
{
- return true;
+ return true;
}
- }
- return false;
+ }
+ return false;
}
/**
@@ -1945,6 +1945,7 @@
(
result = DirectConstructor()
| result = ComputedConstructor()
+ | result = JsonConstructor()
) {
return result;
}
@@ -2442,6 +2443,30 @@
}
}
+ASTNode JsonConstructor() :
+{
+ ASTNode result;
+}
+{
+ result = ArrayConstructor()
+ {
+ return result;
+ }
+}
+
+ASTNode ArrayConstructor() :
+{
+ ASTNode expr=null;
+ Token start;
+}
+{
+ (start = "[") [expr = Expr()] "]" {
+ ArrayConstructor an = new ArrayConstructor(createSourceLocation(start));
+ an.setExpression(expr);
+ return an;
+ }
+}
+
SingleTypeNode SingleType() :
{
AtomicTypeNode type;
@@ -2800,7 +2825,7 @@
void FTOrExpr() :
{}
{
- FTOr()
+ FTOr()
}
void FTOr() :
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q01_array.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q01_array.txt
new file mode 100644
index 0000000..404b10d
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q01_array.txt
@@ -0,0 +1 @@
+[ 1 ]
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q02_array.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q02_array.txt
new file mode 100644
index 0000000..6038e9b
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q02_array.txt
@@ -0,0 +1 @@
+[ 1, string, 3.1 ]
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q03_array.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q03_array.txt
new file mode 100644
index 0000000..6330c79
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q03_array.txt
@@ -0,0 +1 @@
+[ [ 1, 2 ], [ 2, 3 ] ]
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q04_array.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q04_array.txt
new file mode 100644
index 0000000..8878e54
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q04_array.txt
@@ -0,0 +1 @@
+[ ]
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/q01_object.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/q01_object.txt
new file mode 100644
index 0000000..56a6051
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/q01_object.txt
@@ -0,0 +1 @@
+1
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q01_array.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q01_array.xq
new file mode 100644
index 0000000..ecb653d
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q01_array.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License. :)
+
+(: Json Array Query :)
+(: Just parse an array with a single item :)
+ [1]
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q02_array.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q02_array.xq
new file mode 100644
index 0000000..4954f21
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q02_array.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License. :)
+
+(: Json Array Query :)
+(: Just parse an array with a sequence of items :)
+ [1,"string",3.1]
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q03_array.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q03_array.xq
new file mode 100644
index 0000000..f9913be
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q03_array.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License. :)
+
+(: Json Array Query :)
+(: Just parse an array with nested arrays :)
+ [[1,2],[2,3]]
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q04_array.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q04_array.xq
new file mode 100644
index 0000000..de1447e
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q04_array.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License. :)
+
+(: Json Array Query :)
+(: Just parse an empty array :)
+ []
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/q01_object.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/q01_object.xq
new file mode 100644
index 0000000..52c9044
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/q01_object.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License. :)
+
+(: Json Object Query :)
+(: Just an object example :)
+ 1
diff --git a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
index 414601e..5e6eb62 100644
--- a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
+++ b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
@@ -44,6 +44,9 @@
<!ENTITY IndexingQueries SYSTEM "cat/IndexingQueries.xml">
+<!ENTITY JsonArrayQueries SYSTEM "cat/JsonArrayQueries.xml">
+<!ENTITY JsonObjectQueries SYSTEM "cat/JsonObjectQueries.xml">
+
]>
<test-suite xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -207,7 +210,7 @@
<title>Aggregate HDFS Execution Tests</title>
<description/>
</GroupInfo>
- &HDFSAggregateQueries;
+ &HDFSAggregateQueries;
</test-group>
</test-group>
<test-group name="IndexingQueries" featureOwner="Steven Jacobs">
@@ -220,7 +223,21 @@
<title>Indexing Execution Tests</title>
<description/>
</GroupInfo>
- &IndexingQueries;
+ &IndexingQueries;
+ </test-group>
+ </test-group>
+ <test-group name="JsoniqQueries" featureOwner="Christina Pavlopoulou">
+ <GroupInfo>
+ <title>Jsoniq Queries</title>
+ <description/>
+ </GroupInfo>
+ <test-group name="JsoniqTesting" featureOwner="Christina Pavlopoulou">
+ <GroupInfo>
+ <title>Json Constructor Tests</title>
+ <description/>
+ </GroupInfo>
+ &JsonArrayQueries;
+ &JsonObjectQueries;
</test-group>
</test-group>
</test-suite>
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/cat/JsonArrayQueries.xml b/vxquery-xtest/src/test/resources/cat/JsonArrayQueries.xml
new file mode 100644
index 0000000..cfa18af
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/cat/JsonArrayQueries.xml
@@ -0,0 +1,43 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog" name="JsonArrayQueries" featureOwner="VXQuery">
+ <GroupInfo>
+ <title>Json Array</title>
+ <description/>
+ </GroupInfo>
+ <test-case name="json-array-q01" FilePath="Json/Array/" Creator="Christina Pavlopoulou">
+ <description>Array with a single item.</description>
+ <query name="q01_array" date="2016-06-09"/>
+ <output-file compare="Text">q01_array.txt</output-file>
+ </test-case>
+ <test-case name="json-array-q02" FilePath="Json/Array/" Creator="Christina Pavlopoulou">
+ <description>Array with a sequence of items.</description>
+ <query name="q02_array" date="2016-06-09"/>
+ <output-file compare="Text">q02_array.txt</output-file>
+ </test-case>
+ <test-case name="json-array-q03" FilePath="Json/Array/" Creator="Christina Pavlopoulou">
+ <description>Array with a sequence of items.</description>
+ <query name="q03_array" date="2016-06-09"/>
+ <output-file compare="Text">q03_array.txt</output-file>
+ </test-case>
+ <test-case name="json-array-q04" FilePath="Json/Array/" Creator="Christina Pavlopoulou">
+ <description>Empty array.</description>
+ <query name="q04_array" date="2016-06-09"/>
+ <output-file compare="Text">q04_array.txt</output-file>
+ </test-case>
+</test-group>
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/cat/JsonObjectQueries.xml b/vxquery-xtest/src/test/resources/cat/JsonObjectQueries.xml
new file mode 100644
index 0000000..dcdf6e6
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/cat/JsonObjectQueries.xml
@@ -0,0 +1,28 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog" name="JsonObjectQueries" featureOwner="VXQuery">
+ <GroupInfo>
+ <title>Json Object</title>
+ <description/>
+ </GroupInfo>
+ <test-case name="json-object-q01" FilePath="Json/Object/" Creator="Christina Pavlopoulou">
+ <description>Object.</description>
+ <query name="q01_object" date="2016-06-09"/>
+ <output-file compare="Text">q01_object.txt</output-file>
+ </test-case>
+</test-group>
\ No newline at end of file