zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #18728
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/ns-nodes into lp:zorba.
Commit message:
Implemented computed namespace constructors
Requested reviews:
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/ns-nodes/+merge/151929
Implemented computed namespace constructors
--
https://code.launchpad.net/~zorba-coders/zorba/ns-nodes/+merge/151929
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/identtypes.h'
--- include/zorba/identtypes.h 2013-02-07 17:24:36 +0000
+++ include/zorba/identtypes.h 2013-03-06 11:14:46 +0000
@@ -34,6 +34,7 @@
PI_TYPE,
TEXT_TYPE,
COMMENT_TYPE,
+ NAMESPACE_TYPE,
ANY_NODE_TYPE, // node()
STRUCTURED_ITEM_TYPE, // structured-item
#ifdef ZORBA_WITH_JSON
=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h 2013-03-05 23:11:50 +0000
+++ include/zorba/pregenerated/diagnostic_list.h 2013-03-06 11:14:46 +0000
@@ -186,6 +186,10 @@
extern ZORBA_DLL_PUBLIC XQueryErrorCode XQDY0096;
+extern ZORBA_DLL_PUBLIC XQueryErrorCode XQDY0101;
+
+extern ZORBA_DLL_PUBLIC XQueryErrorCode XQDY0102;
+
extern ZORBA_DLL_PUBLIC XQueryErrorCode XTDE1310;
extern ZORBA_DLL_PUBLIC XQueryErrorCode XTDE1340;
=== modified file 'include/zorba/store_consts.h'
--- include/zorba/store_consts.h 2013-02-07 17:24:36 +0000
+++ include/zorba/store_consts.h 2013-03-06 11:14:46 +0000
@@ -112,7 +112,8 @@
attributeNode = 3,
textNode = 4,
piNode = 5,
- commentNode = 6
+ commentNode = 6,
+ namespaceNode = 7
};
static std::string toString(NodeKind k)
@@ -140,6 +141,9 @@
case commentNode:
return "commentNode";
+ case namespaceNode:
+ return "namespaceNode";
+
default:
return "<unknown NodeKind>";
}
@@ -170,6 +174,9 @@
case commentNode:
return "comment";
+ case namespaceNode:
+ return "namespace-node";
+
default:
return "<unknown NodeKind>";
}
=== modified file 'include/zorba/typeident.h'
--- include/zorba/typeident.h 2013-02-07 17:24:36 +0000
+++ include/zorba/typeident.h 2013-03-06 11:14:46 +0000
@@ -72,6 +72,9 @@
createPIType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
static TypeIdentifier_t
+ createNamespaceType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
+
+ static TypeIdentifier_t
createTextType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
static TypeIdentifier_t
=== modified file 'modules/w3c/pregenerated/xqt-errors.xq'
--- modules/w3c/pregenerated/xqt-errors.xq 2013-03-06 00:18:36 +0000
+++ modules/w3c/pregenerated/xqt-errors.xq 2013-03-06 11:14:46 +0000
@@ -831,6 +831,22 @@
(:~
:
+ : Invalid prefix and/or uri in computed namespace constructor
+ :
+ : @see http://www.w3.org/2005/xqt-errors
+:)
+declare variable $err:XQDY0101 as xs:QName := fn:QName($err:NS, "err:XQDY0101");
+
+(:~
+ :
+ : In an element constructor, if two or more namespace bindings in the in-scope bindings would have the same prefix, then an error is raised if they have different URIs; if they would have the same prefix and URI, duplicate bindings are ignored.
+ :
+ : @see http://www.w3.org/2005/xqt-errors
+:)
+declare variable $err:XQDY0102 as xs:QName := fn:QName($err:NS, "err:XQDY0102");
+
+(:~
+ :
: It is a non-recoverable dynamic error if the picture string does not
: satisfy the format-number function rules.
:
=== modified file 'src/api/identtypesimpl.cpp'
--- src/api/identtypesimpl.cpp 2013-02-07 17:24:36 +0000
+++ src/api/identtypesimpl.cpp 2013-03-06 11:14:46 +0000
@@ -19,7 +19,8 @@
namespace zorba {
-char const *const IdentTypes::kind_string_of[] = {
+char const *const IdentTypes::kind_string_of[] =
+{
"NAMED",
"element",
"attribute",
@@ -27,6 +28,7 @@
"processing-instruction",
"text",
"comment",
+ "namespace-node",
"node",
"item",
"empty-sequence",
@@ -36,7 +38,9 @@
0
};
-char const *const IdentTypes::quantifier_string_of[] = {
+
+char const *const IdentTypes::quantifier_string_of[] =
+{
"",
"?",
"+",
@@ -48,11 +52,13 @@
namespace std {
-ostream& operator<<(ostream& o, const zorba::IdentTypes::kind_t ik) {
+ostream& operator<<(ostream& o, const zorba::IdentTypes::kind_t ik)
+{
return o << zorba::IdentTypes::kind_string_of[ik];
}
-ostream& operator<<(ostream& o, const zorba::IdentTypes::quantifier_t iq) {
+ostream& operator<<(ostream& o, const zorba::IdentTypes::quantifier_t iq)
+{
return o << zorba::IdentTypes::quantifier_string_of[iq];
}
=== modified file 'src/api/typeidentimpl.cpp'
--- src/api/typeidentimpl.cpp 2013-02-07 17:24:36 +0000
+++ src/api/typeidentimpl.cpp 2013-03-06 11:14:46 +0000
@@ -190,6 +190,16 @@
}
+TypeIdentifier_t TypeIdentifier::createNamespaceType(IdentTypes::quantifier_t quantifier)
+{
+ TypeIdentifier_t ti(new TypeIdentifier());
+ ti->m_kind = IdentTypes::NAMESPACE_TYPE;
+ ti->m_quantifier = quantifier;
+
+ return ti;
+}
+
+
TypeIdentifier_t TypeIdentifier::createAnyNodeType(IdentTypes::quantifier_t quantifier)
{
TypeIdentifier_t ti(new TypeIdentifier());
=== modified file 'src/compiler/CMakeLists.txt'
--- src/compiler/CMakeLists.txt 2013-02-07 17:24:36 +0000
+++ src/compiler/CMakeLists.txt 2013-03-06 11:14:46 +0000
@@ -22,7 +22,6 @@
ADD_SRC_SUBFOLDER(COMPILER_SRCS parsetree PARSETREE_SRCS)
ADD_SRC_SUBFOLDER(COMPILER_SRCS translator TRANSLATOR_SRCS)
-#ADD_SRC_SUBFOLDER(COMPILER_SRCS normalizer NORMALIZER_SRCS)
ADD_SRC_SUBFOLDER(COMPILER_SRCS codegen CODEGEN_SRCS)
ADD_SRC_SUBFOLDER(COMPILER_SRCS expression EXPRESSION_SRCS)
ADD_SRC_SUBFOLDER(COMPILER_SRCS rewriter REWRITER_SRCS)
=== modified file 'src/compiler/codegen/plan_visitor.cpp'
--- src/compiler/codegen/plan_visitor.cpp 2013-02-26 04:12:43 +0000
+++ src/compiler/codegen/plan_visitor.cpp 2013-03-06 11:14:46 +0000
@@ -3075,6 +3075,23 @@
}
+bool begin_visit(namespace_expr& v)
+{
+ CODEGEN_TRACE_IN("");
+ return true;
+}
+
+
+void end_visit(namespace_expr& v)
+{
+ CODEGEN_TRACE_OUT("");
+
+ PlanIter_t uri = pop_itstack();
+ PlanIter_t prefix = pop_itstack();
+ push_itstack(new NamespaceIterator(sctx, qloc, prefix, uri));
+}
+
+
bool begin_visit(text_expr& v)
{
CODEGEN_TRACE_IN ("");
@@ -3146,8 +3163,8 @@
isRoot = true;
}
- PlanIter_t content = pop_itstack ();
- PlanIter_t target = pop_itstack ();
+ PlanIter_t content = pop_itstack();
+ PlanIter_t target = pop_itstack();
push_itstack(new PiIterator(sctx, qloc, target, content, isRoot));
}
=== modified file 'src/compiler/expression/expr.cpp'
--- src/compiler/expression/expr.cpp 2013-02-07 17:24:36 +0000
+++ src/compiler/expression/expr.cpp 2013-03-06 11:14:46 +0000
@@ -652,6 +652,66 @@
/***************************************************************************//**
********************************************************************************/
+namespace_expr::namespace_expr(
+ CompilerCB* ccb,
+ static_context* sctx,
+ user_function* udf,
+ const QueryLoc& loc,
+ expr* preExpr,
+ expr* uriExpr)
+ :
+ expr(ccb, sctx, udf, loc, attr_expr_kind),
+ thePrefixExpr(preExpr),
+ theUriExpr(uriExpr)
+{
+ compute_scripting_kind();
+
+ setUnfoldable(ANNOTATION_TRUE_FIXED);
+ setConstructsNodes(ANNOTATION_TRUE_FIXED);
+}
+
+
+const store::Item* namespace_expr::getPrefix() const
+{
+ if (thePrefixExpr->get_expr_kind() == const_expr_kind)
+ {
+ return static_cast<const_expr*>(thePrefixExpr)->get_val();
+ }
+
+ return NULL;
+}
+
+
+void namespace_expr::compute_scripting_kind()
+{
+ checkNonUpdating(thePrefixExpr);
+ checkNonUpdating(theUriExpr);
+
+ short nameExprKind = thePrefixExpr->get_scripting_detail();
+ short valueExprKind = theUriExpr->get_scripting_detail();
+
+ theScriptingKind |= (nameExprKind | valueExprKind);
+
+ if (is_vacuous())
+ {
+ theScriptingKind = SIMPLE_EXPR;
+ }
+ else
+ {
+ theScriptingKind &= ~VACUOUS_EXPR;
+
+ if (is_sequential())
+ theScriptingKind &= ~SIMPLE_EXPR;
+ }
+}
+
+
+DEF_EXPR_ACCEPT(namespace_expr)
+
+
+/***************************************************************************//**
+
+********************************************************************************/
text_expr::text_expr(
CompilerCB* ccb,
static_context* sctx,
=== modified file 'src/compiler/expression/expr.h'
--- src/compiler/expression/expr.h 2013-02-26 04:12:43 +0000
+++ src/compiler/expression/expr.h 2013-03-06 11:14:46 +0000
@@ -712,7 +712,44 @@
};
-/***************************************************************************//**
+/*******************************************************************************
+
+********************************************************************************/
+class namespace_expr : public expr
+{
+ friend class ExprManager;
+ friend class ExprIterator;
+ friend class expr;
+
+protected:
+ expr * thePrefixExpr;
+ expr * theUriExpr;
+
+protected:
+ namespace_expr(
+ CompilerCB* ccb,
+ static_context* sctx,
+ user_function* udf,
+ const QueryLoc& loc,
+ expr* preExpr,
+ expr* uriExpr);
+
+public:
+ expr* getPrefixExpr() const { return thePrefixExpr; }
+
+ expr* getUriExpr() const { return theUriExpr; }
+
+ const store::Item* getPrefix() const;
+
+ void compute_scripting_kind();
+
+ void accept(expr_visitor&);
+
+ std::ostream& put(std::ostream&) const;
+};
+
+
+/*******************************************************************************
********************************************************************************/
class text_expr : public expr
=== modified file 'src/compiler/expression/expr_base.cpp'
--- src/compiler/expression/expr_base.cpp 2013-02-21 16:34:45 +0000
+++ src/compiler/expression/expr_base.cpp 2013-03-06 11:14:46 +0000
@@ -1081,6 +1081,7 @@
case doc_expr_kind:
case elem_expr_kind:
case attr_expr_kind:
+ case namespace_expr_kind:
case text_expr_kind:
case pi_expr_kind:
#ifdef ZORBA_WITH_JSON
=== modified file 'src/compiler/expression/expr_base.h'
--- src/compiler/expression/expr_base.h 2013-02-13 12:53:50 +0000
+++ src/compiler/expression/expr_base.h 2013-03-06 11:14:46 +0000
@@ -56,6 +56,7 @@
doc_expr_kind,
elem_expr_kind,
attr_expr_kind,
+ namespace_expr_kind,
text_expr_kind,
pi_expr_kind,
=== modified file 'src/compiler/expression/expr_classes.h'
--- src/compiler/expression/expr_classes.h 2013-02-07 17:24:36 +0000
+++ src/compiler/expression/expr_classes.h 2013-03-06 11:14:46 +0000
@@ -46,6 +46,7 @@
class attr_expr;
class text_expr;
class pi_expr;
+ class namespace_expr;
class trycatch_expr;
class function_item_expr;
=== modified file 'src/compiler/expression/expr_clone.cpp'
--- src/compiler/expression/expr_clone.cpp 2013-02-21 16:34:45 +0000
+++ src/compiler/expression/expr_clone.cpp 2013-03-06 11:14:46 +0000
@@ -116,6 +116,18 @@
CLONE(e->getValueExpr(), udf, subst));
break;
}
+ case namespace_expr_kind:
+ {
+ const namespace_expr* e = static_cast<const namespace_expr*>(this);
+
+ newExpr = theCCB->theEM->
+ create_namespace_expr(theSctx,
+ udf,
+ theLoc,
+ CLONE(e->getPrefixExpr(), udf, subst),
+ CLONE(e->getUriExpr(), udf, subst));
+ break;
+ }
case text_expr_kind:
{
const text_expr* e = static_cast<const text_expr*>(this);
=== modified file 'src/compiler/expression/expr_iter.cpp'
--- src/compiler/expression/expr_iter.cpp 2013-02-21 16:34:45 +0000
+++ src/compiler/expression/expr_iter.cpp 2013-03-06 11:14:46 +0000
@@ -566,6 +566,19 @@
return;
}
+ case namespace_expr_kind:
+ {
+ namespace_expr* nsExpr = static_cast<namespace_expr*>(theExpr);
+
+ EXPR_ITER_BEGIN();
+
+ EXPR_ITER_NEXT(nsExpr->thePrefixExpr);
+ EXPR_ITER_NEXT(nsExpr->theUriExpr);
+
+ EXPR_ITER_END();
+ return;
+ }
+
case text_expr_kind:
{
text_expr* textExpr = static_cast<text_expr*>(theExpr);
=== modified file 'src/compiler/expression/expr_manager.cpp'
--- src/compiler/expression/expr_manager.cpp 2013-02-07 17:24:36 +0000
+++ src/compiler/expression/expr_manager.cpp 2013-03-06 11:14:46 +0000
@@ -327,6 +327,17 @@
}
+namespace_expr* ExprManager::create_namespace_expr(
+ static_context* sctx,
+ user_function* udf,
+ const QueryLoc& loc,
+ expr* prefixExpr,
+ expr* uriExpr)
+{
+ CREATE_AND_RETURN_EXPR(namespace_expr, sctx, udf, loc, prefixExpr, uriExpr);
+}
+
+
text_expr* ExprManager::create_text_expr(
static_context* sctx,
user_function* udf,
=== modified file 'src/compiler/expression/expr_manager.h'
--- src/compiler/expression/expr_manager.h 2013-02-07 17:24:36 +0000
+++ src/compiler/expression/expr_manager.h 2013-03-06 11:14:46 +0000
@@ -204,6 +204,13 @@
expr* aQNameExpr,
expr* aValueExpr);
+ namespace_expr* create_namespace_expr(
+ static_context* sctx,
+ user_function* udf,
+ const QueryLoc& loc,
+ expr* prefixExpr,
+ expr* uriExpr);
+
text_expr* create_text_expr(
static_context* sctx,
user_function* udf,
=== modified file 'src/compiler/expression/expr_put.cpp'
--- src/compiler/expression/expr_put.cpp 2013-02-21 16:34:45 +0000
+++ src/compiler/expression/expr_put.cpp 2013-03-06 11:14:46 +0000
@@ -811,7 +811,18 @@
BEGIN_PUT(attr_expr);
theQNameExpr->put(os);
- PUT_SUB("=", theValueExpr);
+ theValueExpr->put(os);
+
+ END_PUT();
+}
+
+
+ostream& namespace_expr::put(ostream& os) const
+{
+ BEGIN_PUT(attr_expr);
+
+ thePrefixExpr->put(os);
+ theUriExpr->put(os);
END_PUT();
}
=== modified file 'src/compiler/expression/expr_type.cpp'
--- src/compiler/expression/expr_type.cpp 2013-02-26 04:12:43 +0000
+++ src/compiler/expression/expr_type.cpp 2013-03-06 11:14:46 +0000
@@ -525,12 +525,13 @@
case attr_expr_kind:
{
- newType = tm->create_node_type(store::StoreConsts::attributeNode,
- NULL,
- rtm.UNTYPED_ATOMIC_TYPE_ONE,
- TypeConstants::QUANT_ONE,
- false,
- false);
+ newType = rtm.ATTRIBUTE_UNTYPED_TYPE_ONE;
+ break;
+ }
+
+ case namespace_expr_kind:
+ {
+ newType = rtm.NAMESPACE_TYPE_ONE;
break;
}
=== modified file 'src/compiler/expression/expr_visitor.h'
--- src/compiler/expression/expr_visitor.h 2013-02-07 17:24:36 +0000
+++ src/compiler/expression/expr_visitor.h 2013-03-06 11:14:46 +0000
@@ -66,6 +66,7 @@
DECL_EXPR_VISITOR_VISIT_MEM_FNS( elem_expr );
DECL_EXPR_VISITOR_VISIT_MEM_FNS( doc_expr );
DECL_EXPR_VISITOR_VISIT_MEM_FNS( attr_expr );
+ DECL_EXPR_VISITOR_VISIT_MEM_FNS( namespace_expr );
DECL_EXPR_VISITOR_VISIT_MEM_FNS( text_expr );
DECL_EXPR_VISITOR_VISIT_MEM_FNS( pi_expr );
=== removed directory 'src/compiler/normalizer'
=== removed file 'src/compiler/normalizer/CMakeLists.txt'
--- src/compiler/normalizer/CMakeLists.txt 2013-02-07 17:24:36 +0000
+++ src/compiler/normalizer/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
-# Copyright 2006-2008 The FLWOR Foundation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-SET(NORMALIZER_SRCS
- normalizer.cpp)
=== removed file 'src/compiler/normalizer/normalizer.cpp'
--- src/compiler/normalizer/normalizer.cpp 2013-02-07 17:24:36 +0000
+++ src/compiler/normalizer/normalizer.cpp 1970-01-01 00:00:00 +0000
@@ -1,353 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <typeinfo>
-#include <iostream>
-
-#include "types/root_typemanager.h"
-#include "types/typeops.h"
-#include "system/globalenv.h"
-
-#include "context/static_context.h"
-
-#include "compiler/api/compilercb.h"
-#include "compiler/normalizer/normalizer.h"
-#include "compiler/expression/expr.h"
-#include "compiler/expression/fo_expr.h"
-#include "compiler/expression/var_expr.h"
-#include "compiler/expression/flwor_expr.h"
-#include "compiler/expression/path_expr.h"
-#include "compiler/expression/expr_visitor.h"
-
-#include "functions/signature.h"
-#include "functions/function.h"
-#include "functions/library.h"
-
-
-namespace zorba
-{
-
-
-static inline expr::expr_t wrap_in_atomization(
- short context,
- expr::expr_t e)
-{
- fo_expr_t fo = new fo_expr(context, e->get_loc(), GET_BUILTIN_FUNCTION(FN_DATA_1), e);
- return fo.getp();
-}
-
-
-static inline expr::expr_t wrap_in_type_conversion(
- short context,
- expr::expr_t e,
- xqtref_t type)
-{
- expr::expr_t ph = new promote_expr(context, e->get_loc(), e, type);
- // TODO : Need to add convert_simple_operand
- return ph;
-}
-
-
-static inline expr::expr_t wrap_in_typematch(
- short context,
- expr::expr_t e,
- xqtref_t type)
-{
- // treat_expr should be avoided for updating expressions too,
- // but in that case "type" will be item()* anyway
- return TypeOps::is_subtype(*GENV_TYPESYSTEM.ITEM_TYPE_STAR, *type)
- ? e
- : new treat_expr(context, e->get_loc(), e, type, XPTY0004);
-}
-
-
-#if 0
-
-static inline void checkNonUpdating(const expr* lExpr)
-{
- if (lExpr != 0 && lExpr->is_updating())
- throw XQUERY_EXCEPTION(err::XUST0001, ERROR_LOC(lExpr->get_loc()));
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-class normalizer : public expr_visitor
-{
- CompilerCB * m_cb;
-
-public:
- normalizer(CompilerCB* aCompilerCB) : m_cb(aCompilerCB) {}
-
- ~normalizer() { }
-
-#define DEF_VISIT_METHODS( e ) \
- bool begin_visit(e& node) { return true; } \
- void end_visit(e& node) {}
-
-DEF_VISIT_METHODS (expr)
-
-DEF_VISIT_METHODS (debugger_expr)
-
-DEF_VISIT_METHODS (wrapper_expr)
-
-DEF_VISIT_METHODS (sequential_expr)
-
-DEF_VISIT_METHODS (var_expr)
-
-DEF_VISIT_METHODS (order_modifier)
-
-DEF_VISIT_METHODS (eval_expr)
-
-
-
-bool begin_visit(flwor_expr& node)
-{
- return true;
-}
-
-
-void end_visit(flwor_expr& node)
-{
-}
-
-
-void end_visit (promote_expr&)
-{
-}
-
-bool begin_visit (promote_expr& node)
-{
- checkNonUpdating(&*node.get_input());
- return true;
-}
-
-
-void end_visit (trycatch_expr&)
-{
-}
-
-bool begin_visit (trycatch_expr& node)
-{
- checkNonUpdating(&*node.get_try_expr());
- return true;
-}
-
-
-void end_visit (if_expr&)
-{
-}
-
-bool begin_visit(if_expr& node)
-{
- return true;
-}
-
-
-void end_visit (fo_expr&)
-{
-}
-
-bool begin_visit (fo_expr& node)
-{
- return true;
-}
-
-
-void end_visit (instanceof_expr&)
-{
-}
-
-bool begin_visit (instanceof_expr& node)
-{
- checkNonUpdating(&*node.get_input());
- return true;
-}
-
-
-DEF_VISIT_METHODS (treat_expr)
-
-
-void end_visit (castable_expr&)
-{
-}
-
-bool begin_visit (castable_expr& node)
-{
- checkNonUpdating(&*node.get_input());
- return true;
-}
-
-
-void end_visit (cast_expr&)
-{
-}
-
-bool begin_visit (cast_expr& node)
-{
- checkNonUpdating(&*node.get_input());
- return true;
-}
-
-
-void end_visit (name_cast_expr&)
-{
-}
-
-bool begin_visit (name_cast_expr& node)
-{
- checkNonUpdating(&*node.get_input());
- return true;
-}
-
-
-void end_visit (validate_expr&)
-{
-}
-
-bool begin_visit (validate_expr& node)
-{
- checkNonUpdating(&*node.get_expr());
- return true;
-}
-
-
-void end_visit (extension_expr&)
-{
-}
-
-bool begin_visit (extension_expr& node)
-{
- checkNonUpdating(&*node.get_expr());
- return true;
-}
-
-
-DEF_VISIT_METHODS (relpath_expr)
-DEF_VISIT_METHODS (axis_step_expr)
-DEF_VISIT_METHODS (match_expr)
-DEF_VISIT_METHODS (const_expr)
-DEF_VISIT_METHODS (order_expr)
-
-
-void end_visit (elem_expr&)
-{
-}
-
-bool begin_visit (elem_expr& node)
-{
- //node.setQNameExpr(wrap_in_atomization(m_sctx, node.getQNameExpr()));
- checkNonUpdating(&*node.getQNameExpr());
- checkNonUpdating(&*node.getAttrs());
- checkNonUpdating(&*node.getContent());
- return true;
-}
-
-
-void end_visit (doc_expr&)
-{
-}
-
-bool begin_visit (doc_expr& node)
-{
- checkNonUpdating(node.getContent());
- return true;
-}
-
-
-void end_visit (attr_expr&)
-{
-}
-
-bool begin_visit (attr_expr& node)
-{
- assert (node.getQNameExpr() != NULL);
-
- checkNonUpdating(&*node.getQNameExpr());
- checkNonUpdating(&*node.getValueExpr());
-
- return true;
-}
-
-
-void end_visit (text_expr&)
-{
-}
-
-bool begin_visit (text_expr& node)
-{
- checkNonUpdating(&*node.get_text());
- return true;
-}
-
-
-void end_visit (pi_expr&)
-{
-}
-
-bool begin_visit (pi_expr& node)
-{
- checkNonUpdating(&*node.get_target_expr());
- return true;
-}
-
-
-DEF_VISIT_METHODS (insert_expr)
-DEF_VISIT_METHODS (delete_expr)
-DEF_VISIT_METHODS (rename_expr)
-DEF_VISIT_METHODS (replace_expr)
-DEF_VISIT_METHODS (transform_expr)
-
-DEF_VISIT_METHODS (exit_expr)
-DEF_VISIT_METHODS (while_expr)
-DEF_VISIT_METHODS (flowctl_expr)
-
-DEF_VISIT_METHODS (function_def_expr)
-
-};
-
-#endif
-
-
-void normalize_expr_tree(
- const char* norm_descr,
- CompilerCB* aCompilerCB,
- expr_t& root,
- const XQType* rType)
-{
- //normalizer n(aCompilerCB);
-
- //root->accept(n);
-
- if (rType != NULL)
- {
- if (TypeOps::is_builtin_simple(*rType))
- {
- root = wrap_in_atomization(root->get_sctx_id(), root);
- root = wrap_in_type_conversion(root->get_sctx_id(), root, rType);
- }
- else
- {
- root = wrap_in_typematch(root->get_sctx_id(), root, rType);
- }
- }
-
- if (aCompilerCB->theConfig.normalize_cb)
- aCompilerCB->theConfig.normalize_cb (&*root, norm_descr);
-}
-
-}
-/* vim:set et sw=2 ts=2: */
=== removed file 'src/compiler/normalizer/normalizer.h'
--- src/compiler/normalizer/normalizer.h 2013-02-07 17:24:36 +0000
+++ src/compiler/normalizer/normalizer.h 1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef ZORBA_NORMALIZER_H
-#define ZORBA_NORMALIZER_H
-
-#include "common/shared_types.h"
-
-namespace zorba
-{
-
-class XQType;
-class CompilerCB;
-
-
-void normalize_expr_tree(
- const char* descr,
- CompilerCB* cb,
- expr_t& root,
- const XQType* rType);
-
-}
-
-#endif /* ZORBA_NORMALIZER_H */
-
-/*
- * Local variables:
- * mode: c++
- * End:
- */
-/* vim:set et sw=2 ts=2: */
=== modified file 'src/compiler/parser/xquery_parser.y'
--- src/compiler/parser/xquery_parser.y 2013-02-07 17:24:36 +0000
+++ src/compiler/parser/xquery_parser.y 2013-03-06 11:14:46 +0000
@@ -213,6 +213,7 @@
%token <sval> COMP_ELEMENT_QNAME_LBRACE "'element QName {'"
%token <sval> COMP_ATTRIBUTE_QNAME_LBRACE "'attribute QName {'"
%token <sval> COMP_PI_NCNAME_LBRACE "'processing-instruction NCName {'"
+ //%token <sval> COMP_NS_NCNAME_LBRACE "'naespace NCName {'"
%token <sval> QNAME_SVAL "'QName'"
%token <sval> EQNAME_SVAL "'EQName'"
%token <sval> ANNOTATION_QNAME_SVAL "'%QName'"
@@ -713,6 +714,7 @@
%type <expr> CompDocConstructor
%type <expr> CompElemConstructor
%type <expr> CompPIConstructor
+%type <expr> CompNamespaceConstructor
%type <expr> CompTextConstructor
%type <expr> ComputedConstructor
%type <expr> Constructor
@@ -929,7 +931,7 @@
%destructor { release_hack( $$ ); } JSONObjectConstructor JSONPairList JSONArrayConstructor JSONSimpleObjectUnion JSONAccumulatorObjectUnion JSONDeleteExpr JSONInsertExpr JSONRenameExpr JSONReplaceExpr JSONAppendExpr
// exprnodes
-%destructor { release_hack( $$ ); } AdditiveExpr AndExpr AxisStep CDataSection CastExpr CastableExpr CommonContent ComparisonExpr CompAttrConstructor CompCommentConstructor CompDocConstructor CompElemConstructor CompPIConstructor CompTextConstructor ComputedConstructor Constructor ContextItemExpr DirCommentConstructor DirElemConstructor DirElemContent DirPIConstructor DirectConstructor BracedExpr BlockExpr EnclosedStatementsAndOptionalExpr BlockStatement Statement Statements StatementsAndExpr StatementsAndOptionalExpr StatementsAndOptionalExprTop SwitchStatement TypeswitchStatement TryStatement CatchListStatement CatchStatement ApplyStatement IfStatement FLWORStatement ReturnStatement VarDeclStatement Expr ExprSingle ExprSimple ExtensionExpr FLWORExpr ReturnExpr FilterExpr FunctionCall IfExpr InstanceofExpr IntersectExceptExpr Literal MultiplicativeExpr NumericLiteral OrExpr OrderedExpr ParenthesizedExpr PathExpr Predicate PrimaryExpr QuantifiedExpr QueryBody RangeExpr RelativePathExpr StepExpr StringLiteral TreatExpr StringConcatExpr SwitchExpr TypeswitchExpr UnaryExpr UnionExpr UnorderedExpr ValidateExpr ValueExpr SimpleMapExpr VarRef TryExpr CatchListExpr CatchExpr DeleteExpr InsertExpr RenameExpr ReplaceExpr TransformExpr VarNameList VarNameDecl AssignStatement ExitStatement WhileStatement FlowCtlStatement QNAME EQNAME FUNCTION_NAME FTContainsExpr
+%destructor { release_hack( $$ ); } AdditiveExpr AndExpr AxisStep CDataSection CastExpr CastableExpr CommonContent ComparisonExpr CompAttrConstructor CompCommentConstructor CompDocConstructor CompElemConstructor CompPIConstructor CompNamespaceConstructor CompTextConstructor ComputedConstructor Constructor ContextItemExpr DirCommentConstructor DirElemConstructor DirElemContent DirPIConstructor DirectConstructor BracedExpr BlockExpr EnclosedStatementsAndOptionalExpr BlockStatement Statement Statements StatementsAndExpr StatementsAndOptionalExpr StatementsAndOptionalExprTop SwitchStatement TypeswitchStatement TryStatement CatchListStatement CatchStatement ApplyStatement IfStatement FLWORStatement ReturnStatement VarDeclStatement Expr ExprSingle ExprSimple ExtensionExpr FLWORExpr ReturnExpr FilterExpr FunctionCall IfExpr InstanceofExpr IntersectExceptExpr Literal MultiplicativeExpr NumericLiteral OrExpr OrderedExpr ParenthesizedExpr PathExpr Predicate PrimaryExpr QuantifiedExpr QueryBody RangeExpr RelativePathExpr StepExpr StringLiteral TreatExpr StringConcatExpr SwitchExpr TypeswitchExpr UnaryExpr UnionExpr UnorderedExpr ValidateExpr ValueExpr SimpleMapExpr VarRef TryExpr CatchListExpr CatchExpr DeleteExpr InsertExpr RenameExpr ReplaceExpr TransformExpr VarNameList VarNameDecl AssignStatement ExitStatement WhileStatement FlowCtlStatement QNAME EQNAME FUNCTION_NAME FTContainsExpr
// internal non-terminals with values
%destructor { delete $$; } FunctionSig VarNameAndType NameTestList DecimalFormatParam DecimalFormatParamList
@@ -4570,349 +4572,335 @@
// [92]
Constructor :
- DirectConstructor
- {
- $$ = $1;
- }
- | ComputedConstructor
- {
- $$ = $1;
- }
- ;
-
-// [93]
+ DirectConstructor
+ {
+ $$ = $1;
+ }
+ | ComputedConstructor
+ {
+ $$ = $1;
+ }
+;
+
+
DirectConstructor :
- DirElemConstructor
- {
- $$ = $1;
- }
- | DirCommentConstructor
- {
- $$ = $1;
- }
- | DirPIConstructor
- {
- $$ = $1;
- }
- ;
-
-// [94]
+ DirElemConstructor
+ {
+ $$ = $1;
+ }
+ | DirCommentConstructor
+ {
+ $$ = $1;
+ }
+ | DirPIConstructor
+ {
+ $$ = $1;
+ }
+;
+
+
DirElemConstructor :
- LT_OR_START_TAG QNAME OptionalBlank EMPTY_TAG_END /* ws: explicitXQ */
- {
- $$ = new DirElemConstructor(
- LOC(@$),
- static_cast<QName*>($2),
- NULL,
- NULL,
- NULL
- );
- }
- | LT_OR_START_TAG QNAME DirAttributeList OptionalBlank EMPTY_TAG_END /* ws: explicitXQ */
- {
- $$ = new DirElemConstructor(
- LOC(@$),
- static_cast<QName*>($2),
- NULL,
- dynamic_cast<DirAttributeList*>($3),
- NULL
- );
- }
- | LT_OR_START_TAG QNAME OptionalBlank TAG_END START_TAG_END QNAME OptionalBlank TAG_END
- {
- if (static_cast<QName*>($2)->get_qname() != static_cast<QName*>($6)->get_qname())
- {
- error(@5, "syntax error, end tag </" + static_cast<QName*>($6)->get_qname().str() + "> does not match start tag <"
- + static_cast<QName*>($2)->get_qname().str() + ">");
- YYERROR;
- }
-
- $$ = new DirElemConstructor(
- LOC(@$),
- static_cast<QName*>($2),
- static_cast<QName*>($6),
- NULL,
- NULL
- );
- }
- | LT_OR_START_TAG QNAME OptionalBlank TAG_END DirElemContentList START_TAG_END QNAME OptionalBlank TAG_END
- {
- if (static_cast<QName*>($2)->get_qname() != static_cast<QName*>($7)->get_qname())
- {
- error(@5, "syntax error, end tag </" + static_cast<QName*>($7)->get_qname().str() + "> does not match start tag <"
- + static_cast<QName*>($2)->get_qname().str() + ">");
- YYERROR;
- }
-
- $$ = new DirElemConstructor(
- LOC(@$),
- static_cast<QName*>($2),
- static_cast<QName*>($7),
- NULL,
- dynamic_cast<DirElemContentList*>($5)
- );
- }
- | LT_OR_START_TAG QNAME DirAttributeList OptionalBlank TAG_END START_TAG_END QNAME OptionalBlank TAG_END
- {
- if (static_cast<QName*>($2)->get_qname() != static_cast<QName*>($7)->get_qname())
- {
- error(@5, "syntax error, end tag </" + static_cast<QName*>($7)->get_qname().str() + "> does not match start tag <"
- + static_cast<QName*>($2)->get_qname().str() + ">");
- YYERROR;
- }
-
- $$ = new DirElemConstructor(
- LOC(@$),
- static_cast<QName*>($2),
- static_cast<QName*>($7),
- dynamic_cast<DirAttributeList*>($3),
- NULL
- );
- }
- | LT_OR_START_TAG QNAME DirAttributeList OptionalBlank TAG_END DirElemContentList START_TAG_END QNAME OptionalBlank TAG_END
- {
- if (static_cast<QName*>($2)->get_qname() != static_cast<QName*>($8)->get_qname())
- {
- error(@5, "syntax error, end tag </" + static_cast<QName*>($8)->get_qname().str() + "> does not match start tag <"
- + static_cast<QName*>($2)->get_qname().str() + ">");
- YYERROR;
- }
-
- $$ = new DirElemConstructor(
- LOC(@$),
- static_cast<QName*>($2),
- static_cast<QName*>($8),
- dynamic_cast<DirAttributeList*>($3),
- dynamic_cast<DirElemContentList*>($6)
- );
- }
- /* ws: explicitXQ */
- ;
-
-// [94a]
+ LT_OR_START_TAG QNAME OptionalBlank EMPTY_TAG_END /* ws: explicitXQ */
+ {
+ $$ = new DirElemConstructor(LOC(@$),
+ static_cast<QName*>($2),
+ NULL,
+ NULL,
+ NULL);
+ }
+ | LT_OR_START_TAG QNAME OptionalBlank TAG_END START_TAG_END QNAME OptionalBlank TAG_END
+ {
+ if (static_cast<QName*>($2)->get_qname() != static_cast<QName*>($6)->get_qname())
+ {
+ error(@5, "syntax error, end tag </" +
+ static_cast<QName*>($6)->get_qname().str() +
+ "> does not match start tag <" +
+ static_cast<QName*>($2)->get_qname().str() + ">");
+ YYERROR;
+ }
+
+ $$ = new DirElemConstructor(LOC(@$),
+ static_cast<QName*>($2),
+ static_cast<QName*>($6),
+ NULL,
+ NULL);
+ }
+ | LT_OR_START_TAG QNAME DirAttributeList OptionalBlank EMPTY_TAG_END /* ws:explicitXQ */
+ {
+ $$ = new DirElemConstructor(LOC(@$),
+ static_cast<QName*>($2),
+ NULL,
+ dynamic_cast<DirAttributeList*>($3),
+ NULL);
+ }
+ | LT_OR_START_TAG QNAME DirAttributeList OptionalBlank TAG_END START_TAG_END QNAME OptionalBlank TAG_END
+ {
+ if (static_cast<QName*>($2)->get_qname() != static_cast<QName*>($7)->get_qname())
+ {
+ error(@5, "syntax error, end tag </" +
+ static_cast<QName*>($7)->get_qname().str() +
+ "> does not match start tag <" +
+ static_cast<QName*>($2)->get_qname().str() + ">");
+ YYERROR;
+ }
+
+ $$ = new DirElemConstructor(LOC(@$),
+ static_cast<QName*>($2),
+ static_cast<QName*>($7),
+ dynamic_cast<DirAttributeList*>($3),
+ NULL);
+ }
+ | LT_OR_START_TAG QNAME OptionalBlank TAG_END
+ DirElemContentList
+ START_TAG_END QNAME OptionalBlank TAG_END
+ {
+ if (static_cast<QName*>($2)->get_qname() != static_cast<QName*>($7)->get_qname())
+ {
+ error(@5, "syntax error, end tag </" +
+ static_cast<QName*>($7)->get_qname().str() +
+ "> does not match start tag <" +
+ static_cast<QName*>($2)->get_qname().str() + ">");
+ YYERROR;
+ }
+
+ $$ = new DirElemConstructor(LOC(@$),
+ static_cast<QName*>($2),
+ static_cast<QName*>($7),
+ NULL,
+ dynamic_cast<DirElemContentList*>($5));
+ }
+ | LT_OR_START_TAG QNAME DirAttributeList OptionalBlank TAG_END
+ DirElemContentList
+ START_TAG_END QNAME OptionalBlank TAG_END
+ {
+ if (static_cast<QName*>($2)->get_qname() != static_cast<QName*>($8)->get_qname())
+ {
+ error(@5, "syntax error, end tag </" +
+ static_cast<QName*>($8)->get_qname().str() +
+ "> does not match start tag <" +
+ static_cast<QName*>($2)->get_qname().str() + ">");
+ YYERROR;
+ }
+
+ $$ = new DirElemConstructor(LOC(@$),
+ static_cast<QName*>($2),
+ static_cast<QName*>($8),
+ dynamic_cast<DirAttributeList*>($3),
+ dynamic_cast<DirElemContentList*>($6));
+ }
+/* ws: explicitXQ */
+;
+
+
DirElemContentList :
- DirElemContent
- {
- DirElemContentList *decl = new DirElemContentList( LOC(@$) );
- decl->push_back( dynamic_cast<DirElemContent*>($1) );
- $$ = decl;
- }
- | DirElemContentList DirElemContent
- {
- DirElemContentList *decl = dynamic_cast<DirElemContentList*>($1);
- if ( decl )
- decl->push_back( dynamic_cast<DirElemContent*>($2) );
- $$ = $1;
- }
- ;
-
-// [95]
+ DirElemContent
+ {
+ DirElemContentList *decl = new DirElemContentList( LOC(@$) );
+ decl->push_back( dynamic_cast<DirElemContent*>($1) );
+ $$ = decl;
+ }
+ | DirElemContentList DirElemContent
+ {
+ DirElemContentList *decl = dynamic_cast<DirElemContentList*>($1);
+ if ( decl )
+ decl->push_back( dynamic_cast<DirElemContent*>($2) );
+ $$ = $1;
+ }
+;
+
+
DirAttributeList :
- DirAttr
- {
- DirAttributeList *dal = new DirAttributeList( LOC(@$) );
- dal->push_back( dynamic_cast<DirAttr*>($1) );
- $$ = dal;
- }
- | DirAttributeList DirAttr
- {
- DirAttributeList *dal = dynamic_cast<DirAttributeList*>($1);
- if ( dal )
- dal->push_back( dynamic_cast<DirAttr*>($2) );
- $$ = $1;
- }
- ;
-
-// [95a]
+ DirAttr
+ {
+ DirAttributeList *dal = new DirAttributeList( LOC(@$) );
+ dal->push_back( dynamic_cast<DirAttr*>($1) );
+ $$ = dal;
+ }
+ | DirAttributeList DirAttr
+ {
+ DirAttributeList *dal = dynamic_cast<DirAttributeList*>($1);
+ if ( dal )
+ dal->push_back( dynamic_cast<DirAttr*>($2) );
+ $$ = $1;
+ }
+;
+
+
DirAttr :
- BLANK QNAME OptionalBlank EQUALS OptionalBlank DirAttributeValue /* ws: explicitXQ */
- {
- $$ = new DirAttr(
- LOC(@$),
- static_cast<QName*>($2),
- dynamic_cast<DirAttributeValue*>($6)
- );
- }
- ;
+ BLANK QNAME OptionalBlank EQUALS OptionalBlank DirAttributeValue /* ws: explicitXQ */
+ {
+ $$ = new DirAttr(LOC(@$),
+ static_cast<QName*>($2),
+ dynamic_cast<DirAttributeValue*>($6));
+ }
+;
// OptionaBlank used in the DirElemConstr
OptionalBlank :
- /* empty */
- | BLANK;
-
-// [96]
+ /* empty */
+ | BLANK;
+
+
DirAttributeValue :
- QUOTE opt_QuoteAttrContentList QUOTE
- {
- $$ = new DirAttributeValue( LOC(@$),
- dynamic_cast<QuoteAttrContentList*>($2));
- }
- | APOS opt_AposAttrContentList APOS /* ws: explicitXQ */
- {
- $$ = new DirAttributeValue( LOC(@$),
- dynamic_cast<AposAttrContentList*>($2));
- }
- ;
-
-// [96a]
+ QUOTE opt_QuoteAttrContentList QUOTE
+ {
+ $$ = new DirAttributeValue(LOC(@$),
+ dynamic_cast<QuoteAttrContentList*>($2));
+ }
+ | APOS opt_AposAttrContentList APOS /* ws: explicitXQ */
+ {
+ $$ = new DirAttributeValue( LOC(@$),
+ dynamic_cast<AposAttrContentList*>($2));
+ }
+;
+
+
opt_QuoteAttrContentList :
- /* empty */
- {
- $$ = new QuoteAttrContentList( LOC(@$) );
- }
- | QuoteAttrContentList
- {
- $$ = $1;
- }
- ;
+ /* empty */
+ {
+ $$ = new QuoteAttrContentList( LOC(@$) );
+ }
+ | QuoteAttrContentList
+ {
+ $$ = $1;
+ }
+;
QuoteAttrContentList :
- ESCAPE_QUOTE
- {
- QuoteAttrContentList *qacl = new QuoteAttrContentList( LOC(@$) );
- qacl->push_back( new QuoteAttrValueContent( LOC(@$), "\"" ) );
- $$ = qacl;
- }
- | QuoteAttrValueContent
- {
- QuoteAttrContentList *qacl = new QuoteAttrContentList( LOC(@$) );
- qacl->push_back( dynamic_cast<QuoteAttrValueContent*>($1) );
- $$ = qacl;
- }
- | QuoteAttrContentList ESCAPE_QUOTE
- {
- QuoteAttrContentList *qacl =
- dynamic_cast<QuoteAttrContentList*>($1);
- if ( qacl )
- qacl->push_back( new QuoteAttrValueContent( LOC(@$), "\"" ) );
- $$ = $1;
- }
- | QuoteAttrContentList QuoteAttrValueContent
- {
- QuoteAttrContentList *qacl =
- dynamic_cast<QuoteAttrContentList*>($1);
- if ( qacl )
- qacl->push_back( dynamic_cast<QuoteAttrValueContent*>($2) );
- $$ = $1;
- }
- ;
-
-// [96b]
+ ESCAPE_QUOTE
+ {
+ QuoteAttrContentList *qacl = new QuoteAttrContentList( LOC(@$) );
+ qacl->push_back( new QuoteAttrValueContent( LOC(@$), "\"" ) );
+ $$ = qacl;
+ }
+ | QuoteAttrValueContent
+ {
+ QuoteAttrContentList *qacl = new QuoteAttrContentList( LOC(@$) );
+ qacl->push_back( dynamic_cast<QuoteAttrValueContent*>($1) );
+ $$ = qacl;
+ }
+ | QuoteAttrContentList ESCAPE_QUOTE
+ {
+ QuoteAttrContentList* qacl = dynamic_cast<QuoteAttrContentList*>($1);
+ if ( qacl )
+ qacl->push_back( new QuoteAttrValueContent( LOC(@$), "\"" ) );
+ $$ = $1;
+ }
+ | QuoteAttrContentList QuoteAttrValueContent
+ {
+ QuoteAttrContentList *qacl = dynamic_cast<QuoteAttrContentList*>($1);
+ if ( qacl )
+ qacl->push_back( dynamic_cast<QuoteAttrValueContent*>($2) );
+ $$ = $1;
+ }
+;
+
+
opt_AposAttrContentList :
- /* empty */
- {
- $$ = new AposAttrContentList( LOC(@$) );
- }
- | AposAttrContentList
- {
- $$ = $1;
- }
- ;
+ /* empty */
+ {
+ $$ = new AposAttrContentList( LOC(@$) );
+ }
+ | AposAttrContentList
+ {
+ $$ = $1;
+ }
+;
AposAttrContentList :
- ESCAPE_APOS
- {
- AposAttrContentList *aacl = new AposAttrContentList( LOC(@$) );
- aacl->push_back( new AposAttrValueContent( LOC(@$),"'") );
- $$ = aacl;
- }
- | AposAttrValueContent
- {
- AposAttrContentList *aacl = new AposAttrContentList( LOC(@$) );
- aacl->push_back( dynamic_cast<AposAttrValueContent*>($1) );
- $$ = aacl;
- }
- | AposAttrContentList ESCAPE_APOS
- {
- AposAttrContentList *aacl = dynamic_cast<AposAttrContentList*>($1);
- if (aacl)
- aacl->push_back( new AposAttrValueContent( LOC(@$),"'") );
- $$ = $1;
- }
- | AposAttrContentList AposAttrValueContent
- {
- AposAttrContentList *aacl = dynamic_cast<AposAttrContentList*>($1);
- if ( aacl )
- aacl->push_back( dynamic_cast<AposAttrValueContent*>($2) );
- $$ = $1;
- }
- ;
-
-// [97]
+ ESCAPE_APOS
+ {
+ AposAttrContentList *aacl = new AposAttrContentList( LOC(@$) );
+ aacl->push_back( new AposAttrValueContent( LOC(@$),"'") );
+ $$ = aacl;
+ }
+ | AposAttrValueContent
+ {
+ AposAttrContentList *aacl = new AposAttrContentList( LOC(@$) );
+ aacl->push_back( dynamic_cast<AposAttrValueContent*>($1) );
+ $$ = aacl;
+ }
+ | AposAttrContentList ESCAPE_APOS
+ {
+ AposAttrContentList *aacl = dynamic_cast<AposAttrContentList*>($1);
+ if (aacl)
+ aacl->push_back( new AposAttrValueContent( LOC(@$),"'") );
+ $$ = $1;
+ }
+ | AposAttrContentList AposAttrValueContent
+ {
+ AposAttrContentList *aacl = dynamic_cast<AposAttrContentList*>($1);
+ if ( aacl )
+ aacl->push_back( dynamic_cast<AposAttrValueContent*>($2) );
+ $$ = $1;
+ }
+;
+
+
QuoteAttrValueContent :
- QUOTE_ATTR_CONTENT
- {
- $$ = new QuoteAttrValueContent( LOC(@$), SYMTAB($1) );
- }
- | CommonContent
- {
- $$ = new QuoteAttrValueContent(
- LOC(@$), dynamic_cast<CommonContent*>($1)
- );
- }
- ;
-
-// [98]
+ QUOTE_ATTR_CONTENT
+ {
+ $$ = new QuoteAttrValueContent( LOC(@$), SYMTAB($1) );
+ }
+ | CommonContent
+ {
+ $$ = new QuoteAttrValueContent(LOC(@$), dynamic_cast<CommonContent*>($1));
+ }
+;
+
+
AposAttrValueContent :
- APOS_ATTR_CONTENT
- {
- $$ = new AposAttrValueContent( LOC(@$), SYMTAB($1) );
- }
- | CommonContent
- {
- $$ = new AposAttrValueContent(
- LOC(@$), dynamic_cast<CommonContent*>($1)
- );
- }
- ;
-
-// [99]
+ APOS_ATTR_CONTENT
+ {
+ $$ = new AposAttrValueContent( LOC(@$), SYMTAB($1) );
+ }
+ | CommonContent
+ {
+ $$ = new AposAttrValueContent(LOC(@$), dynamic_cast<CommonContent*>($1));
+ }
+;
+
+
DirElemContent :
- DirectConstructor
- {
- $$ = new DirElemContent( LOC(@$), $1 );
- }
- | ELEMENT_CONTENT
- {
- $$ = new DirElemContent( LOC(@$), SYMTAB($1) );
- }
- | CDataSection
- {
- rchandle<CDataSection> cdata_h = dynamic_cast<CDataSection*>($1);
- $$ = new DirElemContent( LOC(@$), cdata_h );
- }
- | CommonContent
- {
- rchandle<CommonContent> cont_h = dynamic_cast<CommonContent*>($1);
- $$ = new DirElemContent( LOC(@$), cont_h );
- }
- ;
-
-// [100]
+ DirectConstructor
+ {
+ $$ = new DirElemContent( LOC(@$), $1 );
+ }
+ | ELEMENT_CONTENT
+ {
+ $$ = new DirElemContent( LOC(@$), SYMTAB($1) );
+ }
+ | CDataSection
+ {
+ rchandle<CDataSection> cdata_h = dynamic_cast<CDataSection*>($1);
+ $$ = new DirElemContent( LOC(@$), cdata_h );
+ }
+ | CommonContent
+ {
+ rchandle<CommonContent> cont_h = dynamic_cast<CommonContent*>($1);
+ $$ = new DirElemContent( LOC(@$), cont_h );
+ }
+;
+
+
CommonContent :
- CHAR_REF_LITERAL
- {
- $$ = new CommonContent(
- LOC(@$), ParseConstants::cont_charref, SYMTAB($1)
- );
- }
- | DOUBLE_LBRACE
- {
- $$ = new CommonContent(
- LOC(@$), ParseConstants::cont_escape_lbrace
- );
- }
- | DOUBLE_RBRACE
- {
- $$ = new CommonContent(
- LOC(@$), ParseConstants::cont_escape_rbrace
- );
- }
- | LBRACE StatementsAndExpr RBRACE
- {
- $$ = new CommonContent(LOC(@$), new EnclosedExpr(LOC(@$), $2));
- }
- ;
+ CHAR_REF_LITERAL
+ {
+ $$ = new CommonContent(LOC(@$), ParseConstants::cont_charref, SYMTAB($1));
+ }
+ | DOUBLE_LBRACE
+ {
+ $$ = new CommonContent(LOC(@$), ParseConstants::cont_escape_lbrace);
+ }
+ | DOUBLE_RBRACE
+ {
+ $$ = new CommonContent(LOC(@$), ParseConstants::cont_escape_rbrace);
+ }
+ | LBRACE StatementsAndExpr RBRACE
+ {
+ $$ = new CommonContent(LOC(@$), new EnclosedExpr(LOC(@$), $2));
+ }
+;
DirCommentConstructor :
@@ -4979,28 +4967,30 @@
{
$$ = $1;
}
+ |
+ CompNamespaceConstructor
;
-// [108]
+
CompDocConstructor :
- DOCUMENT LBRACE StatementsAndExpr RBRACE
- {
- $$ = new CompDocConstructor( LOC(@$), $3 );
- }
- ;
-
-// [109]
+ DOCUMENT LBRACE StatementsAndExpr RBRACE
+ {
+ $$ = new CompDocConstructor( LOC(@$), $3 );
+ }
+;
+
+
CompElemConstructor :
- COMP_ELEMENT_QNAME_LBRACE StatementsAndOptionalExpr RBRACE
- {
- $$ = new CompElemConstructor(LOC(@$), new QName(LOC(@$), SYMTAB($1)), $2);
- }
- | ELEMENT LBRACE Expr RBRACE LBRACE StatementsAndOptionalExpr RBRACE
- {
- $$ = new CompElemConstructor( LOC(@$), $3, $6 );
- }
- ;
+ COMP_ELEMENT_QNAME_LBRACE StatementsAndOptionalExpr RBRACE
+ {
+ $$ = new CompElemConstructor(LOC(@$), new QName(LOC(@$), SYMTAB($1)), $2);
+ }
+| ELEMENT LBRACE Expr RBRACE LBRACE StatementsAndOptionalExpr RBRACE
+ {
+ $$ = new CompElemConstructor( LOC(@$), $3, $6 );
+ }
+;
// [110]
/*
@@ -5011,45 +5001,62 @@
;
*/
-// [111]
+
CompAttrConstructor :
- COMP_ATTRIBUTE_QNAME_LBRACE StatementsAndOptionalExpr RBRACE
- {
- $$ = new CompAttrConstructor( LOC(@$), new QName(LOC(@$), SYMTAB($1)), $2 );
- }
- | ATTRIBUTE LBRACE Expr RBRACE LBRACE StatementsAndOptionalExpr RBRACE
- {
- $$ = new CompAttrConstructor( LOC(@$), $3, $6 );
- }
- ;
-
-// [112]
+ COMP_ATTRIBUTE_QNAME_LBRACE StatementsAndOptionalExpr RBRACE
+ {
+ $$ = new CompAttrConstructor( LOC(@$), new QName(LOC(@$), SYMTAB($1)), $2 );
+ }
+| ATTRIBUTE LBRACE Expr RBRACE LBRACE StatementsAndOptionalExpr RBRACE
+ {
+ $$ = new CompAttrConstructor( LOC(@$), $3, $6 );
+ }
+;
+
+
CompTextConstructor :
- TEXT LBRACE StatementsAndExpr RBRACE
- {
- $$ = new CompTextConstructor( LOC(@$), $3 );
- }
- ;
-
-// [113]
+ TEXT LBRACE StatementsAndExpr RBRACE
+ {
+ $$ = new CompTextConstructor( LOC(@$), $3 );
+ }
+;
+
+
CompCommentConstructor :
- COMMENT LBRACE StatementsAndExpr RBRACE
- {
- $$ = new CompCommentConstructor( LOC(@$), $3 );
- }
- ;
-
-// [114]
+ COMMENT LBRACE StatementsAndExpr RBRACE
+ {
+ $$ = new CompCommentConstructor( LOC(@$), $3 );
+ }
+;
+
+
CompPIConstructor :
- COMP_PI_NCNAME_LBRACE StatementsAndOptionalExpr RBRACE
- {
- $$ = new CompPIConstructor( LOC(@$), SYMTAB($1), $2 );
- }
- | PROCESSING_INSTRUCTION LBRACE Expr RBRACE LBRACE StatementsAndOptionalExpr RBRACE
- {
- $$ = new CompPIConstructor( LOC(@$), $3, $6 );
- }
- ;
+ COMP_PI_NCNAME_LBRACE StatementsAndOptionalExpr RBRACE
+ {
+ $$ = new CompPIConstructor(LOC(@$), SYMTAB($1), $2);
+ }
+| PROCESSING_INSTRUCTION LBRACE Expr RBRACE LBRACE StatementsAndOptionalExpr RBRACE
+ {
+ $$ = new CompPIConstructor(LOC(@$), $3, $6);
+ }
+;
+
+
+CompNamespaceConstructor :
+ /*
+ COMP_NS_NCNAME_LBRACE StatementsAndExpr RBRACE
+ NAMESPACE NCNAME LBRACE StatementsAndExpr RBRACE
+ {
+ $$ = new CompNamespaceConstructor(LOC(@$), SYMTAB($2), $4);
+ }
+ |
+ */
+ NAMESPACE LBRACE Expr RBRACE LBRACE StatementsAndExpr RBRACE
+ {
+ $$ = new CompNamespaceConstructor(LOC(@$), $3, $6);
+ }
+;
+
TypeDeclaration :
=== modified file 'src/compiler/parsetree/parsenode_print_xml_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xml_visitor.cpp 2013-02-07 17:24:36 +0000
+++ src/compiler/parsetree/parsenode_print_xml_visitor.cpp 2013-03-06 11:14:46 +0000
@@ -716,6 +716,7 @@
BEGIN_END_TAG (CompDocConstructor)
BEGIN_END_TAG (CompElemConstructor)
BEGIN_END_TAG (CompPIConstructor)
+BEGIN_END_TAG (CompNamespaceConstructor)
BEGIN_END_TAG (CompTextConstructor)
BEGIN_END_TAG (ConstructionDecl)
BEGIN_END_TAG (ContextItemExpr)
=== modified file 'src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp 2013-02-26 04:12:43 +0000
+++ src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp 2013-03-06 11:14:46 +0000
@@ -1360,6 +1360,7 @@
XQDOC_NO_BEGIN_END_TAG (CompDocConstructor)
XQDOC_NO_BEGIN_END_TAG (CompElemConstructor)
XQDOC_NO_BEGIN_END_TAG (CompPIConstructor)
+XQDOC_NO_BEGIN_END_TAG (CompNamespaceConstructor)
XQDOC_NO_BEGIN_END_TAG (CompTextConstructor)
XQDOC_NO_BEGIN_END_TAG (ConstructionDecl)
XQDOC_NO_BEGIN_END_TAG (ContextItemExpr)
=== modified file 'src/compiler/parsetree/parsenode_print_xquery_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xquery_visitor.cpp 2013-02-26 04:12:43 +0000
+++ src/compiler/parsetree/parsenode_print_xquery_visitor.cpp 2013-03-06 11:14:46 +0000
@@ -1394,6 +1394,30 @@
}
DEFAULT_END_VISIT (CompPIConstructor)
+
+ void* begin_visit(const CompNamespaceConstructor& n)
+ {
+ os << "namespace";
+
+ if (!n.get_prefix().empty())
+ {
+ os << n.get_prefix();
+ }
+ else
+ {
+ os << '{';
+ n.get_prefix_expr()->accept(*this);
+ os << '}';
+ }
+
+ os << '{';
+ n.get_uri_expr()->accept(*this);
+ os << '}';
+ return 0;
+ }
+ DEFAULT_END_VISIT(CompNamespaceConstructor)
+
+
void* begin_visit(const CompTextConstructor& n)
{
os << "text {";
=== modified file 'src/compiler/parsetree/parsenode_visitor.h'
--- src/compiler/parsetree/parsenode_visitor.h 2013-02-07 17:24:36 +0000
+++ src/compiler/parsetree/parsenode_visitor.h 2013-03-06 11:14:46 +0000
@@ -162,6 +162,7 @@
DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( CompDocConstructor );
DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( CompElemConstructor );
DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( CompPIConstructor );
+ DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( CompNamespaceConstructor );
DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( CompTextConstructor );
DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( ContextItemExpr );
DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( DirCommentConstructor );
=== modified file 'src/compiler/parsetree/parsenodes.cpp'
--- src/compiler/parsetree/parsenodes.cpp 2013-02-18 01:12:45 +0000
+++ src/compiler/parsetree/parsenodes.cpp 2013-03-06 11:14:46 +0000
@@ -4141,29 +4141,30 @@
// [116] CompPIConstructor
// -----------------------
CompPIConstructor::CompPIConstructor(
- const QueryLoc& loc_,
- zstring const& _target,
- rchandle<exprnode> _content_expr_h)
-:
+ const QueryLoc& loc_,
+ zstring const& _target,
+ rchandle<exprnode> _content_expr_h)
+ :
exprnode(loc_),
target(_target),
target_expr_h(NULL),
content_expr_h(_content_expr_h)
-{}
+{
+}
+
CompPIConstructor::CompPIConstructor(
- const QueryLoc& loc_,
- rchandle<exprnode> _target_expr_h,
- rchandle<exprnode> _content_expr_h)
-:
+ const QueryLoc& loc_,
+ rchandle<exprnode> _target_expr_h,
+ rchandle<exprnode> _content_expr_h)
+ :
exprnode(loc_),
target(""),
target_expr_h(_target_expr_h),
content_expr_h(_content_expr_h)
-{}
-
-
-//-CompPIConstructor::
+{
+}
+
void CompPIConstructor::accept( parsenode_visitor &v ) const
{
@@ -4174,6 +4175,39 @@
}
+CompNamespaceConstructor::CompNamespaceConstructor(
+ const QueryLoc& loc,
+ const zstring& pre,
+ const rchandle<exprnode>& uri)
+ :
+ exprnode(loc),
+ thePrefix(pre),
+ theUriExpr(uri)
+{
+}
+
+
+CompNamespaceConstructor::CompNamespaceConstructor(
+ const QueryLoc& loc,
+ const rchandle<exprnode>& pre,
+ const rchandle<exprnode>& uri)
+ :
+ exprnode(loc),
+ thePrefixExpr(pre),
+ theUriExpr(uri)
+{
+}
+
+
+void CompNamespaceConstructor::accept(parsenode_visitor& v) const
+{
+ BEGIN_VISITOR();
+ ACCEPT(thePrefixExpr);
+ ACCEPT(theUriExpr);
+ END_VISITOR();
+}
+
+
// [117] SingleType
// ----------------
SingleType::SingleType(
=== modified file 'src/compiler/parsetree/parsenodes.h'
--- src/compiler/parsetree/parsenodes.h 2013-02-18 01:12:45 +0000
+++ src/compiler/parsetree/parsenodes.h 2013-03-06 11:14:46 +0000
@@ -75,6 +75,7 @@
class CompDocConstructor;
class CompElemConstructor;
class CompPIConstructor;
+class CompNamespaceConstructor;
class CompTextConstructor;
class ConstructionDecl;
class ContextItemExpr;
@@ -4747,7 +4748,8 @@
CompAttrConstructor |
CompTextConstructor |
CompCommentConstructor |
- CompPIConstructor
+ CompPIConstructor |
+ CompNamespaceConstructor
********************************************************************************/
@@ -4890,6 +4892,38 @@
/*******************************************************************************
+
+********************************************************************************/
+class CompNamespaceConstructor : public exprnode
+{
+protected:
+ zstring thePrefix;
+ rchandle<exprnode> thePrefixExpr;
+ rchandle<exprnode> theUriExpr;
+
+public:
+ CompNamespaceConstructor(
+ const QueryLoc& loc,
+ const zstring& pre,
+ const rchandle<exprnode>& uri);
+
+ CompNamespaceConstructor(
+ const QueryLoc& loc,
+ const rchandle<exprnode>& pre,
+ const rchandle<exprnode>& uri);
+
+ const zstring& get_prefix() const { return thePrefix; }
+
+ rchandle<exprnode> get_prefix_expr() const { return thePrefixExpr; }
+
+ rchandle<exprnode> get_uri_expr() const { return theUriExpr; }
+
+ void accept(parsenode_visitor&) const;
+};
+
+
+
+/*******************************************************************************
SingleType ::= SimpleType "?"?
********************************************************************************/
class SingleType : public parsenode
=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
--- src/compiler/rewriter/rules/nodeid_rules.cpp 2013-02-21 16:34:45 +0000
+++ src/compiler/rewriter/rules/nodeid_rules.cpp 2013-03-06 11:14:46 +0000
@@ -448,6 +448,7 @@
#endif
case attr_expr_kind :
+ case namespace_expr_kind :
case elem_expr_kind :
case pi_expr_kind :
case text_expr_kind :
@@ -672,6 +673,7 @@
case doc_expr_kind:
case elem_expr_kind:
case attr_expr_kind:
+ case namespace_expr_kind:
case text_expr_kind:
case pi_expr_kind:
{
@@ -679,7 +681,7 @@
// and inherit), should it be considered unsafe? The answer is no, because if
// copy is needed, then any other construction done during the "current" one
// will need to copy as well, so the input trees to the current constructor
- // will be standalone. This is enforced bhy the findNodeSources() method,
+ // will be standalone. This is enforced by the findNodeSources() method,
// which drills down inside constructors and will collect as sources any
// nested c onstructors as well.
break;
@@ -1204,6 +1206,7 @@
case doc_expr_kind:
case elem_expr_kind:
case attr_expr_kind:
+ case namespace_expr_kind:
case text_expr_kind:
case pi_expr_kind:
{
=== modified file 'src/compiler/rewriter/tools/dataflow_annotations.cpp'
--- src/compiler/rewriter/tools/dataflow_annotations.cpp 2013-02-21 16:34:45 +0000
+++ src/compiler/rewriter/tools/dataflow_annotations.cpp 2013-03-06 11:14:46 +0000
@@ -202,24 +202,17 @@
break;
case elem_expr_kind:
- compute_elem_expr(static_cast<elem_expr *>(e));
- break;
-
case doc_expr_kind:
- compute_doc_expr(static_cast<doc_expr *>(e));
- break;
-
case attr_expr_kind:
- compute_attr_expr(static_cast<attr_expr *>(e));
- break;
-
+ case namespace_expr_kind:
case text_expr_kind:
- compute_text_expr(static_cast<text_expr *>(e));
- break;
-
case pi_expr_kind:
- compute_pi_expr(static_cast<pi_expr *>(e));
+ {
+ default_walk(e);
+ SORTED_NODES(e);
+ DISTINCT_NODES(e);
break;
+ }
#ifdef ZORBA_WITH_JSON
case json_direct_object_expr_kind:
@@ -671,46 +664,6 @@
}
-void DataflowAnnotationsComputer::compute_elem_expr(elem_expr* e)
-{
- default_walk(e);
- SORTED_NODES(e);
- DISTINCT_NODES(e);
-}
-
-
-void DataflowAnnotationsComputer::compute_doc_expr(doc_expr* e)
-{
- default_walk(e);
- SORTED_NODES(e);
- DISTINCT_NODES(e);
-}
-
-
-void DataflowAnnotationsComputer::compute_attr_expr(attr_expr* e)
-{
- default_walk(e);
- SORTED_NODES(e);
- DISTINCT_NODES(e);
-}
-
-
-void DataflowAnnotationsComputer::compute_text_expr(text_expr* e)
-{
- default_walk(e);
- SORTED_NODES(e);
- DISTINCT_NODES(e);
-}
-
-
-void DataflowAnnotationsComputer::compute_pi_expr(pi_expr* e)
-{
- default_walk(e);
- SORTED_NODES(e);
- DISTINCT_NODES(e);
-}
-
-
////////////////////////////////////////////////////////////////////////////////
// //
// //
@@ -1023,6 +976,7 @@
}
case attr_expr_kind:
+ case namespace_expr_kind:
case text_expr_kind:
case pi_expr_kind:
{
@@ -1357,6 +1311,7 @@
}
case attr_expr_kind:
+ case namespace_expr_kind:
case text_expr_kind:
case pi_expr_kind:
{
=== modified file 'src/compiler/rewriter/tools/dataflow_annotations.h'
--- src/compiler/rewriter/tools/dataflow_annotations.h 2013-02-07 17:24:36 +0000
+++ src/compiler/rewriter/tools/dataflow_annotations.h 2013-03-06 11:14:46 +0000
@@ -53,11 +53,6 @@
void compute_match_expr(match_expr* e);
void compute_const_expr(const_expr* e);
void compute_order_expr(order_expr* e);
- void compute_elem_expr(elem_expr* e);
- void compute_doc_expr(doc_expr* e);
- void compute_attr_expr(attr_expr* e);
- void compute_text_expr(text_expr* e);
- void compute_pi_expr(pi_expr* e);
void default_walk(expr* e);
bool generic_compute(expr* e);
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2013-02-28 11:15:32 +0000
+++ src/compiler/translator/translator.cpp 2013-03-06 11:14:46 +0000
@@ -12043,18 +12043,19 @@
store::Item_t qnameItem;
expand_elem_qname(qnameItem, v.get_elem_name(), loc);
- nameExpr = theExprManager->create_const_expr(theRootSctx, theUDF, loc, qnameItem);
+ nameExpr = CREATE(const)(theRootSctx, theUDF, loc, qnameItem);
bool copyNodes = (theCCB->theConfig.opt_level < CompilerCB::config::O1 ||
!Properties::instance()->noCopyOptim());
- push_nodestack(theExprManager->create_elem_expr(theRootSctx, theUDF,
- loc,
- nameExpr,
- attrExpr,
- contentExpr,
- theNSCtx,
- copyNodes));
+ push_nodestack(CREATE(elem)(theRootSctx,
+ theUDF,
+ loc,
+ nameExpr,
+ attrExpr,
+ contentExpr,
+ theNSCtx,
+ copyNodes));
pop_elem_scope();
pop_scope();
}
@@ -12311,8 +12312,7 @@
}
else
{
- fo_expr* expr_list = theExprManager->
- create_fo_expr(theRootSctx, theUDF, loc, op_concatenate, args);
+ fo_expr* expr_list = CREATE(fo)(theRootSctx, theUDF, loc, op_concatenate, args);
normalize_fo(expr_list);
@@ -12437,7 +12437,9 @@
}
+/*******************************************************************************
+********************************************************************************/
void* begin_visit(const CDataSection& v)
{
TRACE_VISIT();
@@ -12457,6 +12459,9 @@
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const DirAttributeValue& v)
{
TRACE_VISIT();
@@ -12497,6 +12502,9 @@
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const QuoteAttrContentList& v)
{
TRACE_VISIT();
@@ -12512,6 +12520,9 @@
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const AposAttrContentList& v)
{
TRACE_VISIT();
@@ -12541,6 +12552,9 @@
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const QuoteAttrValueContent& v)
{
TRACE_VISIT();
@@ -12554,6 +12568,9 @@
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const AposAttrValueContent& v)
{
TRACE_VISIT();
@@ -12567,6 +12584,9 @@
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const CommonContent& v)
{
TRACE_VISIT();
@@ -12640,6 +12660,9 @@
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const DirCommentConstructor& v)
{
TRACE_VISIT();
@@ -12661,6 +12684,9 @@
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const DirPIConstructor& v)
{
TRACE_VISIT();
@@ -12685,6 +12711,9 @@
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const CompDocConstructor& v)
{
TRACE_VISIT();
@@ -12695,17 +12724,20 @@
{
TRACE_VISIT_OUT();
- expr* lContent = pop_nodestack();
+ expr* content = pop_nodestack();
- fo_expr* lEnclosed = wrap_in_enclosed_expr(lContent, loc);
+ fo_expr* enclosed = wrap_in_enclosed_expr(content, loc);
bool copyNodes = (theCCB->theConfig.opt_level < CompilerCB::config::O1 ||
!Properties::instance()->noCopyOptim());
- push_nodestack(theExprManager->create_doc_expr(theRootSctx, theUDF, loc, lEnclosed, copyNodes));
+ push_nodestack(CREATE(doc)(theRootSctx, theUDF, loc, enclosed, copyNodes));
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const CompElemConstructor& v)
{
TRACE_VISIT();
@@ -12723,9 +12755,9 @@
{
contentExpr = pop_nodestack();
- fo_expr* lEnclosed = wrap_in_enclosed_expr(contentExpr, loc);
+ fo_expr* enclosed = wrap_in_enclosed_expr(contentExpr, loc);
- contentExpr = lEnclosed;
+ contentExpr = enclosed;
}
QName* constQName = v.get_qname_expr().dyn_cast<QName>();
@@ -12735,32 +12767,32 @@
store::Item_t qnameItem;
expand_elem_qname(qnameItem, constQName, loc);
- nameExpr = theExprManager->create_const_expr(theRootSctx, theUDF, loc, qnameItem);
+ nameExpr = CREATE(const)(theRootSctx, theUDF, loc, qnameItem);
}
else
{
nameExpr = pop_nodestack();
-
- expr* atomExpr = wrap_in_atomization(nameExpr);
- nameExpr = theExprManager->create_name_cast_expr(theRootSctx, theUDF,
- loc,
- atomExpr,
- theNSCtx,
- false);
+ nameExpr = wrap_in_atomization(nameExpr);
+ nameExpr =
+ CREATE(name_cast)(theRootSctx, theUDF, loc, nameExpr, theNSCtx, false);
}
bool copyNodes = (theCCB->theConfig.opt_level < CompilerCB::config::O1 ||
!Properties::instance()->noCopyOptim());
- push_nodestack(theExprManager->create_elem_expr(theRootSctx, theUDF,
- loc,
- nameExpr,
- contentExpr,
- theNSCtx,
- copyNodes));
+ push_nodestack(CREATE(elem)(theRootSctx,
+ theUDF,
+ loc,
+ nameExpr,
+ contentExpr,
+ theNSCtx,
+ copyNodes));
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const CompAttrConstructor& v)
{
TRACE_VISIT();
@@ -12778,7 +12810,6 @@
if (v.get_val_expr() != 0)
{
valueExpr = pop_nodestack();
-
valueExpr = wrap_in_enclosed_expr(valueExpr, loc);
}
@@ -12789,25 +12820,93 @@
store::Item_t qnameItem;
expand_no_default_qname(qnameItem, constQName, constQName->get_location());
- nameExpr = theExprManager->create_const_expr(theRootSctx, theUDF, loc, qnameItem);
+ nameExpr = CREATE(const)(theRootSctx, theUDF, loc, qnameItem);
}
else
{
nameExpr = pop_nodestack();
- expr* atomExpr = wrap_in_atomization(nameExpr);
- nameExpr = theExprManager->create_name_cast_expr(theRootSctx, theUDF,
- loc,
- atomExpr,
- theNSCtx,
- true);
+ nameExpr = wrap_in_atomization(nameExpr);
+ nameExpr =
+ CREATE(name_cast)(theRootSctx, theUDF, loc, nameExpr, theNSCtx, true);
}
- attrExpr = theExprManager->create_attr_expr(theRootSctx, theUDF, loc, nameExpr, valueExpr);
+ attrExpr = CREATE(attr)(theRootSctx, theUDF, loc, nameExpr, valueExpr);
push_nodestack(attrExpr);
}
+/*******************************************************************************
+
+********************************************************************************/
+void* begin_visit(const CompNamespaceConstructor& v)
+{
+ TRACE_VISIT();
+
+ if (theSctx->xquery_version() < StaticContextConsts::xquery_version_3_0)
+ {
+ RAISE_ERROR(err::XPST0003, loc, ERROR_PARAMS(ZED(XPST0003_CompNS)));
+ }
+
+ return no_state;
+}
+
+void end_visit(const CompNamespaceConstructor& v, void* /*visit_state*/)
+{
+ TRACE_VISIT_OUT();
+
+ expr* uriExpr = pop_nodestack();
+ uriExpr = create_cast_expr(loc, uriExpr, theRTM.ANY_URI_TYPE_ONE, false, true);
+
+ expr* prefixExpr;
+
+ if (v.get_prefix_expr() != NULL)
+ {
+ prefixExpr = pop_nodestack();
+ prefixExpr = wrap_in_type_promotion(prefixExpr,
+ theRTM.STRING_TYPE_QUESTION,
+ PROMOTE_TYPE_PROMOTION);
+ }
+ else
+ {
+ store::Item_t qnameItem;
+ GENV_ITEMFACTORY->createQName(qnameItem, "", "", v.get_prefix());
+ prefixExpr = CREATE(const)(theRootSctx, theUDF, loc, qnameItem);
+ }
+
+ expr* nsExpr = CREATE(namespace)(theRootSctx, theUDF, loc, prefixExpr, uriExpr);
+
+ push_nodestack(nsExpr);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void* begin_visit(const CompTextConstructor& v)
+{
+ TRACE_VISIT();
+ return no_state;
+}
+
+void end_visit(const CompTextConstructor& v, void* /*visit_state*/)
+{
+ TRACE_VISIT_OUT();
+
+ expr* inputExpr = pop_nodestack();
+
+ fo_expr* enclosedExpr = wrap_in_enclosed_expr(inputExpr, loc);
+
+ expr* textExpr =
+ CREATE(text)(theRootSctx, theUDF, loc, text_constructor, enclosedExpr);
+
+ push_nodestack(textExpr);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const CompCommentConstructor& v)
{
TRACE_VISIT();
@@ -12822,14 +12921,16 @@
fo_expr* enclosedExpr = wrap_in_enclosed_expr(inputExpr, loc);
- expr* textExpr = theExprManager->create_text_expr(theRootSctx, theUDF, loc,
- comment_constructor,
- enclosedExpr);
+ expr* textExpr =
+ CREATE(text)(theRootSctx, theUDF, loc, comment_constructor, enclosedExpr);
push_nodestack(textExpr);
}
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const CompPIConstructor& v)
{
TRACE_VISIT();
@@ -12858,42 +12959,33 @@
{
target = pop_nodestack();
- expr* castExpr = create_cast_expr(loc, target, theRTM.NCNAME_TYPE_ONE, false, true);
+ expr* castExpr =
+ create_cast_expr(loc, target, theRTM.NCNAME_TYPE_ONE, false, true);
target = wrap_in_enclosed_expr(castExpr, loc);
}
- expr* e = (v.get_target_expr () != NULL ?
- theExprManager->create_pi_expr(theRootSctx, theUDF, loc, target, content) :
- theExprManager->create_pi_expr(theRootSctx, theUDF, loc, theExprManager->create_const_expr(theRootSctx, theUDF, loc, v.get_target().str()), content));
-
- push_nodestack (e);
-}
-
-
-void* begin_visit(const CompTextConstructor& v)
-{
- TRACE_VISIT();
- return no_state;
-}
-
-void end_visit(const CompTextConstructor& v, void* /*visit_state*/)
-{
- TRACE_VISIT_OUT();
-
- expr* inputExpr = pop_nodestack();
-
- fo_expr* enclosedExpr = wrap_in_enclosed_expr(inputExpr, loc);
-
- expr* textExpr = theExprManager->create_text_expr(theRootSctx, theUDF,
- loc,
- text_constructor,
- enclosedExpr);
-
- push_nodestack(textExpr);
-}
-
-
+ expr* e;
+
+ if (v.get_target_expr() != NULL)
+ {
+ e = CREATE(pi)(theRootSctx, theUDF, loc, target, content);
+ }
+ else
+ {
+ e = CREATE(pi)(theRootSctx, theUDF, loc,
+ CREATE(const)(theRootSctx, theUDF, loc, v.get_target().str()),
+ content);
+ }
+
+ push_nodestack(e);
+}
+
+
+
+/*******************************************************************************
+
+********************************************************************************/
void* begin_visit(const TypeName& v)
{
TRACE_VISIT();
@@ -13992,11 +14084,9 @@
// We use a name_cast_expr here for static typing reasons. However, during codegen,
// we are not going to generate a NameCastIterator, because we don't always know at
// compile time whether the target will an element or an attribute node.
- nameExpr = theExprManager->
- create_name_cast_expr(theRootSctx, theUDF, loc, nameExpr, theNSCtx, false);
+ nameExpr = CREATE(name_cast)(theRootSctx, theUDF, loc, nameExpr, theNSCtx, false);
- expr* renameExpr = theExprManager->
- create_rename_expr(theRootSctx, theUDF, loc, targetExpr, nameExpr);
+ expr* renameExpr = CREATE(rename)(theRootSctx, theUDF, loc, targetExpr, nameExpr);
push_nodestack(renameExpr);
}
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2013-03-04 16:17:30 +0000
+++ src/diagnostics/diagnostic_en.xml 2013-03-06 11:14:46 +0000
@@ -163,6 +163,10 @@
<value>function and variable annotations only available in XQuery 3.0 or later</value>
</entry>
+ <entry key="CompNS">
+ <value>computed namespace constructors only available in XQuery 3.0 or later</value>
+ </entry>
+
<entry key="Scripting">
<value>scripting feature not available</value>
</entry>
@@ -931,7 +935,19 @@
QName (for example, because it contains a namespace prefix not found in
statically known namespaces).
</comment>
- <value>${"1": }can not convert to expanded QName${: 2}</value>
+ <value>$1</value>
+
+ <entry key="NotCastToQName">
+ <value>$2: can not convert to xs:QName</value>
+ </entry>
+
+ <entry key="NoEmptyLocalname">
+ <value>can not convert empty local name to xs:QName</value>
+ </entry>
+
+ <entry key="NameSapceConstructor">
+ <value>$2: cannot cast prefix to xs:NCName</value>
+ </entry>
</diagnostic>
<diagnostic code="XQDY0084">
@@ -974,6 +990,20 @@
<value>"$1": invalid node-name</value>
</diagnostic>
+ <diagnostic code="XQDY0101">
+ <comment>
+ Invalid prefix and/or uri in computed namespace constructor
+ </comment>
+ <value>Invalid prefix and/or uri in computed namespace constructor: prefix = $1, namespace URI = $2.</value>
+ </diagnostic>
+
+ <diagnostic code="XQDY0102">
+ <comment>
+ In an element constructor, if two or more namespace bindings in the in-scope bindings would have the same prefix, then an error is raised if they have different URIs; if they would have the same prefix and URI, duplicate bindings are ignored.
+ </comment>
+ <value>"$1": uri causes namespace binding conflict: prefix $2 already bound to $3</value>
+ </diagnostic>
+
<diagnostic code="XTDE1310">
<comment>
It is a non-recoverable dynamic error if the picture string does not
@@ -1700,7 +1730,7 @@
affects an element node by introducing a new namespace binding that
conflicts with one of its existing namespace bindings.
</comment>
- <value>"$1": qname causes namespace binding conflict: prefix $2 cannot be bound to both $3 and $4</value>
+ <value>"$1": uri causes namespace binding conflict: prefix $2 already bound to $3</value>
</diagnostic>
<diagnostic code="XUDY0024">
@@ -1708,7 +1738,7 @@
It is a dynamic error if the effect of a set of updating expressions is
to introduce conflicting namespace bindings into an element node.
</comment>
- <value>"$1": namespace binding conflicts with $2=$3</value>
+ <value>"$1": uri causes namespace binding conflict: prefix $2 already bound to $3</value>
</diagnostic>
<diagnostic code="XUDY0027">
@@ -3544,10 +3574,6 @@
<value>missing drive specification</value>
</entry>
- <entry key="NoEmptyLocalname">
- <value>local-name can not be empty</value>
- </entry>
-
<entry key="NoEmptySeqAsBaseURI">
<value>can't treat empty sequence as base URI</value>
</entry>
=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp 2013-03-05 23:11:50 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2013-03-06 11:14:46 +0000
@@ -262,6 +262,12 @@
XQueryErrorCode XQDY0096( "XQDY0096" );
+XQueryErrorCode XQDY0101( "XQDY0101" );
+
+
+XQueryErrorCode XQDY0102( "XQDY0102" );
+
+
XQueryErrorCode XTDE1310( "XTDE1310" );
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2013-03-05 23:11:50 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2013-03-06 11:14:46 +0000
@@ -203,11 +203,13 @@
{ "XQDY0061", "invalid validate expression operand${: 1}" },
{ "XQDY0064", "\"XML\": invalid name expression" },
{ "XQDY0072", "comment must not contain \"--\" or end with \"-\"" },
- { "XQDY0074", "${\"1\": }can not convert to expanded QName${: 2}" },
+ { "XQDY0074", "$1" },
{ "XQDY0084", "validated element does not have a top-level element declaration in the in-scope element declarations${: 1}" },
{ "XQDY0091", "\"xml:id\" encountered" },
{ "XQDY0092", "\"$1\": must be either \"preserve\" or \"default\"" },
{ "XQDY0096", "\"$1\": invalid node-name" },
+ { "XQDY0101", "Invalid prefix and/or uri in computed namespace constructor: prefix = $1, namespace URI = $2." },
+ { "XQDY0102", "\"$1\": uri causes namespace binding conflict: prefix $2 already bound to $3" },
{ "XQST0009", "schema import not supported" },
{ "XQST0012", "invalid schema definitions" },
{ "XQST0013", "invalid pragma content" },
@@ -278,8 +280,8 @@
{ "XUDY0018", "\"$1\": function declared external, non-updating returns non-empty pending update list" },
{ "XUDY0019", "\"$1\": function declared external, updating returns non-empty data model instance" },
{ "XUDY0021", "$1${ 2}" },
- { "XUDY0023", "\"$1\": qname causes namespace binding conflict: prefix $2 cannot be bound to both $3 and $4" },
- { "XUDY0024", "\"$1\": namespace binding conflicts with $2=$3" },
+ { "XUDY0023", "\"$1\": uri causes namespace binding conflict: prefix $2 already bound to $3" },
+ { "XUDY0024", "\"$1\": uri causes namespace binding conflict: prefix $2 already bound to $3" },
{ "XUDY0027", "target expression is empty sequence" },
{ "XUDY0029", "node has no parent in \"insert\" expression (with \"before\" or \"after\")" },
{ "XUDY0030", "insertion of attrhbute node before or after document node child" },
@@ -687,7 +689,6 @@
{ "~NoCompareTypes_23", "can not compare item of type $2 with item of type $3" },
{ "~NoCompareWithType_4", "can not compare for equality to type \"$4\"" },
{ "~NoDriveSpecification", "missing drive specification" },
- { "~NoEmptyLocalname", "local-name can not be empty" },
{ "~NoEmptySeqAsBaseURI", "can't treat empty sequence as base URI" },
{ "~NoEmptySeqAsCollationParam", "empty-sequence not allowed as collation parameter" },
{ "~NoExternalFunction_2", "\"$2\": external function not found" },
@@ -904,6 +905,7 @@
{ "~XPDY0002_VariableHasNoValue_2", "\"$2\": variable has no value" },
{ "~XPDY0002_VariableUndeclared_2", "\"$2\": undeclared variable" },
{ "~XPST0003_Annotations", "function and variable annotations only available in XQuery 3.0 or later" },
+ { "~XPST0003_CompNS", "computed namespace constructors only available in XQuery 3.0 or later" },
{ "~XPST0003_CountClause30", "\"count\" clause only available in XQuery 3.0 or later" },
{ "~XPST0003_ModuleDeclNotInMain", "module declaration must not be in main module" },
{ "~XPST0003_OuterForClause30", "\"outer-for\" clause only available in XQuery 3.0 or later" },
@@ -932,6 +934,9 @@
{ "~XPTY0117_NotationParam_23", "$2 can not be promoted to parameter type xs:NOTATION of function $3()" },
{ "~XQDY0027_SerializationElementName_2", "\"$2\": invalid serialization parameters; element name must be \"serialization-parameters\"" },
{ "~XQDY0027_SerializationElementNs_2", "\"$2\": invalid namespace for the \"serialization-parameters\" element; must be \"http://www.w3.org/2010/xslt-xquery-serialization\"" },
+ { "~XQDY0074_NameSapceConstructor", "$2: cannot cast prefix to xs:NCName" },
+ { "~XQDY0074_NoEmptyLocalname", "can not convert empty local name to xs:QName" },
+ { "~XQDY0074_NotCastToQName", "$2: can not convert to xs:QName" },
{ "~XQST0046_BadHexDigit_3", "'$3': invalid hexedecimal digit" },
{ "~XQST0059_SpecificationMessage", "\"$2\": target namespace not found for schema/module${ \"3\"}${: 4}" },
{ "~XQST0059_XercesMessage", "$2,$3: error in schema${ with System ID \"4\"}${ with Public ID \"5\"}${: 6}" },
=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
--- src/diagnostics/pregenerated/dict_zed_keys.h 2013-03-05 23:11:50 +0000
+++ src/diagnostics/pregenerated/dict_zed_keys.h 2013-03-06 11:14:46 +0000
@@ -32,6 +32,7 @@
#define ZED_XPST0003_TypeSwitchExpr30 "~XPST0003_TypeSwitchExpr30"
#define ZED_XPST0003_TryCatchExpr30 "~XPST0003_TryCatchExpr30"
#define ZED_XPST0003_Annotations "~XPST0003_Annotations"
+#define ZED_XPST0003_CompNS "~XPST0003_CompNS"
#define ZED_XPST0003_Scripting "~XPST0003_Scripting"
#define ZED_XPST0003_PiTarget "~XPST0003_PiTarget"
#define ZED_XPST0008_VariableName_2 "~XPST0008_VariableName_2"
@@ -59,6 +60,9 @@
#define ZED_XPDY0002_ContextUndeclared_2 "~XPDY0002_ContextUndeclared_2"
#define ZED_XQDY0027_SerializationElementName_2 "~XQDY0027_SerializationElementName_2"
#define ZED_XQDY0027_SerializationElementNs_2 "~XQDY0027_SerializationElementNs_2"
+#define ZED_XQDY0074_NotCastToQName "~XQDY0074_NotCastToQName"
+#define ZED_XQDY0074_NoEmptyLocalname "~XQDY0074_NoEmptyLocalname"
+#define ZED_XQDY0074_NameSapceConstructor "~XQDY0074_NameSapceConstructor"
#define ZED_FTST0009_BadStopWordsLang "~FTST0009_BadStopWordsLang"
#define ZED_FTST0009_BadStemmerLang "~FTST0009_BadStemmerLang"
#define ZED_FTST0009_BadThesaurusLang "~FTST0009_BadThesaurusLang"
@@ -208,7 +212,6 @@
#define ZED_NoCompareTypes_23 "~NoCompareTypes_23"
#define ZED_NoCompareWithType_4 "~NoCompareWithType_4"
#define ZED_NoDriveSpecification "~NoDriveSpecification"
-#define ZED_NoEmptyLocalname "~NoEmptyLocalname"
#define ZED_NoEmptySeqAsBaseURI "~NoEmptySeqAsBaseURI"
#define ZED_NoEmptySeqAsCollationParam "~NoEmptySeqAsCollationParam"
#define ZED_NoHashItemOfType_2 "~NoHashItemOfType_2"
=== modified file 'src/runtime/accessors/accessors_impl.cpp'
--- src/runtime/accessors/accessors_impl.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/accessors/accessors_impl.cpp 2013-03-06 11:14:46 +0000
@@ -50,19 +50,44 @@
if (consumeNext(inNode, theChildren[0].getp(), planState))
{
- if( inNode->getNodeKind() == store::StoreConsts::elementNode ||
- inNode->getNodeKind() == store::StoreConsts::attributeNode)
+ switch (inNode->getNodeKind())
+ {
+ case store::StoreConsts::elementNode:
+ case store::StoreConsts::attributeNode:
{
result = inNode->getNodeName();
- STACK_PUSH(true, state);
- }
- else if(inNode->getNodeKind() == store::StoreConsts::piNode)
- {
- GENV_ITEMFACTORY->createQName(result, zstring(), zstring(), inNode->getTarget());
- STACK_PUSH(true, state);
+ break;
+ }
+ case store::StoreConsts::piNode:
+ {
+ GENV_ITEMFACTORY->createQName(result, "", "", inNode->getTarget());
+ break;
+ }
+ case store::StoreConsts::namespaceNode:
+ {
+ zstring pre = inNode->getNamespacePrefix();
+
+ if (!pre.empty())
+ GENV_ITEMFACTORY->createQName(result, "", "", pre);
+ else
+ result = NULL;
+
+ break;
+ }
+ case store::StoreConsts::textNode:
+ case store::StoreConsts::commentNode:
+ case store::StoreConsts::documentNode:
+ {
+ result = NULL;
+ break;
+ }
+ default:
+ ZORBA_ASSERT(false);
}
}
- STACK_END (state);
+
+ STACK_PUSH(result != NULL, state);
+ STACK_END(state);
}
@@ -73,7 +98,7 @@
{
store::Item_t inNode;
- PlanIteratorState *state;
+ PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
if (consumeNext(inNode, theChildren[0].getp(), planState))
@@ -85,11 +110,7 @@
}
else
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( FnNilledArgNotNode ) ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc, ERROR_PARAMS(ZED(FnNilledArgNotNode)));
}
}
else
@@ -97,9 +118,10 @@
STACK_PUSH(false, state);
}
- STACK_END (state);
+ STACK_END(state);
}
+
/*******************************************************************************
2.3 fn:string
********************************************************************************/
@@ -111,7 +133,7 @@
FnStringIteratorState* state;
DEFAULT_STACK_INIT(FnStringIteratorState, state, planState);
- while(consumeNext(inVal, theChildren[0], planState))
+ while (consumeNext(inVal, theChildren[0], planState))
{
if (inVal->isFunction())
{
@@ -120,7 +142,9 @@
ERROR_PARAMS( inVal->getFunctionName()->getStringValue() ),
ERROR_LOC( loc ) );
}
+
state->hasOutput = true;
+
try
{
inVal->getStringValue2(strval);
@@ -130,6 +154,7 @@
set_source(e, loc);
throw;
}
+
GENV_ITEMFACTORY->createString(result, strval);
STACK_PUSH(true, state);
}
@@ -141,7 +166,7 @@
STACK_PUSH(true, state);
}
- STACK_END (state);
+ STACK_END(state);
}
/*******************************************************************************
@@ -217,6 +242,7 @@
STACK_END(state);
}
+
/*******************************************************************************
2.5 fn:base-uri
********************************************************************************/
@@ -238,7 +264,7 @@
}
}
- STACK_END (state);
+ STACK_END(state);
}
@@ -261,7 +287,7 @@
}
}
- STACK_END (state);
+ STACK_END(state);
}
@@ -270,25 +296,19 @@
********************************************************************************/
bool RootIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
- store::Item_t contextNode;
- store::Item_t parentNode;
-
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
if (!consumeNext(result, theChildren[0].getp(), planState))
return false;
- parentNode = result->getParent();
-
- while (parentNode != NULL)
+ while (result->getParent() != NULL)
{
- result = parentNode;
- parentNode = parentNode->getParent();
+ result = result->getParent();
}
STACK_PUSH(true, state);
- STACK_END (state);
+ STACK_END(state);
}
=== modified file 'src/runtime/core/constructors.cpp'
--- src/runtime/core/constructors.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/core/constructors.cpp 2013-03-06 11:14:46 +0000
@@ -63,6 +63,8 @@
SERIALIZABLE_CLASS_VERSIONS(TextIterator)
+SERIALIZABLE_CLASS_VERSIONS(NamespaceIterator)
+
SERIALIZABLE_CLASS_VERSIONS(EnclosedIterator)
/*******************************************************************************
@@ -325,7 +327,7 @@
if (nodeName->getLocalName().empty())
{
- RAISE_ERROR(err::XQDY0074, loc, ERROR_PARAMS("", ZED(NoEmptyLocalname)));
+ RAISE_ERROR(err::XQDY0074, loc, ERROR_PARAMS(ZED(XQDY0074_NoEmptyLocalname)));
}
pre = nodeName->getPrefix();
@@ -408,6 +410,7 @@
if (theChildrenIter != 0)
{
bool valid = false;
+ store::StoreConsts::NodeKind childKind;
while ((valid = consumeNext(child, theChildrenIter, planState)))
{
@@ -417,15 +420,21 @@
child->getStringValue2(content);
factory->createTextNode(child, result, content);
- }
-
- assert(child->getNodeKind() != store::StoreConsts::documentNode);
-
- if (child->getNodeKind() != store::StoreConsts::attributeNode)
+ childKind = store::StoreConsts::textNode;
+ }
+ else
+ {
+ childKind = child->getNodeKind();
+ }
+
+ assert(childKind != store::StoreConsts::documentNode);
+
+ if (childKind != store::StoreConsts::attributeNode &&
+ childKind != store::StoreConsts::namespaceNode)
{
// Remove empty text nodes, as per 3.8.3.1 Computed Element Constructors
// http://www.w3.org/TR/xquery-30/#id-computedElements
- if (child->getNodeKind() == store::StoreConsts::textNode &&
+ if (childKind == store::StoreConsts::textNode &&
child->getStringValue().empty())
continue;
else
@@ -443,15 +452,21 @@
assert(child->isAtomic());
child->getStringValue2(content);
factory->createTextNode(child, result, content);
- }
-
- assert(child->getNodeKind() != store::StoreConsts::documentNode);
-
- if (child->getNodeKind() == store::StoreConsts::attributeNode)
+ childKind = store::StoreConsts::textNode;
+ }
+ else
+ {
+ childKind = child->getNodeKind();
+ }
+
+ assert(childKind != store::StoreConsts::documentNode);
+
+ if (childKind == store::StoreConsts::attributeNode ||
+ childKind == store::StoreConsts::namespaceNode)
throw XQUERY_EXCEPTION(err::XQTY0024, ERROR_LOC(loc));
// Skip text node with zero-length value
- if (child->getNodeKind() == store::StoreConsts::textNode &&
+ if (childKind == store::StoreConsts::textNode &&
child->getStringValue().empty())
{
;
@@ -617,7 +632,7 @@
// (bug 955135)
if (theRaiseXQDY0074)
{
- RAISE_ERROR(err::XQDY0074, loc, ERROR_PARAMS("", ZED(NoEmptyLocalname)));
+ RAISE_ERROR(err::XQDY0074, loc, ERROR_PARAMS(ZED(XQDY0074_NoEmptyLocalname)));
}
if (theRaiseXQDY0044)
@@ -641,7 +656,7 @@
if (qname->getLocalName().empty())
{
- RAISE_ERROR(err::XQDY0074, loc, ERROR_PARAMS("", ZED(NoEmptyLocalname)));
+ RAISE_ERROR(err::XQDY0074, loc, ERROR_PARAMS(ZED(XQDY0074_NoEmptyLocalname)));
}
if (ZSTREQ(qname->getNamespace(), "http://www.w3.org/2000/xmlns/") ||
@@ -828,6 +843,15 @@
}
+void PiIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+ serialize_baseclass(ar,
+ (BinaryBaseIterator<PiIterator, PlanIteratorState>*)this);
+
+ ar & theIsRoot;
+}
+
+
bool PiIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
store::Item_t lItem;
@@ -915,6 +939,72 @@
BINARY_ACCEPT(PiIterator);
+/*******************************************************************************
+
+********************************************************************************/
+NamespaceIterator::NamespaceIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ PlanIter_t& prefix,
+ PlanIter_t& uri)
+ :
+ BinaryBaseIterator<NamespaceIterator, PlanIteratorState>(sctx, loc, prefix, uri)
+{
+}
+
+
+void NamespaceIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+ serialize_baseclass(ar,
+ (BinaryBaseIterator<NamespaceIterator, PlanIteratorState>*)this);
+}
+
+
+bool NamespaceIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t prefixItem;
+ store::Item_t uriItem;
+ zstring prefix;
+ zstring uri;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ if (consumeNext(prefixItem, theChild0, planState))
+ {
+ // translator places a promote to xs:string? op
+ prefix = prefixItem->getStringValue();
+ }
+
+ // translator places a cast as xs:anyUri op
+ ZORBA_ASSERT(consumeNext(uriItem, theChild1, planState));
+ uri = uriItem->getStringValue();
+
+ if (!GenericCast::castableToNCName(prefix))
+ {
+ RAISE_ERROR(err::XQDY0074, loc,
+ ERROR_PARAMS(ZED(XQDY0074_NameSapceConstructor), prefix));
+ }
+
+ if (prefix == "xmlns" ||
+ (prefix == "xml" && uri != "http://www.w3.org/XML/1998/namespace") ||
+ (prefix != "xml" && uri == "http://www.w3.org/XML/1998/namespace") ||
+ uri.empty() ||
+ uri == "http://www.w3.org/2000/xmlns")
+ {
+ RAISE_ERROR(err::XQDY0101, loc, ERROR_PARAMS(prefix, uri));
+ }
+
+ GENV_ITEMFACTORY->createNamespaceNode(result, prefix, uri);
+ STACK_PUSH(true, state);
+
+ STACK_END(state);
+}
+
+
+BINARY_ACCEPT(NamespaceIterator);
+
+
/********************************************************************************
********************************************************************************/
@@ -1289,6 +1379,16 @@
}
+void NameCastIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+ serialize_baseclass(ar,
+ (UnaryBaseIterator<NameCastIterator, PlanIteratorState>*)this);
+
+ ar & theNCtx;
+ ar & theIsAttrName;
+}
+
+
bool NameCastIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
xqtref_t lItemType;
@@ -1312,12 +1412,12 @@
try
{
temp = result;
- valid = GenericCast::instance()->castToQName(result,
- temp,
- &*theNCtx,
- theIsAttrName,
- theSctx->get_typemanager(),
- loc);
+ valid = GenericCast::castToQName(result,
+ temp,
+ &*theNCtx,
+ theIsAttrName,
+ theSctx->get_typemanager(),
+ loc);
}
catch (ZorbaException const& e)
{
@@ -1334,8 +1434,10 @@
RAISE_ERROR(err::XQDY0096, loc, ERROR_PARAMS(name));
}
else
- // the returned error codes are wrong for name casting => they must be changed
- RAISE_ERROR(err::XQDY0074, loc, ERROR_PARAMS("item"));
+ {
+ RAISE_ERROR(err::XQDY0074, loc,
+ ERROR_PARAMS(ZED(XQDY0074_NotCastToQName), name));
+ }
}
else
{
=== modified file 'src/runtime/core/constructors.h'
--- src/runtime/core/constructors.h 2013-02-07 17:24:36 +0000
+++ src/runtime/core/constructors.h 2013-03-06 11:14:46 +0000
@@ -292,9 +292,7 @@
/*******************************************************************************
-
- PiIterator constructs a PI element.
-
+ PiIterator constructs a PI node.
********************************************************************************/
class PiIterator : public BinaryBaseIterator<PiIterator, PlanIteratorState>
{
@@ -303,26 +301,44 @@
public:
SERIALIZABLE_CLASS(PiIterator);
-
SERIALIZABLE_CLASS_CONSTRUCTOR2T(
- PiIterator,
- BinaryBaseIterator<PiIterator, PlanIteratorState>);
-
- void serialize(::zorba::serialization::Archiver& ar)
- {
- serialize_baseclass(ar,
- (BinaryBaseIterator<PiIterator, PlanIteratorState>*)this);
-
- ar & theIsRoot;
- }
+ PiIterator, BinaryBaseIterator<PiIterator, PlanIteratorState>);
+ void serialize(::zorba::serialization::Archiver& ar);
public:
PiIterator(
- static_context* sctx,
- const QueryLoc& loc,
- PlanIter_t& aTarget,
- PlanIter_t& aContent,
- bool isRoot);
+ static_context* sctx,
+ const QueryLoc& loc,
+ PlanIter_t& aTarget,
+ PlanIter_t& aContent,
+ bool isRoot);
+
+ bool isConstructor() const { return true; }
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& planState) const;
+};
+
+
+/*******************************************************************************
+ NamespaceIterator constructs a namespace node.
+********************************************************************************/
+class NamespaceIterator : public BinaryBaseIterator<NamespaceIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(NamespaceIterator);
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(
+ NamespaceIterator, BinaryBaseIterator<NamespaceIterator, PlanIteratorState>);
+
+ void serialize(::zorba::serialization::Archiver& ar);
+
+public:
+ NamespaceIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ PlanIter_t& prefix,
+ PlanIter_t& uri);
bool isConstructor() const { return true; }
@@ -403,27 +419,17 @@
public:
SERIALIZABLE_CLASS(NameCastIterator);
-
SERIALIZABLE_CLASS_CONSTRUCTOR2T(
- NameCastIterator,
- UnaryBaseIterator<NameCastIterator, PlanIteratorState>);
-
- void serialize(::zorba::serialization::Archiver& ar)
- {
- serialize_baseclass(ar,
- (UnaryBaseIterator<NameCastIterator, PlanIteratorState>*)this);
-
- ar & theNCtx;
- ar & theIsAttrName;
- }
+ NameCastIterator, UnaryBaseIterator<NameCastIterator, PlanIteratorState>);
+ void serialize(::zorba::serialization::Archiver& ar);
public:
NameCastIterator(
- static_context* sctx,
- const QueryLoc& loc,
- PlanIter_t& aChild,
- const namespace_context* aNCtx,
- bool isAttrName);
+ static_context* sctx,
+ const QueryLoc& loc,
+ PlanIter_t& aChild,
+ const namespace_context* aNCtx,
+ bool isAttrName);
virtual ~NameCastIterator();
=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
--- src/runtime/json/jsoniq_functions_impl.cpp 2013-02-26 04:12:43 +0000
+++ src/runtime/json/jsoniq_functions_impl.cpp 2013-03-06 11:14:46 +0000
@@ -520,6 +520,7 @@
return false;
}
+
bool
JSONEncodeForRoundtripIterator::encodeAtomic(
const store::Item_t& aValue,
@@ -527,9 +528,11 @@
JSONEncodeForRoundtripIteratorState* aState) const
{
store::SchemaTypeCode typeCode = aValue->getTypeCode();
- switch (typeCode) {
+ switch (typeCode)
+ {
case store::XS_DOUBLE:
case store::XS_FLOAT:
+ {
if (aValue->getBaseItem() == NULL
&& ! aValue->isNaN() && ! aValue->isPosOrNegInf())
{
@@ -537,17 +540,20 @@
return false;
}
break;
+ }
case store::XS_STRING:
case store::XS_INTEGER:
case store::XS_DECIMAL:
case store::XS_BOOLEAN:
case store::JS_NULL:
+ {
if (aValue->getBaseItem() == NULL)
{
// nothing to change, aResult is not set, the caller needs to use aValue
return false;
}
break;
+ }
default:
break;
}
=== modified file 'src/runtime/nodes/nodes_impl.cpp'
--- src/runtime/nodes/nodes_impl.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/nodes/nodes_impl.cpp 2013-03-06 11:14:46 +0000
@@ -31,6 +31,9 @@
#include "util/uri_util.h"
#include "zorbautils/string_util.h"
+#include "diagnostics/util_macros.h"
+
+
using namespace std;
namespace zorba {
@@ -126,7 +129,7 @@
if (lReference.length() != 45 ||
!utf8::match_whole(lReference, "urn:uuid:[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"))
{
- throw XQUERY_EXCEPTION(zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS(lReference), ERROR_LOC(loc));
+ RAISE_ERROR(zerr::ZAPI0028_INVALID_NODE_URI, loc, ERROR_PARAMS(lReference));
}
haveResult = GENV_STORE.getNodeByReference(result, lUUID->getStringValue());
@@ -142,8 +145,9 @@
}
-// 14.2 fn:local-name
-//---------------------
+/*******************************************************************************
+ 14.2 fn:local-name
+********************************************************************************/
bool FnLocalNameIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
store::Item_t inNode;
@@ -154,19 +158,32 @@
if (consumeNext(inNode, theChildren[0], planState))
{
- if(inNode->getNodeKind() == store::StoreConsts::documentNode ||
- inNode->getNodeKind() == store::StoreConsts::commentNode ||
- inNode->getNodeKind() == store::StoreConsts::textNode)
- {
- ;
+ switch (inNode->getNodeKind())
+ {
+ case store::StoreConsts::documentNode:
+ case store::StoreConsts::commentNode:
+ case store::StoreConsts::textNode:
+ {
+ break;
}
- else if(inNode->getNodeKind() == store::StoreConsts::piNode)
+ case store::StoreConsts::piNode:
{
strRes = inNode->getTarget();
+ break;
}
- else
+ case store::StoreConsts::elementNode:
+ case store::StoreConsts::attributeNode:
{
strRes = inNode->getNodeName()->getLocalName();
+ break;
+ }
+ case store::StoreConsts::namespaceNode:
+ {
+ strRes = inNode->getNamespacePrefix();
+ break;
+ }
+ default:
+ ZORBA_ASSERT(false);
}
STACK_PUSH(GENV_ITEMFACTORY->createString(result, strRes), state);
@@ -176,12 +193,13 @@
STACK_PUSH(GENV_ITEMFACTORY->createString(result, strRes), state);
}
- STACK_END (state);
+ STACK_END(state);
}
-// 14.3 fn:namespace-uri
-//---------------------
+/*******************************************************************************
+ 14.3 fn:namespace-uri
+********************************************************************************/
bool FnNamespaceUriIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
store::Item_t inNode;
@@ -192,8 +210,8 @@
if (consumeNext(inNode, theChildren[0].getp(), planState))
{
- if(inNode->getNodeKind() == store::StoreConsts::elementNode ||
- inNode->getNodeKind() == store::StoreConsts::attributeNode)
+ if (inNode->getNodeKind() == store::StoreConsts::elementNode ||
+ inNode->getNodeKind() == store::StoreConsts::attributeNode)
{
uriStr = inNode->getNodeName()->getNamespace();
}
@@ -205,15 +223,14 @@
STACK_PUSH(GENV_ITEMFACTORY->createAnyURI(result, uriStr), state);
}
- STACK_END (state);
+ STACK_END(state);
}
/*******************************************************************************
14.5 fn:lang
********************************************************************************/
-bool
-FnLangIterator::isLangAttr(const store::Item_t& aAttr) const
+bool FnLangIterator::isLangAttr(const store::Item_t& aAttr) const
{
store::Item* lAttrName = aAttr->getNodeName();
@@ -222,13 +239,13 @@
}
-bool
-FnLangIterator::matchesReqLang(
+bool FnLangIterator::matchesReqLang(
const store::Item_t& aAttr,
const zstring& aRequestLang) const
{
- return utf8::match_whole(
- aAttr->getStringValue(), aRequestLang.str() + "(?:-.+)?", "i");
+ return utf8::match_whole(aAttr->getStringValue(),
+ aRequestLang.str() + "(?:-.+)?",
+ "i");
}
@@ -242,7 +259,7 @@
PlanIteratorState *state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
- if(consumeNext(item, theChildren[0].getp(), planState))
+ if (consumeNext(item, theChildren[0].getp(), planState))
{
item->getStringValue2(reqLang);
@@ -257,9 +274,11 @@
lAttributes->open();
while (lAttributes->next(attr))
{
- if (isLangAttr(attr)) {
+ if (isLangAttr(attr))
+ {
lLangAttrFound = true;
- if (matchesReqLang(attr, reqLang)) {
+ if (matchesReqLang(attr, reqLang))
+ {
lLangAttrMatched = true;
}
break; // inner attribute loop
@@ -271,15 +290,18 @@
{
if(item->getParent() != NULL)
{
- if (isLangAttr(item)) {
+ if (isLangAttr(item))
+ {
lLangAttrFound = true;
- if (matchesReqLang(item, reqLang)) {
+ if (matchesReqLang(item, reqLang))
+ {
lLangAttrMatched = true;
}
}
}
}
- if (lLangAttrFound || lLangAttrMatched ) {
+ if (lLangAttrFound || lLangAttrMatched )
+ {
break; // break outer loop
}
item = item->getParent();
@@ -289,7 +311,7 @@
STACK_PUSH(GENV_ITEMFACTORY->createBoolean(result, lLangAttrMatched), state);
- STACK_END (state);
+ STACK_END(state);
}
@@ -328,12 +350,14 @@
********************************************************************************/
static bool is_ancestor_of(store::Item_t parent, store::Item_t child)
{
- if(parent == NULL)
+ if (parent == NULL)
return false;
- while(child != NULL)
+
+ while (child != NULL)
{
if(parent == child)
return true;
+
child = child->getParent();
}
return false;
@@ -467,21 +491,20 @@
bool
IsFollowingSiblingIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
- store::Item_t lPotentialFollowingSibling;
- store::Item_t lItem;
+ store::Item_t followingSibling;
+ store::Item_t item;
+ bool res;
- PlanIteratorState *state;
+ PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
- consumeNext(lPotentialFollowingSibling, theChildren[0].getp(), planState);
- consumeNext(lItem, theChildren[1].getp(), planState);
-
- STACK_PUSH(
- GENV_ITEMFACTORY->createBoolean(result,
- lPotentialFollowingSibling->isFollowingSibling(lItem)
- ), state);
-
- STACK_END (state);
+ consumeNext(followingSibling, theChildren[0].getp(), planState);
+ consumeNext(item, theChildren[1].getp(), planState);
+
+ res = followingSibling->isFollowingSibling(item);
+
+ STACK_PUSH(GENV_ITEMFACTORY->createBoolean(result, res), state);
+ STACK_END(state);
}
@@ -690,8 +713,9 @@
/*******************************************************************************
+
********************************************************************************/
-int getNodePosition(store::Item_t aNode, store::Item_t aNodeName)
+int getNodePosition(const store::Item_t& aNode, const store::Item_t& aNodeName)
{
int count = 1;
store::Iterator_t lIterator = aNode->getParent()->getChildren();
@@ -711,6 +735,7 @@
return count;
}
+
bool FnPathIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
store::Item_t inNode;
@@ -741,6 +766,7 @@
zPosition = ztd::to_string(getNodePosition(inNode, nodeName));
path += "Q{" + zNamespace + "}" + zLocalName + "[" + zPosition + "]";
break;
+
case store::StoreConsts::attributeNode:
nodeName = inNode->getNodeName();
zNamespace =nodeName->getNamespace();
@@ -752,20 +778,24 @@
}
path += zLocalName;
break;
+
case store::StoreConsts::textNode:
zPosition = ztd::to_string(getNodePosition(inNode, NULL));
path += "text()[" + zPosition + "]";
break;
+
case store::StoreConsts::commentNode:
zPosition = ztd::to_string(getNodePosition(inNode, NULL));
path += "comment()[" + zPosition + "]";
break;
+
case store::StoreConsts::piNode:
nodeName = inNode->getNodeName();
zLocalName = nodeName->getLocalName();
zPosition = ztd::to_string(getNodePosition(inNode, nodeName));
path += "processing-instruction(" + zLocalName + ")[" + zPosition + "]";
break;
+
default:
// this is either a documentNode which should always be a root
// node (and not end up here) or it is something very strange
@@ -802,27 +832,29 @@
/*******************************************************************************
+
********************************************************************************/
bool
NodeCopyIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
- store::Item_t lItem;
- store::CopyMode lCopyMode;
- lCopyMode.set(true,
- theSctx->construction_mode() == StaticContextConsts::cons_preserve,
- theSctx->preserve_ns(),
- theSctx->inherit_ns());
-
- PlanIteratorState *state;
+ store::Item_t item;
+ store::CopyMode copyMode;
+
+ copyMode.set(true,
+ theSctx->construction_mode() == StaticContextConsts::cons_preserve,
+ theSctx->preserve_ns(),
+ theSctx->inherit_ns());
+
+ PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
- while (consumeNext(lItem, theChildren[0].getp(), planState))
+ while (consumeNext(item, theChildren[0].getp(), planState))
{
- result = lItem->copy(0, lCopyMode);
+ result = item->copy(0, copyMode);
STACK_PUSH(true, state);
}
- STACK_END (state);
+ STACK_END(state);
}
} // namespace zorba
=== modified file 'src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp'
--- src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp 2013-02-26 04:12:43 +0000
+++ src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp 2013-03-06 11:14:46 +0000
@@ -59,7 +59,7 @@
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
- if(consumeNext (result, theChildren [0].getp (), planState))
+ if (consumeNext(result, theChildren[0].getp(), planState))
{
if (result->isStreamable())
@@ -71,32 +71,29 @@
// We can't replace "iss" with "is" since we still need the auto_ptr for
// the case when the result is not streamable.
is = &result->getStream();
- uri = get_uri( *is );
+ uri = get_uri(*is);
}
else
{
result->getStringValue2(docString);
- iss.reset (new std::istringstream(docString.c_str()));
+ iss.reset(new std::istringstream(docString.c_str()));
is = iss.get();
uri = nullptr;
}
-
baseUri = theSctx->get_base_uri();
-
- try {
+ try
+ {
store::LoadProperties loadProps;
loadProps.setStoreDocument(false);
result = lStore.loadDocument(baseUri, docUri, *is, loadProps);
}
- catch ( ZorbaException const &e ) {
- XQueryException xe(
- XQUERY_EXCEPTION(
- err::FODC0006,
- ERROR_PARAMS( "fn:parse-xml()", e.what() ),
- ERROR_LOC( loc )
- )
+ catch ( ZorbaException const &e )
+ {
+ XQueryException xe(XQUERY_EXCEPTION(err::FODC0006,
+ ERROR_PARAMS("fn:parse-xml()", e.what()),
+ ERROR_LOC(loc))
);
set_data( xe, e );
throw xe;
@@ -107,6 +104,7 @@
STACK_END (state);
}
+
/*******************************************************************************
14.9.2 fn:serialize
********************************************************************************/
=== modified file 'src/runtime/schema/schema_impl.cpp'
--- src/runtime/schema/schema_impl.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/schema/schema_impl.cpp 2013-03-06 11:14:46 +0000
@@ -114,9 +114,9 @@
bool
ZorbaSchemaTypeIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
- store::Item_t item;
+ store::Item_t item;
- PlanIteratorState *state;
+ PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
if (consumeNext(item, theChildren[0].getp(), planState))
@@ -126,16 +126,17 @@
STACK_PUSH(true, state );
}
- STACK_END (state);
+ STACK_END(state);
}
+
bool
ZorbaIsValidatedIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
store::Item_t item;
store::ItemFactory* factory = GENV_ITEMFACTORY;
- PlanIteratorState *state;
+ PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
if (consumeNext(item, theChildren[0].getp(), planState))
@@ -145,7 +146,7 @@
STACK_PUSH(true, state);
}
- STACK_END (state);
+ STACK_END(state);
}
} // namespace zorba
=== modified file 'src/runtime/sequences/sequences_impl.cpp'
--- src/runtime/sequences/sequences_impl.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/sequences/sequences_impl.cpp 2013-03-06 11:14:46 +0000
@@ -957,6 +957,7 @@
break;
case store::StoreConsts::documentNode:
+ {
return DeepEqual(loc,
sctx,
dctx,
@@ -966,8 +967,9 @@
true,
false);
break;
-
+ }
case store::StoreConsts::elementNode:
+ {
if (! item1->getNodeName()->equals(item2->getNodeName()))
return false;
@@ -987,7 +989,7 @@
true,
true));
break;
-
+ }
case store::StoreConsts::attributeNode:
{
if (! item1->getNodeName()->equals(item2->getNodeName()))
@@ -1007,7 +1009,7 @@
break;
}
- case store::StoreConsts::textNode: /* deliberate fall-through */
+ case store::StoreConsts::textNode:
case store::StoreConsts::commentNode:
{
return (0 == utf8::compare(item1->getStringValue(),
@@ -1031,6 +1033,22 @@
return (0 == lCmpRes);
break;
}
+
+ case store::StoreConsts::namespaceNode:
+ {
+ int lCmpRes = utf8::compare(item1->getNamespacePrefix(),
+ item2->getNamespacePrefix(),
+ collator);
+ if (0 != lCmpRes)
+ return false;
+
+ lCmpRes = utf8::compare(item1->getStringValue(),
+ item2->getStringValue(),
+ collator);
+
+ return (0 == lCmpRes);
+ break;
+ }
}
ZORBA_ASSERT(false); // should never reach here
@@ -1038,6 +1056,7 @@
}
}
+
bool FnDeepEqualIterator::nextImpl(
store::Item_t& result,
PlanState& planState) const
=== modified file 'src/runtime/store/maps_impl.cpp'
--- src/runtime/store/maps_impl.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/store/maps_impl.cpp 2013-03-06 11:14:46 +0000
@@ -542,6 +542,7 @@
/*******************************************************************************
+
********************************************************************************/
bool
MapKeysIterator::nextImpl(
@@ -605,8 +606,7 @@
store::Item_t& lValue = (*lIter);
if (! lValue.isNull())
{
- GENV_ITEMFACTORY->createQName(lValueAttrName,
- "", "", "value");
+ GENV_ITEMFACTORY->createQName(lValueAttrName, "", "", "value");
lTypeName = lValue->getType();
=== modified file 'src/runtime/visitors/planiter_visitor_impl_code.h'
--- src/runtime/visitors/planiter_visitor_impl_code.h 2013-02-07 17:24:36 +0000
+++ src/runtime/visitors/planiter_visitor_impl_code.h 2013-03-06 11:14:46 +0000
@@ -29,6 +29,8 @@
PLAN_ITER_VISITOR (AttributeIterator);
+ PLAN_ITER_VISITOR (NamespaceIterator);
+
PLAN_ITER_VISITOR (DocumentIterator);
#ifdef ZORBA_WITH_JSON
=== modified file 'src/runtime/visitors/planiter_visitor_impl_include.h'
--- src/runtime/visitors/planiter_visitor_impl_include.h 2013-02-07 17:24:36 +0000
+++ src/runtime/visitors/planiter_visitor_impl_include.h 2013-03-06 11:14:46 +0000
@@ -24,13 +24,14 @@
#endif
class OrIterator;
class AndIterator;
- class CompareIterator;
- class AtomicValuesEquivalenceIterator;
- class UDFunctionCallIterator;
- class ExtFunctionCallIterator;
- class ElementIterator;
- class AttributeIterator;
- class CommentIterator;
+class CompareIterator;
+class AtomicValuesEquivalenceIterator;
+class UDFunctionCallIterator;
+class ExtFunctionCallIterator;
+class ElementIterator;
+class AttributeIterator;
+class NamespaceIterator;
+class CommentIterator;
#ifdef ZORBA_WITH_JSON
class JSONObjectIterator;
=== modified file 'src/runtime/visitors/printer_visitor_impl.cpp'
--- src/runtime/visitors/printer_visitor_impl.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/visitors/printer_visitor_impl.cpp 2013-03-06 11:14:46 +0000
@@ -1305,8 +1305,11 @@
}
PRINTER_VISITOR_DEFINITION (CommentIterator)
+
PRINTER_VISITOR_DEFINITION (PiIterator)
+ PRINTER_VISITOR_DEFINITION (NamespaceIterator)
+
#ifdef ZORBA_WITH_JSON
PRINTER_VISITOR_DEFINITION(JSONObjectIterator)
PRINTER_VISITOR_DEFINITION(JSONArrayIterator)
=== modified file 'src/runtime/visitors/printer_visitor_impl.h'
--- src/runtime/visitors/printer_visitor_impl.h 2013-02-07 17:24:36 +0000
+++ src/runtime/visitors/printer_visitor_impl.h 2013-03-06 11:14:46 +0000
@@ -230,6 +230,7 @@
DECLARE_VISITOR (AtomicValuesEquivalenceIterator)
DECLARE_VISITOR (ElementIterator)
DECLARE_VISITOR (AttributeIterator)
+ DECLARE_VISITOR (NamespaceIterator)
DECLARE_VISITOR (DocumentIterator)
DECLARE_VISITOR (CommentIterator)
DECLARE_VISITOR (PiIterator)
=== modified file 'src/store/api/item.h'
--- src/store/api/item.h 2013-02-26 04:12:43 +0000
+++ src/store/api/item.h 2013-03-06 11:14:46 +0000
@@ -664,6 +664,21 @@
getNodeName() const;
/**
+ * Accessor for namepsace nodes.
+ * @return the prefix property of the node
+ */
+ virtual zstring
+ getNamespacePrefix() const;
+
+ /**
+ * Accessor for namepsace nodes.
+ * @return the uri property of the node
+ */
+ virtual zstring
+ getNamespaceUri() const;
+
+
+ /**
* If this item is a node and it belongs to a collection, return that
* collection. Otherwise, return 0.
*
=== modified file 'src/store/api/item_factory.h'
--- src/store/api/item_factory.h 2013-02-26 04:12:43 +0000
+++ src/store/api/item_factory.h 2013-03-06 11:14:46 +0000
@@ -704,6 +704,19 @@
zstring& content) = 0;
/**
+ * Create a new namespace node N as the root (and single node) of a new XML tree.
+ *
+ * @param result The new node N created by this method
+ * @param prefix The prefix of the new node.
+ * @param uri The uri of the new node
+ * @return Always true (if any errors occur, the method throws exceptions)
+ */
+ virtual bool createNamespaceNode(
+ Item_t& result,
+ zstring& prefix,
+ zstring& uri) = 0;
+
+ /**
* Create a pending updates list.
*/
virtual PUL* createPendingUpdateList() = 0;
=== modified file 'src/store/api/item_handle.h'
--- src/store/api/item_handle.h 2013-02-26 04:12:43 +0000
+++ src/store/api/item_handle.h 2013-03-06 11:14:46 +0000
@@ -110,13 +110,15 @@
{
if (p != rhs)
{
- if (p)
- p->removeReference();
+ T* tmp = p;
p = const_cast<T*>(rhs);
if (p)
- p->addReference();
+ p->addReference();
+
+ if (tmp)
+ tmp->removeReference();
}
return *this;
@@ -126,13 +128,15 @@
{
if (p != rhs)
{
- if (p)
- p->removeReference();
+ T* tmp = p;
p = static_cast<T*>(const_cast<otherT*>(rhs));
if (p)
p->addReference();
+
+ if (tmp)
+ tmp->removeReference();
}
return *this;
}
=== modified file 'src/store/naive/item.cpp'
--- src/store/naive/item.cpp 2013-02-26 04:12:43 +0000
+++ src/store/naive/item.cpp 2013-03-06 11:14:46 +0000
@@ -1019,6 +1019,21 @@
);
}
+
+zstring Item::getNamespacePrefix() const
+{
+ throw ZORBA_EXCEPTION(zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS(__FUNCTION__, getType()->getStringValue()));
+}
+
+
+zstring Item::getNamespaceUri() const
+{
+ throw ZORBA_EXCEPTION(zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS(__FUNCTION__, getType()->getStringValue()));
+}
+
+
const store::Collection* Item::getCollection() const
{
throw ZORBA_EXCEPTION(
=== modified file 'src/store/naive/node_factory.cpp'
--- src/store/naive/node_factory.cpp 2013-02-07 17:24:36 +0000
+++ src/store/naive/node_factory.cpp 2013-03-06 11:14:46 +0000
@@ -179,6 +179,16 @@
}
+NamespaceNode* NodeFactory::createNamespaceNode(
+ XmlTree* tree,
+ zstring& prefix,
+ zstring& uri)
+{
+ return new NamespaceNode(tree, prefix, uri);
+}
+
+
+
} /* namespace simplestore */
} /* namespace store */
=== modified file 'src/store/naive/node_factory.h'
--- src/store/naive/node_factory.h 2013-02-07 17:24:36 +0000
+++ src/store/naive/node_factory.h 2013-03-06 11:14:46 +0000
@@ -39,6 +39,7 @@
class TextNode;
class PiNode;
class CommentNode;
+ class NamespaceNode;
/*******************************************************************************
@@ -138,7 +139,12 @@
bool append,
csize pos,
zstring& content);
-}; /* class NodeFactory */
+
+ virtual NamespaceNode* createNamespaceNode(
+ XmlTree* tree,
+ zstring& prefix,
+ zstring& uri);
+};
} /* namespace simplestore */
=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp 2013-02-28 11:15:32 +0000
+++ src/store/naive/node_items.cpp 2013-03-06 11:14:46 +0000
@@ -86,6 +86,9 @@
}
+/*******************************************************************************
+
+********************************************************************************/
XmlTree::XmlTree(XmlNode* root, const TreeId& id)
:
theRefCount(0),
@@ -112,7 +115,6 @@
{
// std::cout << "Deleting Xml Tree: " << this << std::endl;
- // Only delete if not in a collection, or if it is the overall root.
if (theCollectionInfo != NULL &&
theCollectionInfo->getRoot() == static_cast<StructuredItem*>(getRoot()))
{
@@ -158,7 +160,7 @@
********************************************************************************/
store::Item* XmlTree::getType(const XmlNode* n) const
{
- if(theTypesMap == NULL)
+ if (theTypesMap == NULL)
{
return NULL;
}
@@ -275,19 +277,20 @@
********************************************************************************/
void XmlTree::attachToCollection(
- simplestore::Collection* aCollection,
- const TreeId& aTreeId,
- const xs_integer& aPosition)
+ simplestore::Collection* collection,
+ const TreeId& treeId,
+ const xs_integer& pos)
{
assert(!theCollectionInfo);
theCollectionInfo = new CollectionTreeInfo();
- theCollectionInfo->setCollection(aCollection);
- theCollectionInfo->setPosition(aPosition);
+ theCollectionInfo->setCollection(collection);
+ theCollectionInfo->setPosition(pos);
theCollectionInfo->setRoot(getRoot());
- theTreeId = aTreeId;
+ theTreeId = treeId;
}
+
/*******************************************************************************
********************************************************************************/
@@ -494,6 +497,10 @@
}
#endif
+
+/*******************************************************************************
+
+********************************************************************************/
size_t XmlNode::alloc_size() const
{
return store::Item::alloc_size();
@@ -648,7 +655,9 @@
assert(!isConnectorNode());
store::StoreConsts::NodeKind kind = getNodeKind();
- bool copy = (copymode.theDoCopy || kind == store::StoreConsts::attributeNode);
+ bool copy = (copymode.theDoCopy ||
+ kind == store::StoreConsts::attributeNode ||
+ kind == store::StoreConsts::namespaceNode);
InternalNode* parent = NULL;
csize pos = 0;
@@ -923,17 +932,19 @@
GET_STORE().unregisterReferenceToDeletedNode(this);
}
+
/*******************************************************************************
********************************************************************************/
void XmlNode::attachToCollection(
- simplestore::Collection* aCollection,
- const TreeId& aTreeId,
- const xs_integer& aPosition)
+ simplestore::Collection* collection,
+ const TreeId& treeId,
+ const xs_integer& position)
{
- getTree()->attachToCollection(aCollection, aTreeId, aPosition);
+ getTree()->attachToCollection(collection, treeId, position);
}
-
+
+
/*******************************************************************************
********************************************************************************/
@@ -942,14 +953,16 @@
getTree()->detachFromCollection();
}
+
/*******************************************************************************
********************************************************************************/
-void XmlNode::setCollectionTreeInfo(CollectionTreeInfo* lTreeInfo)
+void XmlNode::setCollectionTreeInfo(CollectionTreeInfo* treeInfo)
{
- getTree()->setCollectionTreeInfo(lTreeInfo);
+ getTree()->setCollectionTreeInfo(treeInfo);
}
+
/*******************************************************************************
********************************************************************************/
@@ -958,6 +971,7 @@
return getTree()->getRefCount();
}
+
/*******************************************************************************
********************************************************************************/
@@ -969,8 +983,8 @@
}
assert(this == getTree()->getRoot());
assert(dynamic_cast<const XmlNode*>(anotherItem));
- const XmlNode* aNode = static_cast<const XmlNode*>(anotherItem);
- return getTree() == aNode->getTree();
+ const XmlNode* node = static_cast<const XmlNode*>(anotherItem);
+ return getTree() == node->getTree();
}
@@ -2682,9 +2696,10 @@
+ (haveLocalBindings() ? ztd::alloc_sizeof(theNsContext) : 0);
}
+
size_t ElementNode::dynamic_size() const
{
- return sizeof( *this );
+ return sizeof(*this);
}
@@ -3084,7 +3099,7 @@
The higher parent gives the latest namespaces, instead of first.
********************************************************************************/
void ElementNode::getNamespaceBindings(
- store::NsBindings& bindings,
+ store::NsBindings& bindings,
store::StoreConsts::NsScoping ns_scoping) const
{
assert(bindings.empty());
@@ -3311,7 +3326,7 @@
}
else
{
- throw XQUERY_EXCEPTION(err::XUDY0024, ERROR_PARAMS(qname->show(), prefix, ns2));
+ throw XQUERY_EXCEPTION(err::XUDY0024, ERROR_PARAMS(ns2, prefix, ns));
}
}
@@ -3350,8 +3365,38 @@
/*******************************************************************************
+
+********************************************************************************/
+void ElementNode::addBindingForNSNode(const zstring& prefix, const zstring& ns)
+{
+ // If ns is empty, then prefix must be empty
+ ZORBA_FATAL(!ns.empty() || prefix.empty(),
+ "prefix = " << prefix << " ns = " << ns);
+
+ if (prefix == "xml")
+ return;
+
+ zstring ns2;
+ bool found = findBinding(prefix, ns2);
+
+ if (!found)
+ {
+ if (!ns.empty())
+ {
+ addLocalBinding(prefix, ns);
+ return;
+ }
+ }
+ else if (ns2 != ns)
+ {
+ throw XQUERY_EXCEPTION(err::XQDY0102, ERROR_PARAMS(ns2, prefix, ns));
+ }
+}
+
+
+/*******************************************************************************
Add a given ns binding to the local ns bindings of "this", if it's not already
- there. It is assumed that the given binding does not conflit with the other
+ there. It is assumed that the given binding does not conflict with the other
local bindings of "this" (ZORBA_FATAL is called if this condition is not true).
Note: it is possible to add the binding (empty --> empty); this happens when we
@@ -3382,6 +3427,7 @@
theNsContext->removeBinding(prefix, ns);
}
+
#if 1
/*******************************************************************************
@@ -3420,7 +3466,7 @@
ns bindings of "this" node.
********************************************************************************/
void ElementNode::checkNamespaceConflict(
- const store::Item* qname,
+ const store::Item* qname,
const QueryLoc* loc) const
{
const QNameItem* qn = reinterpret_cast<const QNameItem*>(qname);
@@ -3437,8 +3483,7 @@
if (found && ns2 != ns)
{
- RAISE_ERROR(err::XUDY0023, loc,
- ERROR_PARAMS(qn->getStringValue(), prefix, ns, ns2));
+ RAISE_ERROR(err::XUDY0023, loc, ERROR_PARAMS(ns2, prefix, ns));
}
}
@@ -3990,6 +4035,7 @@
GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC].getp());
}
+
void AttributeNode::setType(store::Item_t& type)
{
#ifndef DEBUG
@@ -4817,6 +4863,7 @@
return false;
}
+
/*******************************************************************************
********************************************************************************/
@@ -4825,6 +4872,7 @@
return getParent()->isFollowing(aOther);
}
+
/*******************************************************************************
********************************************************************************/
@@ -4951,6 +4999,10 @@
return NULL;
}
+
+/*******************************************************************************
+
+********************************************************************************/
void TextNode::swap(Item* anotherItem)
{
throw ZORBA_EXCEPTION(
@@ -5185,19 +5237,21 @@
/*******************************************************************************
********************************************************************************/
-
size_t CommentNode::alloc_size() const
{
return OrdPathNode::alloc_size() + ztd::alloc_sizeof( theContent );
}
+
size_t CommentNode::dynamic_size() const
{
return sizeof( *this );
}
-///////////////////////////////////////////////////////////////////////////////
-
+
+/*******************************************************************************
+
+********************************************************************************/
XmlNode* CommentNode::copyInternal(
InternalNode* rootParent,
InternalNode* parent,
@@ -5248,10 +5302,12 @@
store::Item* CommentNode::getType() const
{
return NULL;
- // return GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC];
}
+/*******************************************************************************
+
+********************************************************************************/
void CommentNode::getTypedValue(store::Item_t& val, store::Iterator_t& iter) const
{
zstring rch = theContent;
@@ -5268,6 +5324,7 @@
return "<!--" + theContent + "-->";
}
+
/*******************************************************************************
********************************************************************************/
@@ -5285,6 +5342,93 @@
}
+/////////////////////////////////////////////////////////////////////////////////
+// //
+// class NamespaceNode //
+// //
+/////////////////////////////////////////////////////////////////////////////////
+
+
+/*******************************************************************************
+
+********************************************************************************/
+NamespaceNode::NamespaceNode(XmlTree* tree, zstring& prefix, zstring& uri)
+ :
+ XmlNode(tree, NULL, store::StoreConsts::namespaceNode)
+{
+ thePrefix.take(prefix);
+ theUri.take(uri);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+XmlNode* NamespaceNode::copyInternal(
+ InternalNode* rootParent,
+ InternalNode* parent,
+ csize pos,
+ const XmlNode* rootCopy,
+ const store::CopyMode& copymode) const
+{
+ ZORBA_ASSERT(rootParent == parent);
+
+ if (parent != NULL)
+ {
+ ZORBA_ASSERT(parent->getNodeKind() == store::StoreConsts::elementNode);
+
+ ElementNode* elem = static_cast<ElementNode*>(parent);
+
+ elem->addBindingForNSNode(thePrefix, theUri);
+ }
+
+ return const_cast<NamespaceNode*>(this);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void NamespaceNode::getTypedValue(store::Item_t& val, store::Iterator_t& iter) const
+{
+ zstring rch = theUri;
+ GET_FACTORY().createString(val, rch);
+ iter = NULL;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+store::Item* NamespaceNode::getNodeName() const
+{
+ if (thePrefix.empty())
+ return NULL;
+
+ store::Item_t result;
+ GET_FACTORY().createQName(result, "", "", thePrefix);
+ return result;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+store::Iterator_t NamespaceNode::getChildren() const
+{
+ return NULL;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+zstring NamespaceNode::show() const
+{
+ return "<namespace prefix=\"" + thePrefix + "\" uri=\"" + theUri + "\"/>";
+}
+
+
#ifndef ZORBA_NO_FULL_TEXT
/******************************************************************************
@@ -5311,7 +5455,8 @@
}
-void XmlNodeTokenizerCallback::item( Item const &api_item, bool entering ) {
+void XmlNodeTokenizerCallback::item( Item const &api_item, bool entering )
+{
if ( token_store_ ) {
store::Item const *const item = Unmarshaller::getInternalItem( api_item );
if ( entering ) {
@@ -5330,8 +5475,14 @@
void XmlNodeTokenizerCallback::
-token( char const *utf8_s, size_type utf8_len, iso639_1::type lang,
- size_type pos, size_type sent, size_type para, Item const *api_item )
+token(
+ char const *utf8_s,
+ size_type utf8_len,
+ iso639_1::type lang,
+ size_type pos,
+ size_type sent,
+ size_type para,
+ Item const *api_item )
{
store::Item const *const item = Unmarshaller::getInternalItem( *api_item );
FTToken t( utf8_s, utf8_len, pos, sent, para, item, lang );
@@ -5346,9 +5497,11 @@
FTTokenIterator_t
-AttributeNode::getTokens( TokenizerProvider const &provider,
- Tokenizer::State &state, iso639_1::type lang,
- bool ) const
+AttributeNode::getTokens(
+ TokenizerProvider const &provider,
+ Tokenizer::State &state,
+ iso639_1::type lang,
+ bool ) const
{
FTTokenStore &token_store = getTree()->getTokenStore();
while ( true ) {
@@ -5430,10 +5583,11 @@
#endif
-FTTokenIterator_t
-XmlNode::getTokens( TokenizerProvider const &provider,
- Tokenizer::State &state, iso639_1::type lang,
- bool ) const
+FTTokenIterator_t XmlNode::getTokens(
+ TokenizerProvider const &provider,
+ Tokenizer::State &state,
+ iso639_1::type lang,
+ bool) const
{
FTTokenStore &token_store = getTree()->getTokenStore();
FTTokenStore::container_type &tokens = token_store.getDocumentTokens();
=== modified file 'src/store/naive/node_items.h'
--- src/store/naive/node_items.h 2013-02-26 04:12:43 +0000
+++ src/store/naive/node_items.h 2013-03-06 11:14:46 +0000
@@ -141,12 +141,15 @@
A collection-relative id for this tree. Uniquely identifies the tree within a
collection, or if the tree does not belong to any collection, its id is unique
among all the other trees that do not belong to any collection either. NOTE:
- when a tree becomes member of a colection, it gets a new id.
+ when a tree becomes member of a colection or gets removed from a collection,
+ it gets a new id.
theCollectionInfo:
------------------
Contains info that is relevant only if the tree belongs to a collection (see
- class CollectionTreeInfo for more details).
+ class CollectionTreeInfo for more details). Note: the object pointed to by
+ theCollectionInfo is owned by this tree iff the tree belongs to a collection
+ directly.
theRootNode:
------------
@@ -163,6 +166,9 @@
theTypesMap:
------------
+ For each element/attribute node in the tree, it maps the node to its data type
+ (specified as a qname). Nodes whose type is xs:untyped are not included in this
+ map.
theTokens:
----------
@@ -196,6 +202,7 @@
#endif
bool theIsValidated;
+
bool theIsRecursive;
#ifndef EMBEDED_TYPE
@@ -231,9 +238,9 @@
void setCollectionTreeInfo(CollectionTreeInfo* collectionInfo);
void attachToCollection(
- simplestore::Collection* aCollection,
- const TreeId& aTreeId,
- const xs_integer& aPosition);
+ simplestore::Collection* collection,
+ const TreeId& treeId,
+ const xs_integer& pos);
void detachFromCollection();
@@ -291,7 +298,7 @@
#ifndef ZORBA_NO_FULL_TEXT
FTTokenStore& getTokenStore() { return theTokens; }
-#endif /* ZORBA_NO_FULL_TEXT */
+#endif
};
@@ -398,21 +405,17 @@
#endif
protected:
- XmlNode() : theParent(NULL)
- {
- }
+ XmlNode() : theParent(NULL) { }
- XmlNode(store::StoreConsts::NodeKind k) :
- StructuredItem(),
- theParent(NULL)
+ XmlNode(store::StoreConsts::NodeKind k)
+ :
+ StructuredItem(),
+ theParent(NULL)
{
theFlags = (uint32_t)k;
}
- XmlNode(
- XmlTree* tree,
- InternalNode* parent,
- store::StoreConsts::NodeKind nodeKind);
+ XmlNode(XmlTree* tree, InternalNode* parent, store::StoreConsts::NodeKind k);
virtual void getBaseURIInternal(zstring& uri, bool& local) const;
@@ -429,7 +432,7 @@
virtual void swap(Item* anotherItem);
#ifndef ZORBA_NO_FULL_TEXT
- virtual void tokenize( XmlNodeTokenizerCallback& );
+ virtual void tokenize(XmlNodeTokenizerCallback&);
#endif
private:
@@ -447,8 +450,6 @@
virtual ~XmlNode() {}
#endif
- size_t alloc_size() const;
-
SYNC_CODE(RCLock* getRCLock() const { return getTree()->getRCLock(); })
void free()
@@ -457,6 +458,8 @@
getTree()->free();
}
+ size_t alloc_size() const;
+
//
// Item methods
//
@@ -482,10 +485,7 @@
return reinterpret_cast<store::Item*>(theParent);
}
- bool equals(
- const store::Item* other,
- long timezone = 0,
- const XQPCollator* aCollation = 0) const;
+ bool equals(const store::Item* other, long tz = 0, const XQPCollator* c = 0) const;
uint32_t hash(long timezone = 0, const XQPCollator* aCollation = 0) const;
@@ -969,8 +969,6 @@
void getTypedValue(store::Item_t& val, store::Iterator_t& iter) const;
- store::Item_t getAtomizationValue() const;
-
zstring getStringValue() const;
void getStringValue2(zstring& val) const;
@@ -1021,9 +1019,9 @@
friend class UpdReplaceContent;
protected:
- store::Item_t theName;
+ store::Item_t theName;
#ifdef EMBEDED_TYPE
- store::Item_t theTypeName;
+ store::Item_t theTypeName;
#endif
protected:
@@ -1053,6 +1051,7 @@
// Item methods
//
size_t alloc_size() const;
+
size_t dynamic_size() const;
store::Item* getNodeName() const { return theName.getp(); }
@@ -1061,8 +1060,6 @@
void getTypedValue(store::Item_t& val, store::Iterator_t& iter) const;
- store::Item_t getAtomizationValue() const;
-
bool isId() const;
bool isIdRefs() const;
@@ -1143,18 +1140,15 @@
void removeLocalBinding(const zstring& prefix, const zstring& ns);
- bool addBindingForQName(
- store::Item_t& qname,
- bool isAttr,
- bool replacePrefix);
+ bool addBindingForQName(store::Item_t& qname, bool isAttr, bool replacePrefix);
void addBindingForQName2(const store::Item* qname);
+ void addBindingForNSNode(const zstring& prefix, const zstring& ns);
+
void checkNamespaceConflict(const store::Item* qname, const QueryLoc* loc) const;
- void uninheritBinding(
- NsBindingsContext* rootNSCtx,
- const zstring& prefix);
+ void uninheritBinding(NsBindingsContext* rootNSCtx, const zstring& prefix);
void checkUniqueAttr(const store::Item* attrName) const;
@@ -1262,8 +1256,6 @@
void appendStringValue(zstring& buf) const;
- store::Item_t getAtomizationValue() const;
-
bool isId() const;
bool isIdRefs() const;
@@ -1406,8 +1398,6 @@
void getTypedValue(store::Item_t& val, store::Iterator_t& iter) const;
- store::Item_t getAtomizationValue() const;
-
zstring getStringValue() const;
void getStringValue2(zstring& val) const;
@@ -1548,8 +1538,6 @@
void getTypedValue(store::Item_t& val, store::Iterator_t& iter) const;
- store::Item_t getAtomizationValue() const;
-
zstring getStringValue() const { return theContent; }
void getStringValue2(zstring& val) const { val = theContent; }
@@ -1617,8 +1605,6 @@
void getTypedValue(store::Item_t& val, store::Iterator_t& iter) const;
- store::Item_t getAtomizationValue() const;
-
zstring getStringValue() const { return theContent; }
void getStringValue2(zstring& val) const { val = theContent; }
@@ -1639,6 +1625,47 @@
};
+/*******************************************************************************
+
+********************************************************************************/
+class NamespaceNode : public XmlNode
+{
+ friend class XmlNode;
+ friend class NodeFactory;
+
+protected:
+ zstring thePrefix;
+ zstring theUri;
+
+protected:
+ NamespaceNode(XmlTree* tree, zstring& prefix, zstring& uri);
+
+public:
+ XmlNode* copyInternal(
+ InternalNode* rootParent,
+ InternalNode* parent,
+ csize pos,
+ const XmlNode* rootCopy,
+ const store::CopyMode& copymode) const;
+
+ store::Item* getType() const { return NULL; }
+
+ void getTypedValue(store::Item_t& val, store::Iterator_t& iter) const;
+
+ zstring getStringValue() const { return theUri; }
+
+ void getStringValue2(zstring& val) const { val = theUri; }
+
+ void appendStringValue(zstring& buf) const { buf += theUri; }
+
+ store::Item* getNodeName() const;
+
+ store::Iterator_t getChildren() const;
+
+ zstring show() const;
+};
+
+
#ifdef TEXT_ORDPATH
/*******************************************************************************
Do a doc-order comparison of "this" nodes and the "other" node. Return -1 if
=== modified file 'src/store/naive/simple_item_factory.cpp'
--- src/store/naive/simple_item_factory.cpp 2013-02-26 04:12:43 +0000
+++ src/store/naive/simple_item_factory.cpp 2013-03-06 11:14:46 +0000
@@ -2001,6 +2001,32 @@
/*******************************************************************************
********************************************************************************/
+bool BasicItemFactory::createNamespaceNode(
+ store::Item_t& result,
+ zstring& prefix,
+ zstring& uri)
+{
+ XmlTree* xmlTree = GET_NODE_FACTORY().createXmlTree();
+ NamespaceNode* n;
+
+ try
+ {
+ n = GET_NODE_FACTORY().createNamespaceNode(xmlTree, prefix, uri);
+ }
+ catch (...)
+ {
+ delete xmlTree;
+ throw;
+ }
+
+ result = n;
+ return true;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
store::PUL* BasicItemFactory::createPendingUpdateList()
{
return new PULImpl();
=== modified file 'src/store/naive/simple_item_factory.h'
--- src/store/naive/simple_item_factory.h 2013-02-26 04:12:43 +0000
+++ src/store/naive/simple_item_factory.h 2013-03-06 11:14:46 +0000
@@ -386,29 +386,33 @@
zstring& content);
bool createCommentNode (
- store::Item_t& result,
- store::Item* parent,
- ulong pos,
- zstring& content);
+ store::Item_t& result,
+ store::Item* parent,
+ ulong pos,
+ zstring& content);
+ bool createNamespaceNode (
+ store::Item_t& result,
+ zstring& prefix,
+ zstring& uri);
store::PUL* createPendingUpdateList();
bool createError(
- store::Item_t& result,
- ZorbaException* ze);
-
- bool createFunction(
- store::Item_t&,
- const store::Item_t&,
- const signature&,
- const store::Iterator_t&);
-
- bool createFunction(
- store::Item_t&,
- const std::vector<store::Iterator_t>&,
- const signature&,
- const store::Iterator_t&);
+ store::Item_t& result,
+ ZorbaException* ze);
+
+ bool createFunction(
+ store::Item_t&,
+ const store::Item_t&,
+ const signature&,
+ const store::Iterator_t&);
+
+ bool createFunction(
+ store::Item_t&,
+ const std::vector<store::Iterator_t>&,
+ const signature&,
+ const store::Iterator_t&);
#ifdef ZORBA_WITH_JSON
bool createJSONNull(store::Item_t& result);
=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp 2013-02-07 17:24:36 +0000
+++ src/types/casting.cpp 2013-03-06 11:14:46 +0000
@@ -2569,9 +2569,9 @@
{
cp = cps[i];
- if(!XQCharType::isLetter(cp) && !XQCharType::isDigit(cp) &&
- (cp != '.') && (cp != '-') && (cp != '_') &&
- !XQCharType::isCombiningChar(cp) && !XQCharType::isExtender(cp))
+ if (!XQCharType::isLetter(cp) && !XQCharType::isDigit(cp) &&
+ (cp != '.') && (cp != '-') && (cp != '_') &&
+ !XQCharType::isCombiningChar(cp) && !XQCharType::isExtender(cp))
return false;
}
=== modified file 'src/types/root_typemanager.cpp'
--- src/types/root_typemanager.cpp 2013-02-07 17:24:36 +0000
+++ src/types/root_typemanager.cpp 2013-03-06 11:14:46 +0000
@@ -544,6 +544,8 @@
NODE_TYPE_DEFN(COMMENT, store::StoreConsts::commentNode, STRING_TYPE_ONE);
+ NODE_TYPE_DEFN(NAMESPACE, store::StoreConsts::namespaceNode, ANY_URI_TYPE_ONE);
+
#undef NODE_TYPE_DEFN
}
=== modified file 'src/types/root_typemanager.h'
--- src/types/root_typemanager.h 2013-02-07 17:24:36 +0000
+++ src/types/root_typemanager.h 2013-03-06 11:14:46 +0000
@@ -177,7 +177,7 @@
* Pre-allocate XQType objects for the following KindTest sequence types:
*
* N(), N()?, N()+, N()*, where N is one of node, document-node, text, comment,
- * or processing-instruction.
+ * processing-instruction, or namespace-node.
*
* N(xs:untyped), N(xs:untyped)?, N(xs:untyped)+, N(xs:untyped)*, where N is
* one of node or document.
@@ -206,6 +206,7 @@
ALL_NODE_TYPE_DECL(DOCUMENT);
ALL_NODE_TYPE_DECL(ELEMENT);
ALL_NODE_TYPE_DECL(ATTRIBUTE);
+ ALL_NODE_TYPE_DECL(NAMESPACE);
ALL_NODE_TYPE_DECL(TEXT);
ALL_NODE_TYPE_DECL(PI);
ALL_NODE_TYPE_DECL(COMMENT);
=== modified file 'src/types/schema/XercesParseUtils.cpp'
--- src/types/schema/XercesParseUtils.cpp 2013-02-07 17:24:36 +0000
+++ src/types/schema/XercesParseUtils.cpp 2013-03-06 11:14:46 +0000
@@ -1297,9 +1297,8 @@
if (lIndex == 0)
{
- throw XQUERY_EXCEPTION(
- err::XQDY0074, ERROR_PARAMS( textValue.str() )
- );
+ throw XQUERY_EXCEPTION(err::XQDY0074,
+ ERROR_PARAMS(ZED(XQDY0074_NotCastToQName), textValue.str()));
}
else if ( lIndex > 0 )
{
@@ -1310,7 +1309,8 @@
return factory->createQName(result, lNamespace, lPrefix, lLocal);
}
- throw XQUERY_EXCEPTION( err::XQDY0074, ERROR_PARAMS( textValue.str() ) );
+ throw XQUERY_EXCEPTION(err::XQDY0074,
+ ERROR_PARAMS(ZED(XQDY0074_NotCastToQName), textValue.str()));
}
} // namespace zorba
=== modified file 'src/types/typeimpl.cpp'
--- src/types/typeimpl.cpp 2013-02-07 17:24:36 +0000
+++ src/types/typeimpl.cpp 2013-03-06 11:14:46 +0000
@@ -960,7 +960,7 @@
}
}
- // document-node( E ) matches any document node that contains exactly one element
+ // document-node(E) matches any document node that contains exactly one element
// node, optionally accompanied by one or more comment and processing instruction
// nodes, if E is an ElementTest or SchemaElementTest that matches the element node.
bool is_element_test = (
=== modified file 'src/types/typemanagerimpl.cpp'
--- src/types/typemanagerimpl.cpp 2013-02-07 17:24:36 +0000
+++ src/types/typemanagerimpl.cpp 2013-03-06 11:14:46 +0000
@@ -565,6 +565,7 @@
case store::StoreConsts::textNode:
case store::StoreConsts::commentNode:
+ case store::StoreConsts::namespaceNode:
return create_builtin_node_type(nodeKind, quant, true);
case store::StoreConsts::piNode:
@@ -701,6 +702,23 @@
}
}
+ case store::StoreConsts::namespaceNode:
+ {
+ switch(quantifier)
+ {
+ case TypeConstants::QUANT_ONE:
+ return GENV_TYPESYSTEM.NAMESPACE_TYPE_ONE;
+ case TypeConstants::QUANT_QUESTION:
+ return GENV_TYPESYSTEM.NAMESPACE_TYPE_QUESTION;
+ case TypeConstants::QUANT_STAR:
+ return GENV_TYPESYSTEM.NAMESPACE_TYPE_STAR;
+ case TypeConstants::QUANT_PLUS:
+ return GENV_TYPESYSTEM.NAMESPACE_TYPE_PLUS;
+ default:
+ ZORBA_ASSERT(false);
+ }
+ }
+
default:
ZORBA_ASSERT(false);
return GENV_TYPESYSTEM.NONE_TYPE;
@@ -793,6 +811,10 @@
{
return GENV_TYPESYSTEM.COMMENT_TYPE_ONE;
}
+ case store::StoreConsts::namespaceNode:
+ {
+ return GENV_TYPESYSTEM.NAMESPACE_TYPE_ONE;
+ }
default:
{
ZORBA_ASSERT(false);
@@ -1161,6 +1183,9 @@
case IdentTypes::COMMENT_TYPE:
return create_builtin_node_type(store::StoreConsts::commentNode, q, false);
+ case IdentTypes::NAMESPACE_TYPE:
+ return create_builtin_node_type(store::StoreConsts::namespaceNode, q, false);
+
case IdentTypes::ANY_NODE_TYPE:
return create_builtin_node_type(store::StoreConsts::anyNode, q, false);
=== modified file 'src/types/typeops.cpp'
--- src/types/typeops.cpp 2013-02-26 04:12:43 +0000
+++ src/types/typeops.cpp 2013-03-06 11:14:46 +0000
@@ -1322,6 +1322,9 @@
case store::StoreConsts::piNode:
return TypeIdentifier::createPIType(q);
+ case store::StoreConsts::namespaceNode:
+ return TypeIdentifier::createNamespaceType(q);
+
case store::StoreConsts::commentNode:
return TypeIdentifier::createCommentType(q);
@@ -1361,8 +1364,8 @@
if (nt.is_schema_test())
{
ZORBA_ASSERT(nodeName);
- String uri( Unmarshaller::newString( nodeName->getNamespace() ) );
- String local( Unmarshaller::newString( nodeName->getLocalName() ) );
+ String uri( Unmarshaller::newString(nodeName->getNamespace()));
+ String local( Unmarshaller::newString(nodeName->getLocalName()));
return TypeIdentifier::createSchemaAttributeType(uri, local, q);
}
=== modified file 'src/zorbaserialization/archiver_consts.h'
--- src/zorbaserialization/archiver_consts.h 2013-02-07 17:24:36 +0000
+++ src/zorbaserialization/archiver_consts.h 2013-03-06 11:14:46 +0000
@@ -316,6 +316,8 @@
TYPE_FnAdjustToTimeZoneIterator_2,
TYPE_FnAdjustToTimeZoneIterator_1,
+ TYPE_NamespaceIterator,
+
TYPE_FunctionItem,
TYPE_namespace_context,
=== modified file 'src/zorbautils/properties_base.cpp'
--- src/zorbautils/properties_base.cpp 2013-02-07 17:24:36 +0000
+++ src/zorbautils/properties_base.cpp 2013-03-06 11:14:46 +0000
@@ -60,11 +60,21 @@
if (line.size() == 0 || line[0] == '#')
continue;
+ size_t i = 0;
+ for (; i < line.size(); ++i)
+ {
+ if (!isspace(line[i]))
+ break;
+ }
+
+ if (i == line.size())
+ continue;
+
++nargs;
char* str = new char[line.size() + 3];
- str [0] = str[1] = '-';
+ str[0] = str[1] = '-';
memcpy(str + 2, line.data(), line.size());
=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt 2013-02-28 07:01:30 +0000
+++ test/fots/CMakeLists.txt 2013-03-06 11:14:46 +0000
@@ -633,7 +633,6 @@
EXPECTED_FOTS_FAILURE (prod-CompAttrConstructor K2-ComputeConAttr-58 0)
EXPECTED_FOTS_FAILURE (prod-CompDocConstructor K2-ConDocNode-2 0)
EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-001 0)
-EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-002 0)
EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-003 0)
EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-004 0)
EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-005 0)
@@ -641,8 +640,6 @@
EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-010 0)
EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-011 0)
EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-012 0)
-EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-013 0)
-EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-014 0)
EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-015 0)
EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-022 0)
EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-027 0)
=== modified file 'test/fots_driver/fots-driver.xq'
--- test/fots_driver/fots-driver.xq 2013-02-28 11:15:32 +0000
+++ test/fots_driver/fots-driver.xq 2013-03-06 11:14:46 +0000
@@ -792,7 +792,10 @@
try
{
{
- variable $queryName := trace(data($case/@name), "processing test case :");
+ variable $trace := concat("processing test case : ", $case/@name,
+ " in test set : ", $testSetName);
+
+ variable $queryName := trace($trace, "");
variable $test as xs:string := util:get-value($case, $testSetBaseURI, "test");
Follow ups
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-07
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: noreply, 2013-03-07
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-07
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Markos Zaharioudakis, 2013-03-07
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-07
-
Re: [Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-07
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-07
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Markos Zaharioudakis, 2013-03-07
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-07
-
Re: [Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-07
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-07
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Markos Zaharioudakis, 2013-03-07
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-06
-
Re: [Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-06
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-06
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Markos Zaharioudakis, 2013-03-06
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-06
-
Re: [Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-06
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Zorba Build Bot, 2013-03-06
-
[Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Markos Zaharioudakis, 2013-03-06
-
Re: [Merge] lp:~zorba-coders/zorba/ns-nodes into lp:zorba
From: Markos Zaharioudakis, 2013-03-06