zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #21177
[Merge] lp:~zorba-coders/zorba/bug1147563 into lp:zorba
Sorin Marian Nasoi has proposed merging lp:~zorba-coders/zorba/bug1147563 into lp:zorba.
Requested reviews:
Chris Hillery (ceejatec)
Sorin Marian Nasoi (sorin.marian.nasoi)
Cezar Andrei (cezar-andrei)
Markos Zaharioudakis (markos-za)
Related bugs:
Bug #1147563 in Zorba: "fn:nilled failures (at least 23)"
https://bugs.launchpad.net/zorba/+bug/1147563
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug1147563/+merge/160838
Fixes for nilled function
--
https://code.launchpad.net/~zorba-coders/zorba/bug1147563/+merge/160838
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2013-04-25 02:37:42 +0000
+++ ChangeLog 2013-04-25 09:51:29 +0000
@@ -49,6 +49,8 @@
* Fixed bug #1124273 (xqdoc crash because of annotation literals)
* Fixed bug #1085408 (xs:date(): casting large year values)
* Fixed bug #867027 (XQST0059 error messages inconsistent)
+ * Fixed fn:nilled function
+ * Fixed bug concerning nillability during sequnce type matching.
* Fixed bug #1095889 (Improve error message for xml-parsing error).
* Fixed bug #1131984 (apparently invalid regex in queries)
* Fixed bug #1123163 (fn:format-integer failures)
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2013-04-24 03:54:58 +0000
+++ src/compiler/translator/translator.cpp 2013-04-25 09:51:29 +0000
@@ -293,9 +293,13 @@
{
public:
CompilerCB * theCCB;
+
hashmap<zstring, static_context_t> mod_sctx_map;
+
hashmap<zstring, zstring> mod_ns_map;
- checked_vector<expr*> theInitExprs;
+
+ checked_vector<expr*> theInitExprs;
+
std::auto_ptr<static_context> globalSctx;
public:
@@ -14129,13 +14133,15 @@
if (axisExpr != NULL)
{
+ bool nillable;
store::Item_t typeQNameItem;
- CTX_TM->get_schema_element_typename(elemQNameItem, typeQNameItem, loc);
+ CTX_TM->get_schema_element_typeinfo(elemQNameItem, typeQNameItem, nillable, loc);
match_expr* match = theExprManager->create_match_expr(theRootSctx, theUDF, loc);
match->setTestKind(match_xs_elem_test);
match->setQName(elemQNameItem);
match->setTypeName(typeQNameItem);
+ match->setNilledAllowed(nillable);
axisExpr->setTest(match);
}
@@ -14253,7 +14259,7 @@
if (axisExpr != NULL)
{
store::Item_t typeQNameItem;
- CTX_TM->get_schema_attribute_typename(attrQNameItem, typeQNameItem, loc);
+ CTX_TM->get_schema_attribute_typeinfo(attrQNameItem, typeQNameItem, loc);
match_expr* match = theExprManager->create_match_expr(theRootSctx, theUDF, loc);
match->setTestKind(match_xs_attr_test);
=== modified file 'src/runtime/accessors/accessors_impl.cpp'
--- src/runtime/accessors/accessors_impl.cpp 2013-03-15 08:22:41 +0000
+++ src/runtime/accessors/accessors_impl.cpp 2013-04-25 09:51:29 +0000
@@ -105,8 +105,15 @@
{
if (inNode->isNode())
{
- result = inNode->getNilled();
- STACK_PUSH(result != NULL, state);
+ if (inNode->getNodeKind() == store::StoreConsts::elementNode)
+ {
+ GENV_ITEMFACTORY->createBoolean(result, inNode->getNilled());
+ STACK_PUSH(true, state);
+ }
+ else
+ {
+ STACK_PUSH(false, state);
+ }
}
else
{
@@ -240,6 +247,8 @@
}
state->theTypedValueIter = 0; // TODO remove???
+
+ done:
STACK_END(state);
}
=== modified file 'src/runtime/core/path_iterators.cpp'
--- src/runtime/core/path_iterators.cpp 2013-04-08 15:07:13 +0000
+++ src/runtime/core/path_iterators.cpp 2013-04-25 09:51:29 +0000
@@ -313,7 +313,7 @@
if ((!TypeOps::is_subtype(sctx->get_typemanager(), *atype, *theType)) ||
(theNilledAllowed == false &&
- node->getNilled()->getBooleanValue() == true))
+ node->getNilled() == true))
{
return false;
}
@@ -338,7 +338,7 @@
if ((!TypeOps::is_subtype(sctx->get_typemanager(), *atype, *theType)) ||
(theNilledAllowed == false &&
- node->getNilled()->getBooleanValue() == true))
+ node->getNilled() == true))
return false;
return true;
=== modified file 'src/runtime/core/sequencetypes.cpp'
--- src/runtime/core/sequencetypes.cpp 2013-04-18 08:47:43 +0000
+++ src/runtime/core/sequencetypes.cpp 2013-04-25 09:51:29 +0000
@@ -84,7 +84,7 @@
store::Item_t item;
TypeConstants::quantifier_t quant;
bool res = false;
-
+ store::Item_t temp;
const TypeManager* tm = theSctx->get_typemanager();
PlanIteratorState* state;
=== modified file 'src/runtime/visitors/printer_visitor_impl.cpp'
--- src/runtime/visitors/printer_visitor_impl.cpp 2013-03-27 07:55:14 +0000
+++ src/runtime/visitors/printer_visitor_impl.cpp 2013-04-25 09:51:29 +0000
@@ -208,21 +208,6 @@
thePrinter.endEndVisit();
}
-void PrinterVisitor::beginVisit ( const TreatIterator& a )
-{
- thePrinter.startBeginVisit("TreatIterator", ++theId);
- if (a.theCheckPrime)
- thePrinter.addAttribute("type", a.theTreatType->toString());
- thePrinter.addAttribute("quant", TypeOps::decode_quantifier(a.theQuantifier));
- printCommons( &a, theId );
- thePrinter.endBeginVisit(theId);
-}
-
-void PrinterVisitor::endVisit ( const TreatIterator& )
-{
- thePrinter.startEndVisit();
- thePrinter.endEndVisit();
-}
void PrinterVisitor::beginVisit ( const NumArithIterator<AddOperation>& a )
{
@@ -1176,6 +1161,7 @@
thePrinter.endEndVisit();
}
+
void PrinterVisitor::beginVisit(const PromoteIterator& a)
{
thePrinter.startBeginVisit("PromoteIterator", ++theId);
@@ -1192,6 +1178,24 @@
thePrinter.endEndVisit();
}
+
+void PrinterVisitor::beginVisit ( const TreatIterator& a )
+{
+ thePrinter.startBeginVisit("TreatIterator", ++theId);
+ if (a.theCheckPrime)
+ thePrinter.addAttribute("type", a.theTreatType->toString());
+ thePrinter.addAttribute("quant", TypeOps::decode_quantifier(a.theQuantifier));
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit(theId);
+}
+
+void PrinterVisitor::endVisit ( const TreatIterator& )
+{
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+
+
void PrinterVisitor::beginVisit(const CastableIterator& a)
{
thePrinter.startBeginVisit("CastableIterator", ++theId);
=== modified file 'src/store/api/item.h'
--- src/store/api/item.h 2013-04-08 00:44:26 +0000
+++ src/store/api/item.h 2013-04-25 09:51:29 +0000
@@ -674,7 +674,7 @@
/** Accessor for element node
* @return boolean?
*/
- virtual Item_t
+ virtual bool
getNilled() const;
/** Accessor for document node, element node, attribute node, namespace node,
=== modified file 'src/store/naive/item.cpp'
--- src/store/naive/item.cpp 2013-04-08 00:44:26 +0000
+++ src/store/naive/item.cpp 2013-04-25 09:51:29 +0000
@@ -976,7 +976,7 @@
}
-store::Item_t Item::getNilled() const
+bool Item::getNilled() const
{
throw ZORBA_EXCEPTION(
zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp 2013-04-17 12:37:36 +0000
+++ src/store/naive/node_items.cpp 2013-04-25 09:51:29 +0000
@@ -2968,6 +2968,17 @@
{
zstring rch;
getStringValue2(rch);
+
+ if (rch.empty())
+ {
+ if (getNilled())
+ {
+ val = NULL;
+ iter = NULL;
+ return;
+ }
+ }
+
GET_FACTORY().createUntypedAtomic(val, rch);
}
}
@@ -3048,17 +3059,15 @@
/*******************************************************************************
********************************************************************************/
-store::Item_t ElementNode::getNilled() const
+bool ElementNode::getNilled() const
{
store::Item_t val;
if (getType()->equals(GET_STORE().XS_UNTYPED_QNAME))
- {
- GET_FACTORY().createBoolean(val, false);
- return val;
- }
+ return false;
- bool nilled = true;
+ if (!isValidated())
+ return false;
const_iterator ite = childrenBegin();
const_iterator end = childrenEnd();
@@ -3068,38 +3077,31 @@
if ((*ite)->getNodeKind() == store::StoreConsts::elementNode ||
(*ite)->getNodeKind() == store::StoreConsts::textNode)
{
- nilled = false;
- break;
+ return false;
}
}
- if (!nilled)
- {
- GET_FACTORY().createBoolean(val, false);
- return val;
- }
-
- nilled = false;
-
- //const char* xsi = "http://www.w3.org/2001/XMLSchema-instance";
- //ulong xsilen = strlen(xsi);
-
ite = attrsBegin();
end = attrsEnd();
for (; ite != end; ++ite)
{
XmlNode* attr = *ite;
- if (ZSTREQ(attr->getNodeName()->getNamespace(), "xsi") &&
- ZSTREQ(attr->getNodeName()->getLocalName(), "nil"))
+
+ zstring strval;
+ attr->getStringValue2(strval);
+
+ if (ZSTREQ(attr->getNodeName()->getNamespace(),
+ "http://www.w3.org/2001/XMLSchema-instance") &&
+ ZSTREQ(attr->getNodeName()->getLocalName(), "nil") &&
+ (ZSTREQ(strval, "true") || ZSTREQ(strval, "1") ))
{
- nilled = true;
+ return true;
break;
}
}
- GET_FACTORY().createBoolean(val, nilled);
- return val;
+ return false;
}
=== modified file 'src/store/naive/node_items.h'
--- src/store/naive/node_items.h 2013-03-07 10:10:10 +0000
+++ src/store/naive/node_items.h 2013-04-25 09:51:29 +0000
@@ -500,12 +500,6 @@
store::Item* copy(store::Item* parent, const store::CopyMode& copymode) const;
- virtual store::Item_t getNilled() const
- {
- assert(!isConnectorNode());
- return 0;
- }
-
virtual bool isId() const
{
assert(!isConnectorNode());
@@ -1072,7 +1066,7 @@
void appendStringValue(zstring& buf) const;
- store::Item_t getNilled() const;
+ bool getNilled() const;
store::Iterator_t getAttributes() const;
=== modified file 'src/types/root_typemanager.cpp'
--- src/types/root_typemanager.cpp 2013-03-20 18:39:54 +0000
+++ src/types/root_typemanager.cpp 2013-04-25 09:51:29 +0000
@@ -386,18 +386,21 @@
#undef ATOMIC_TYPE_DEFN
XS_NMTOKENS_TYPE = new UserDefinedXQType(this,
+ false,
XS_NMTOKENS_QNAME,
NULL,
NMTOKEN_TYPE_ONE.getp(),
true);
XS_ENTITIES_TYPE = new UserDefinedXQType(this,
+ false,
XS_ENTITIES_QNAME,
NULL,
ENTITY_TYPE_ONE.getp(),
true);
XS_IDREFS_TYPE = new UserDefinedXQType(this,
+ false,
XS_IDREFS_QNAME,
NULL,
IDREF_TYPE_ONE.getp(),
=== modified file 'src/types/schema/schema.cpp'
--- src/types/schema/schema.cpp 2013-04-16 21:12:12 +0000
+++ src/types/schema/schema.cpp 2013-04-25 09:51:29 +0000
@@ -259,7 +259,8 @@
return lRetval;
}
- else {
+ else
+ {
// We didn't find it. If we return NULL here, Xerces will try to
// resolve it its own way, which we don't want to happen.
throw XQUERY_EXCEPTION(
@@ -271,7 +272,8 @@
);
}
}
- catch (ZorbaException const& e) {
+ catch (ZorbaException const& e)
+ {
TRACE("!!! ZorbaException: " << e );
if ( e.diagnostic() == zerr::ZXQP0029_URI_ACCESS_DENIED ||
e.diagnostic() == err::XQST0059 )
@@ -518,82 +520,71 @@
/*******************************************************************************
- For the given element name find out its declared schema type
+ Find a global element declaration for a given element name and return the name
+ of the associated schema type and whether the element can be nillable.
+ Raise an error if no global element declaration is found for the given name.
*******************************************************************************/
-void Schema::getTypeNameFromElementName(
+void Schema::getInfoFromGlobalElementDecl(
const store::Item* qname,
store::Item_t& typeName,
+ bool& nillable,
const QueryLoc& loc)
{
- XSTypeDefinition* typeDef = getTypeDefForElement(qname);
+ XSElementDeclaration* decl = getDeclForElement(qname);
- if (!typeDef)
+ if (!decl)
{
RAISE_ERROR(err::XPST0008, loc,
ERROR_PARAMS(ZED(XPST0008_SchemaElementName_2), qname->getStringValue()));
}
- const XMLCh* typeNameStr = typeDef->getName();
- const XMLCh* typeUri = typeDef->getNamespace();
-
- GENV_ITEMFACTORY->createQName(typeName,
- StrX(typeUri).localForm(),
- "",
- StrX(typeNameStr).localForm());
-}
-
-
-/*******************************************************************************
- For a given global attribute find out its declared schema type
-*******************************************************************************/
-void Schema::getTypeNameFromAttributeName(
- const store::Item* qname,
- store::Item_t& typeName,
- const QueryLoc& loc)
-{
- XSTypeDefinition* typeDef = getTypeDefForAttribute(qname);
-
- if (!typeDef)
- {
- RAISE_ERROR(err::XPST0008, loc,
- ERROR_PARAMS(ZED(XPST0008_SchemaAttributeName_2), qname->getStringValue()));
- }
-
- const XMLCh* typeNameStr = typeDef->getName();
- const XMLCh* typeUri = typeDef->getNamespace();
-
- GENV_ITEMFACTORY->createQName(typeName,
- StrX(typeUri).localForm(),
- "",
- StrX(typeNameStr).localForm());
-}
-
-
-/*******************************************************************************
- Returns an XQType for a global schema element definition if defined,
- otherwise NULL
-*******************************************************************************/
-xqtref_t Schema::createXQTypeFromElementName(
+ XSTypeDefinition* typeDef = decl->getTypeDefinition();
+
+ const XMLCh* typeNameStr = typeDef->getName();
+ const XMLCh* typeUri = typeDef->getNamespace();
+
+ GENV_ITEMFACTORY->createQName(typeName,
+ StrX(typeUri).localForm(),
+ "",
+ StrX(typeNameStr).localForm());
+
+ nillable = decl->getNillable();
+}
+
+
+/*******************************************************************************
+ Find a global element declaration for a given element name and return an
+ XQType for the associated schema type and whether the element can be nillable.
+ Raise an error if the raiseErrors param is true and no global element
+ declaration is found for the given name.
+*******************************************************************************/
+xqtref_t Schema::createXQTypeFromGlobalElementDecl(
const TypeManager* typeManager,
const store::Item* qname,
- const bool riseErrors,
+ const bool raiseErrors,
+ bool& nillable,
const QueryLoc& loc)
{
TRACE("qn:" << qname->getLocalName() << " @ " <<
qname->getNamespace() );
- XSTypeDefinition* typeDef = getTypeDefForElement(qname);
+ XSElementDeclaration* decl = getDeclForElement(qname);
- if (!riseErrors && !typeDef)
+ if (!raiseErrors && !decl)
return NULL;
- if (!typeDef)
+ if (!decl)
{
RAISE_ERROR(err::XPST0008, loc,
ERROR_PARAMS(ZED(XPST0008_SchemaElementName_2), qname->getStringValue()));
}
+ nillable = decl->getNillable();
+
+ XSTypeDefinition* typeDef = decl->getTypeDefinition();
+
xqtref_t res = createXQTypeFromTypeDefinition(typeManager, typeDef);
+
TRACE("res:" << res->get_qname()->getLocalName() << " @ " <<
res->get_qname()->getNamespace());
@@ -602,18 +593,46 @@
/*******************************************************************************
+ Find a global attribute declaration for a given attribute name and return the
+ name of the associated schema type. Raise an error if no global attribute
+ declaration is found for the given name.
+*******************************************************************************/
+void Schema::getInfoFromGlobalAttributeDecl(
+ const store::Item* qname,
+ store::Item_t& typeName,
+ const QueryLoc& loc)
+{
+ XSTypeDefinition* typeDef = getTypeDefForAttribute(qname);
+
+ if (!typeDef)
+ {
+ RAISE_ERROR(err::XPST0008, loc,
+ ERROR_PARAMS(ZED(XPST0008_SchemaAttributeName_2), qname->getStringValue()));
+ }
+
+ const XMLCh* typeNameStr = typeDef->getName();
+ const XMLCh* typeUri = typeDef->getNamespace();
+
+ GENV_ITEMFACTORY->createQName(typeName,
+ StrX(typeUri).localForm(),
+ "",
+ StrX(typeNameStr).localForm());
+}
+
+
+/*******************************************************************************
Returns an XQType for a global schema attribute definition if defined,
otherwise NULL
*******************************************************************************/
-xqtref_t Schema::createXQTypeFromAttributeName(
+xqtref_t Schema::createXQTypeFromGlobalAttributeDecl(
const TypeManager* typeManager,
const store::Item* qname,
- const bool riseErrors,
+ const bool raiseErrors,
const QueryLoc& loc)
{
XSTypeDefinition* typeDef = getTypeDefForAttribute(qname);
- if (!riseErrors && !typeDef)
+ if (!raiseErrors && !typeDef)
return NULL;
if (!typeDef)
@@ -744,12 +763,10 @@
/*******************************************************************************
- Get the type definition for a globally declared element
+ Get the declaration for a globally declared element
*******************************************************************************/
-XSTypeDefinition* Schema::getTypeDefForElement(const store::Item* qname)
+XSElementDeclaration* Schema::getDeclForElement(const store::Item* qname)
{
- XSTypeDefinition* typeDef = NULL;
-
TRACE(" element qname: " << qname->getLocalName() << "@" <<
qname->getNamespace());
@@ -762,25 +779,7 @@
bool xsModelWasChanged;
XSModel* model = theGrammarPool->getXSModel(xsModelWasChanged);
- XSElementDeclaration* decl = model->getElementDeclaration(local, uri);
-
- if (decl)
- {
- typeDef = decl->getTypeDefinition();
-
- // this works only on the element that is a substitution,
- // not on substitution base element
- //XSElementDeclaration * substGroup =
- // decl->getSubstitutionGroupAffiliation();
-
- //if ( substGroup )
- //{
- // TRACE(" substitutionGroup qname: " << StrX(substGroup->getName()) <<
- // "@" << StrX(substGroup->getNamespace()) << "\n");
- //}
- }
-
- return typeDef;
+ return model->getElementDeclaration(local, uri);
}
@@ -868,6 +867,7 @@
xqtref_t baseXQType = createXQTypeFromTypeDefinition(tm, baseTypeDef);
xqtref_t xqType = new UserDefinedXQType(tm,
+ xsTypeDef->getAnonymous(),
qname,
baseXQType,
TypeConstants::QUANT_ONE,
@@ -903,6 +903,7 @@
// << endl; cout.flush();
xqtref_t xqType = new UserDefinedXQType(tm,
+ xsTypeDef->getAnonymous(),
qname,
NULL,
itemXQType.getp());
@@ -958,6 +959,7 @@
//std::cout << std::endl; std::cout.flush();
xqtref_t xqType = new UserDefinedXQType(tm,
+ xsTypeDef->getAnonymous(),
qname,
baseXQType,
TypeConstants::QUANT_ONE,
@@ -1059,6 +1061,7 @@
}
xqtref_t xqType = new UserDefinedXQType(tm,
+ xsTypeDef->getAnonymous(),
qname,
baseXQType,
TypeConstants::QUANT_ONE,
@@ -1310,9 +1313,10 @@
bool xsModelWasChanged;
XSModel* model = theGrammarPool->getXSModel(xsModelWasChanged);
- XSNamedMap<XSObject> * typeDefs =
- model->getComponents(XSConstants::TYPE_DEFINITION);
- for( uint i = 0; i<typeDefs->getLength(); i++)
+ XSNamedMap<XSObject>* typeDefs =
+ model->getComponents(XSConstants::TYPE_DEFINITION);
+
+ for( uint i = 0; i < typeDefs->getLength(); i++)
{
XSTypeDefinition* typeDef = (XSTypeDefinition*)(typeDefs->item(i));
checkForAnonymousTypesInType(typeManager, typeDef);
@@ -1529,6 +1533,7 @@
xqtref_t xqType =
xqtref_t(new UserDefinedXQType(typeManager,
+ xsTypeDef->getAnonymous(),
qname,
baseXQType,
TypeConstants::QUANT_ONE,
=== modified file 'src/types/schema/schema.h'
--- src/types/schema/schema.h 2013-02-07 17:24:36 +0000
+++ src/types/schema/schema.h 2013-04-25 09:51:29 +0000
@@ -43,6 +43,7 @@
namespace XERCES_CPP_NAMESPACE {
class InputSource;
class XSTypeDefinition;
+ class XSElementDeclaration;
class XSParticle;
class XMLGrammarPool;
}
@@ -106,31 +107,33 @@
void registerXSD(
const char* xsdURL,
- static_context * aSctx,
- internal::StreamResource* aStreamResource,
+ static_context* sctx,
+ internal::StreamResource* streamResource,
const QueryLoc& loc);
void getSubstitutionHeadForElement(
const store::Item* qname,
store::Item_t& result);
- void getTypeNameFromElementName(
- const store::Item* qname,
- store::Item_t& typeName,
- const QueryLoc& loc);
-
- void getTypeNameFromAttributeName(
- const store::Item* qname,
- store::Item_t& typeName,
- const QueryLoc& loc);
-
- xqtref_t createXQTypeFromElementName(
+ void getInfoFromGlobalElementDecl(
+ const store::Item* qname,
+ store::Item_t& typeName,
+ bool& nillable,
+ const QueryLoc& loc);
+
+ xqtref_t createXQTypeFromGlobalElementDecl(
const TypeManager* typeManager,
const store::Item* qname,
- const bool riseErrors,
- const QueryLoc& loc);
-
- xqtref_t createXQTypeFromAttributeName(
+ const bool raiseErrors,
+ bool& nillable,
+ const QueryLoc& loc);
+
+ void getInfoFromGlobalAttributeDecl(
+ const store::Item* qname,
+ store::Item_t& typeName,
+ const QueryLoc& loc);
+
+ xqtref_t createXQTypeFromGlobalAttributeDecl(
const TypeManager* typeManager,
const store::Item* qname,
const bool riseErrors,
@@ -194,11 +197,11 @@
private:
#ifndef ZORBA_NO_XMLSCHEMA
- XERCES_CPP_NAMESPACE::XSTypeDefinition*
- getTypeDefForElement(const store::Item* qname);
+ XERCES_CPP_NAMESPACE::XSElementDeclaration* getDeclForElement(
+ const store::Item* qname);
- XERCES_CPP_NAMESPACE::XSTypeDefinition*
- getTypeDefForAttribute(const store::Item* qname);
+ XERCES_CPP_NAMESPACE::XSTypeDefinition* getTypeDefForAttribute(
+ const store::Item* qname);
xqtref_t createXQTypeFromTypeDefinition(
const TypeManager* typeManager,
=== modified file 'src/types/schema/validate.cpp'
--- src/types/schema/validate.cpp 2013-02-07 17:24:36 +0000
+++ src/types/schema/validate.cpp 2013-04-25 09:51:29 +0000
@@ -193,20 +193,22 @@
{
schemaValidator.startDoc();
- // ask for the type of the root element to populate
- // the cache with anonymous types
store::Iterator_t children = sourceNode->getChildren();
store::Item_t child;
while ( children->next(child) )
{
+ // ask for the type of the element. We don't really need this type here,
+ // but a side-effect of this call is to add the type to the cache.
if ( child->isNode() &&
child->getNodeKind()==store::StoreConsts::elementNode )
{
+ bool nillable;
typeManager->getSchema()->
- createXQTypeFromElementName(typeManager,
- child->getNodeName(),
- false,
- loc);
+ createXQTypeFromGlobalElementDecl(typeManager,
+ child->getNodeName(),
+ false,
+ nillable,
+ loc);
break;
}
}
@@ -259,13 +261,15 @@
//cout << "Validate element" << "\n"; cout.flush();
schemaValidator.startDoc();
- // ask for the type of the root element to populate the cache
- // with anonymous types
+ // ask for the type of the element. We don't really need this type here,
+ // but a side-effect of this call is to add the type to the cache.
+ bool nillable;
typeManager->getSchema()->
- createXQTypeFromElementName(typeManager,
- sourceNode->getNodeName(),
- false,
- loc);
+ createXQTypeFromGlobalElementDecl(typeManager,
+ sourceNode->getNodeName(),
+ false,
+ nillable,
+ loc);
}
store::Item_t newElem = processElement(sctx,
=== modified file 'src/types/typeimpl.cpp'
--- src/types/typeimpl.cpp 2013-03-22 00:38:18 +0000
+++ src/types/typeimpl.cpp 2013-04-25 09:51:29 +0000
@@ -29,6 +29,7 @@
#include "zorbaserialization/serialize_template_types.h"
#include "zorbaserialization/serialize_zorba_types.h"
+#include "store/api/iterator.h"
namespace zorba
{
@@ -718,11 +719,11 @@
bool builtin)
:
XQType(manager, NODE_TYPE_KIND, quantifier, builtin),
- m_node_kind(nodeKind),
- m_node_name(nodeName),
+ theNodeKind(nodeKind),
+ theNodeName(nodeName),
theContentType(contentType),
- m_nillable(nillable),
- m_schema_test(schematest)
+ theNillable(nillable),
+ theIsSchemaTest(schematest)
{
assert(contentType == NULL ||
(nodeKind == store::StoreConsts::documentNode &&
@@ -754,11 +755,11 @@
TypeConstants::quantifier_t quantifier)
:
XQType(source.theManager, NODE_TYPE_KIND, quantifier, false),
- m_node_kind(source.m_node_kind),
- m_node_name(source.m_node_name),
+ theNodeKind(source.theNodeKind),
+ theNodeName(source.theNodeName),
theContentType(source.theContentType),
- m_nillable(source.m_nillable),
- m_schema_test(source.m_schema_test)
+ theNillable(source.theNillable),
+ theIsSchemaTest(source.theIsSchemaTest)
{
}
@@ -769,11 +770,11 @@
void NodeXQType::serialize(::zorba::serialization::Archiver& ar)
{
serialize_baseclass(ar, (XQType*)this);
- SERIALIZE_ENUM(store::StoreConsts::NodeKind, m_node_kind);
- ar & m_node_name;
+ SERIALIZE_ENUM(store::StoreConsts::NodeKind, theNodeKind);
+ ar & theNodeName;
ar & theContentType;
- ar & m_nillable;
- ar & m_schema_test;
+ ar & theNillable;
+ ar & theIsSchemaTest;
}
@@ -791,15 +792,15 @@
********************************************************************************/
bool NodeXQType::is_equal(const TypeManager* tm, const NodeXQType& other) const
{
- if (m_node_kind != other.m_node_kind)
+ if (theNodeKind != other.theNodeKind)
return false;
- if (m_node_name != other.m_node_name)
+ if (theNodeName != other.theNodeName)
{
- if (m_node_name == NULL || other.m_node_name == NULL)
+ if (theNodeName == NULL || other.theNodeName == NULL)
return false;
- if (!m_node_name->equals(other.m_node_name))
+ if (!theNodeName->equals(other.theNodeName))
return false;
}
@@ -829,7 +830,7 @@
const NodeXQType& supertype,
const QueryLoc& loc) const
{
- if (supertype.m_node_kind == store::StoreConsts::anyNode)
+ if (supertype.theNodeKind == store::StoreConsts::anyNode)
{
if (supertype.theContentType != NULL &&
supertype.theContentType->type_kind() == XQType::UNTYPED_KIND)
@@ -841,17 +842,17 @@
return true;
}
- if (supertype.m_node_kind != m_node_kind)
+ if (supertype.theNodeKind != theNodeKind)
return false;
- if (supertype.m_node_name != NULL)
+ if (supertype.theNodeName != NULL)
{
- if (m_node_name == NULL)
+ if (theNodeName == NULL)
return false;
- if (!m_node_name->equals(supertype.m_node_name))
+ if (!theNodeName->equals(supertype.theNodeName))
{
- if (supertype.m_schema_test)
+ if (supertype.theIsSchemaTest)
{
Schema* schema = supertype.theManager->getSchema();
ZORBA_ASSERT(schema != NULL);
@@ -859,11 +860,11 @@
store::Item_t headName;
#ifndef ZORBA_NO_XMLSCHEMA
- schema->getSubstitutionHeadForElement(m_node_name.getp(), headName);
+ schema->getSubstitutionHeadForElement(theNodeName.getp(), headName);
while (headName != NULL)
{
- if (headName->equals(supertype.m_node_name))
+ if (headName->equals(supertype.theNodeName))
{
break;
}
@@ -883,10 +884,18 @@
}
if (theContentType == supertype.theContentType)
+ {
+ if (supertype.theNillable == false && theNillable == true)
+ return false;
+
return true;
+ }
if (theContentType != NULL && supertype.theContentType != NULL)
{
+ if (supertype.theNillable == false && theNillable == true)
+ return false;
+
return TypeOps::is_subtype(tm, *theContentType, *supertype.theContentType);
}
else if (supertype.theContentType == NULL)
@@ -912,7 +921,7 @@
{
assert(subitem->isNode());
- if (m_node_kind == store::StoreConsts::anyNode)
+ if (theNodeKind == store::StoreConsts::anyNode)
{
if (theContentType != NULL &&
theContentType->type_kind() == XQType::UNTYPED_KIND)
@@ -923,74 +932,152 @@
return true;
}
- if (m_node_kind != subitem->getNodeKind())
+ if (theNodeKind != subitem->getNodeKind())
return false;
- if (m_node_name != NULL)
- {
- if (!subitem->getNodeName()->equals(m_node_name))
- {
- if (m_schema_test)
+ switch (theNodeKind)
+ {
+ case store::StoreConsts::textNode:
+ case store::StoreConsts::commentNode:
+ case store::StoreConsts::namespaceNode:
+ {
+ return true;
+ }
+ case store::StoreConsts::piNode:
+ {
+ if (theNodeName != NULL && !subitem->getNodeName()->equals(theNodeName))
+ return false;
+
+ return true;
+ }
+ case store::StoreConsts::attributeNode:
+ {
+ assert(!theIsSchemaTest || (theNodeName && theContentType));
+
+ if (theNodeName != NULL && !subitem->getNodeName()->equals(theNodeName))
+ return false;
+
+ if (theContentType != NULL)
+ {
+ xqtref_t subContentType =
+ tm->create_named_type(subitem->getType(), TypeConstants::QUANT_ONE, loc, true);
+
+ return TypeOps::is_subtype(tm, *subContentType, *theContentType);
+ }
+
+ return true;
+ }
+ case store::StoreConsts::elementNode:
+ {
+ if (theIsSchemaTest)
+ {
+ assert(theNodeName != NULL);
+
+ if (!subitem->getNodeName()->equals(theNodeName))
{
Schema* schema = theManager->getSchema();
ZORBA_ASSERT(schema != NULL);
-
+
store::Item_t headName;
-
+
#ifndef ZORBA_NO_XMLSCHEMA
schema->getSubstitutionHeadForElement(subitem->getNodeName(), headName);
-
+
while (headName != NULL)
{
- if (headName->equals(m_node_name))
- {
+ if (headName->equals(theNodeName))
break;
- }
-
+
schema->getSubstitutionHeadForElement(headName.getp(), headName);
}
#endif // ZORBA_NO_XMLSCHEMA
-
+
if (headName == NULL)
return false;
}
- else
+
+ if (theContentType == NULL ||
+ theContentType->type_kind() == XQType::ANY_TYPE_KIND)
+ return true;
+
+ xqtref_t subContentType = tm->create_named_type(subitem->getType(),
+ TypeConstants::QUANT_ONE,
+ loc,
+ true);
+
+ if (!TypeOps::is_subtype(tm, *subContentType, *theContentType))
+ return false;
+
+ bool nillable;
+ store::Item_t typeName;
+ tm->get_schema_element_typeinfo(subitem->getNodeName(), typeName, nillable, loc);
+
+ if (!nillable && subitem->getNilled())
+ return false;
+
+ return true;
+ }
+ else
+ {
+ if (theNodeName != NULL && !subitem->getNodeName()->equals(theNodeName))
+ return false;
+
+ if (!theNillable && subitem->getNilled())
+ return false;
+
+ if (theContentType == NULL ||
+ theContentType->type_kind() == XQType::ANY_TYPE_KIND)
+ return true;
+
+ xqtref_t subContentType =
+ tm->create_named_type(subitem->getType(), TypeConstants::QUANT_ONE, loc, true);
+
+ return TypeOps::is_subtype(tm, *subContentType, *theContentType);
+ }
+ }
+ case store::StoreConsts::documentNode:
+ {
+ if (theContentType == NULL ||
+ theContentType->type_kind() == XQType::ANY_TYPE_KIND)
+ return true;
+
+ if (theContentType->type_kind() == XQType::UNTYPED_KIND)
+ {
+ return !subitem->isValidated();
+ }
+
+ ZORBA_ASSERT(theContentType->type_kind() == XQType::NODE_TYPE_KIND);
+
+ store::Iterator_t childrenIte = subitem->getChildren();
+ store::Item_t child;
+ store::Item_t elemChild;
+ csize numElemChildren = 0;
+ childrenIte->open();
+ while (childrenIte->next(child))
+ {
+ if (child->getNodeKind() == store::StoreConsts::elementNode)
{
- return false;
+ if (numElemChildren == 0)
+ elemChild.transfer(child);
+
+ ++numElemChildren;
}
}
+ childrenIte->close();
+
+ if (numElemChildren != 1)
+ return false;
+
+ const NodeXQType* elemTestType =
+ static_cast<const NodeXQType*>(theContentType.getp());
+
+ return elemTestType->is_supertype(tm, elemChild, loc);
}
-
- // 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 = (
- m_node_kind == store::StoreConsts::documentNode &&
- theContentType != NULL &&
- theContentType->type_kind() == XQType::NODE_TYPE_KIND &&
- static_cast<const NodeXQType*>(theContentType.getp())->m_schema_test == false);
-
- if (m_node_kind != store::StoreConsts::elementNode &&
- m_node_kind != store::StoreConsts::attributeNode &&
- !is_element_test)
- return true;
-
- if (theContentType == NULL ||
- theContentType->type_kind() == XQType::ANY_TYPE_KIND)
- return true;
-
- if (is_element_test)
+ default:
{
- xqtref_t documentNodeType = tm->create_value_type(subitem, loc);
- return TypeOps::is_subtype(tm, *documentNodeType, *this);
- }
-
- xqtref_t subContentType = tm->create_named_type(subitem->getType(),
- TypeConstants::QUANT_ONE,
- loc,
- true);
-
- return TypeOps::is_subtype(tm, *subContentType, *theContentType);
+ ZORBA_ASSERT(false);
+ }
+ }
}
@@ -999,16 +1086,16 @@
********************************************************************************/
std::ostream& NodeXQType::serialize_ostream(std::ostream& os) const
{
- store::StoreConsts::NodeKind node_kind = m_node_kind;
+ store::StoreConsts::NodeKind node_kind = theNodeKind;
xqtref_t content_type = get_content_type();
os << "[NodeXQType " << store::StoreConsts::toString(node_kind)
<< TypeOps::decode_quantifier(get_quantifier());
- if (m_node_name != NULL)
+ if (theNodeName != NULL)
{
- os << " nametest=[uri: " << m_node_name->getNamespace()
- << ", local: " << m_node_name->getLocalName() << "]";
+ os << " nametest=[uri: " << theNodeName->getNamespace()
+ << ", local: " << theNodeName->getLocalName() << "]";
}
if (content_type != NULL)
@@ -1025,7 +1112,7 @@
{
std::ostringstream os;
- if (m_node_kind == store::StoreConsts::documentNode)
+ if (theNodeKind == store::StoreConsts::documentNode)
{
os << "document-node(";
@@ -1035,26 +1122,26 @@
os << ", " << theContentType->toSchemaString();
}
}
- else if (m_schema_test)
+ else if (theIsSchemaTest)
{
assert(theContentType != NULL);
os << "schema-" << store::StoreConsts::toSchemaString(get_node_kind()) << "("
- << m_node_name->getStringValue();
+ << theNodeName->getStringValue();
}
else
{
os << store::StoreConsts::toSchemaString(get_node_kind()) << "(";
- if (m_node_name != NULL)
+ if (theNodeName != NULL)
{
- os << m_node_name->getStringValue();
+ os << theNodeName->getStringValue();
if (theContentType != NULL)
{
os << ", " << theContentType->toSchemaString();
- if (m_nillable)
+ if (theNillable)
os << "?";
}
}
@@ -1062,7 +1149,7 @@
{
os << "*, " << theContentType->toSchemaString();
- if (m_nillable)
+ if (theNillable)
os << "?";
}
}
@@ -1238,6 +1325,7 @@
********************************************************************************/
UserDefinedXQType::UserDefinedXQType(
const TypeManager* manager,
+ bool isAnonymous,
store::Item_t qname,
const xqtref_t& baseType,
TypeConstants::quantifier_t quantifier,
@@ -1246,8 +1334,9 @@
bool builtin)
:
XQType(manager, USER_DEFINED_KIND, quantifier, builtin),
+ theIsAnonymous(isAnonymous),
theQName(qname),
- m_baseType(baseType),
+ theBaseType(baseType),
theUDTKind(udtKind),
m_contentKind(contentKind)
{
@@ -1267,14 +1356,16 @@
********************************************************************************/
UserDefinedXQType::UserDefinedXQType(
const TypeManager* manager,
+ bool isAnonymous,
store::Item_t qname,
const xqtref_t& baseType,
const XQType* listItemType,
bool builtin)
:
XQType(manager, USER_DEFINED_KIND, TypeConstants::QUANT_STAR, builtin),
+ theIsAnonymous(isAnonymous),
theQName(qname),
- m_baseType(baseType),
+ theBaseType(baseType),
theUDTKind(LIST_UDT),
m_contentKind(SIMPLE_CONTENT_KIND),
m_listItemType(listItemType)
@@ -1288,6 +1379,7 @@
********************************************************************************/
UserDefinedXQType::UserDefinedXQType(
const TypeManager* manager,
+ bool isAnonymous,
store::Item_t qname,
const xqtref_t& baseType,
TypeConstants::quantifier_t quantifier,
@@ -1295,8 +1387,9 @@
bool builtin)
:
XQType(manager, USER_DEFINED_KIND, quantifier, builtin),
+ theIsAnonymous(isAnonymous),
theQName(qname),
- m_baseType(baseType),
+ theBaseType(baseType),
theUDTKind(UNION_UDT),
m_contentKind(SIMPLE_CONTENT_KIND),
m_unionItemTypes(unionItemTypes)
@@ -1317,7 +1410,7 @@
{
serialize_baseclass(ar, (XQType*)this);
ar & theQName;
- ar & m_baseType;
+ ar & theBaseType;
SERIALIZE_ENUM(UDTKind, theUDTKind);
SERIALIZE_ENUM(content_kind_t, m_contentKind);
ar & m_listItemType;
@@ -1330,7 +1423,7 @@
********************************************************************************/
xqtref_t UserDefinedXQType::getBaseBuiltinType() const
{
- xqtref_t builtinType = m_baseType;
+ xqtref_t builtinType = theBaseType;
while (builtinType->type_kind() == XQType::USER_DEFINED_KIND)
{
@@ -1501,7 +1594,7 @@
<< theQName->getNamespace() << " "
<< info.str()
<< " base:"
- << ( m_baseType ? m_baseType->toString() : "NULL" )
+ << ( theBaseType ? theBaseType->toString() : "NULL" )
<< "]";
}
=== modified file 'src/types/typeimpl.h'
--- src/types/typeimpl.h 2013-03-08 15:03:58 +0000
+++ src/types/typeimpl.h 2013-04-25 09:51:29 +0000
@@ -375,6 +375,8 @@
int card() const;
+ virtual bool isAnonymous() const { return false; }
+
bool isComplex() const;
bool isList() const;
@@ -567,11 +569,11 @@
friend class XQType;
private:
- store::StoreConsts::NodeKind m_node_kind;
- store::Item_t m_node_name;
+ store::StoreConsts::NodeKind theNodeKind;
+ store::Item_t theNodeName;
xqtref_t theContentType;
- bool m_nillable;
- bool m_schema_test;
+ bool theNillable;
+ bool theIsSchemaTest;
public:
SERIALIZABLE_CLASS(NodeXQType)
@@ -589,19 +591,17 @@
bool schematest,
bool builtin = false);
- NodeXQType(
- const NodeXQType& source,
- TypeConstants::quantifier_t quantifier);
-
- store::StoreConsts::NodeKind get_node_kind() const { return m_node_kind; }
-
- store::Item* get_node_name() const { return m_node_name.getp(); }
-
- bool is_schema_test() const { return m_schema_test; }
+ NodeXQType(const NodeXQType& source, TypeConstants::quantifier_t quant);
+
+ store::StoreConsts::NodeKind get_node_kind() const { return theNodeKind; }
+
+ store::Item* get_node_name() const { return theNodeName.getp(); }
+
+ bool is_schema_test() const { return theIsSchemaTest; }
const XQType* get_content_type() const { return theContentType.getp(); }
- bool get_nillable() const { return m_nillable; }
+ bool get_nillable() const { return theNillable; }
bool is_untyped() const;
@@ -718,7 +718,7 @@
------------
The baseType of this type. NULL for list or union types.
- m_typeCategory:
+ theUDTKind:
---------------
Whether this is an atomic, list, union, or complex type.
@@ -743,9 +743,11 @@
private:
+ bool theIsAnonymous;
+
store::Item_t theQName;
- xqtref_t m_baseType;
+ xqtref_t theBaseType;
UDTKind theUDTKind;
@@ -767,6 +769,7 @@
// constructor for Atomic and Complex types
UserDefinedXQType(
const TypeManager* manager,
+ bool isAnonymous,
store::Item_t qname,
const xqtref_t& baseType,
TypeConstants::quantifier_t quantifier,
@@ -777,6 +780,7 @@
// Constructor for List types
UserDefinedXQType(
const TypeManager* manager,
+ bool isAnonymous,
store::Item_t qname,
const xqtref_t& baseType,
const XQType* listItemType,
@@ -785,6 +789,7 @@
// Constructor for Union types
UserDefinedXQType(
const TypeManager* manager,
+ bool isAnonymous,
store::Item_t qname,
const xqtref_t& baseType,
TypeConstants::quantifier_t quantifier,
@@ -793,11 +798,13 @@
virtual ~UserDefinedXQType() {}
+ virtual bool isAnonymous() const { return theIsAnonymous; }
+
virtual content_kind_t content_kind() const { return m_contentKind; };
UDTKind getUDTKind() const { return theUDTKind; }
- xqtref_t getBaseType() const { return m_baseType; }
+ xqtref_t getBaseType() const { return theBaseType; }
xqtref_t getBaseBuiltinType() const;
=== modified file 'src/types/typemanager.h'
--- src/types/typemanager.h 2013-02-07 17:24:36 +0000
+++ src/types/typemanager.h 2013-04-25 09:51:29 +0000
@@ -159,17 +159,18 @@
TypeConstants::quantifier_t quant,
const QueryLoc& loc) const = 0;
- virtual void get_schema_element_typename(
+ virtual void get_schema_element_typeinfo(
const store::Item* elemName,
store::Item_t& typeName,
- const QueryLoc& loc) = 0;
+ bool& nillable,
+ const QueryLoc& loc) const = 0;
virtual xqtref_t create_schema_attribute_type(
const store::Item_t& aName,
TypeConstants::quantifier_t quant,
const QueryLoc& loc) const = 0;
- virtual void get_schema_attribute_typename(
+ virtual void get_schema_attribute_typeinfo(
const store::Item* attrName,
store::Item_t& typeName,
const QueryLoc& loc) = 0;
=== modified file 'src/types/typemanagerimpl.cpp'
--- src/types/typemanagerimpl.cpp 2013-04-16 07:39:27 +0000
+++ src/types/typemanagerimpl.cpp 2013-04-25 09:51:29 +0000
@@ -893,14 +893,16 @@
ERROR_PARAMS(ZED(XPST0008_SchemaElementName_2), elemName->getStringValue()));
}
+ bool nillable;
+
xqtref_t contentType =
- m_schema->createXQTypeFromElementName(this, elemName, true, loc);
+ m_schema->createXQTypeFromGlobalElementDecl(this, elemName, true, nillable, loc);
return create_node_type(store::StoreConsts::elementNode,
elemName,
contentType,
quant,
- false, // nillable
+ nillable,
true); // schematest
}
@@ -908,10 +910,11 @@
/***************************************************************************//**
Get the name of the type associated with a given globally declared element name.
********************************************************************************/
-void TypeManagerImpl::get_schema_element_typename(
+void TypeManagerImpl::get_schema_element_typeinfo(
const store::Item* elemName,
store::Item_t& typeName,
- const QueryLoc& loc)
+ bool& nillable,
+ const QueryLoc& loc) const
{
if (m_schema == NULL)
{
@@ -919,7 +922,7 @@
ERROR_PARAMS(ZED(XPST0008_SchemaElementName_2), elemName->getStringValue()));
}
- m_schema->getTypeNameFromElementName(elemName, typeName, loc);
+ m_schema->getInfoFromGlobalElementDecl(elemName, typeName, nillable, loc);
}
@@ -941,7 +944,7 @@
}
xqtref_t contentType =
- m_schema->createXQTypeFromAttributeName(this, attrName, true, loc);
+ m_schema->createXQTypeFromGlobalAttributeDecl(this, attrName, true, loc);
return create_node_type(store::StoreConsts::attributeNode,
attrName,
@@ -956,7 +959,7 @@
Get the name of the type associated with a given globally declared attribute
name.
********************************************************************************/
-void TypeManagerImpl::get_schema_attribute_typename(
+void TypeManagerImpl::get_schema_attribute_typeinfo(
const store::Item* attrName,
store::Item_t& typeName,
const QueryLoc& loc)
@@ -967,7 +970,7 @@
ERROR_PARAMS(ZED(XPST0008_SchemaAttributeName_2), attrName->getStringValue()));
}
- m_schema->getTypeNameFromAttributeName(attrName, typeName, loc);
+ m_schema->getInfoFromGlobalAttributeDecl(attrName, typeName, loc);
}
@@ -1062,6 +1065,7 @@
if (udt.isList())
{
return new UserDefinedXQType(this,
+ udt.isAnonymous(),
udt.getQName(),
udt.getBaseType(),
udt.getListItemType());
@@ -1069,6 +1073,7 @@
else if (udt.isUnion())
{
return new UserDefinedXQType(this,
+ udt.isAnonymous(),
udt.getQName(),
udt.getBaseType(),
quantifier,
@@ -1077,6 +1082,7 @@
else
{
return new UserDefinedXQType(this,
+ udt.isAnonymous(),
udt.getQName(),
udt.getBaseType(),
quantifier,
=== modified file 'src/types/typemanagerimpl.h'
--- src/types/typemanagerimpl.h 2013-02-07 17:24:36 +0000
+++ src/types/typemanagerimpl.h 2013-04-25 09:51:29 +0000
@@ -148,17 +148,18 @@
TypeConstants::quantifier_t quant,
const QueryLoc& loc) const;
- void get_schema_element_typename(
+ void get_schema_element_typeinfo(
const store::Item* elemName,
store::Item_t& typeName,
- const QueryLoc& loc);
+ bool& nillable,
+ const QueryLoc& loc) const;
xqtref_t create_schema_attribute_type(
const store::Item_t& attrName,
TypeConstants::quantifier_t quant,
const QueryLoc& loc) const;
- void get_schema_attribute_typename(
+ void get_schema_attribute_typeinfo(
const store::Item* attrName,
store::Item_t& typeName,
const QueryLoc& loc);
=== modified file 'src/types/typeops.cpp'
--- src/types/typeops.cpp 2013-03-16 08:48:16 +0000
+++ src/types/typeops.cpp 2013-04-25 09:51:29 +0000
@@ -131,20 +131,32 @@
return false;
#ifndef ZORBA_NO_XMLSCHEMA
- if (ntype.get_node_kind() == store::StoreConsts::elementNode)
- {
- return (schema->createXQTypeFromElementName(tm,
- ntype.get_node_name(),
- false,
- QueryLoc::null) != NULL);
- }
- else
- {
- return (schema->createXQTypeFromAttributeName(tm,
- ntype.get_node_name(),
- false,
- QueryLoc::null) != NULL);
- }
+ try
+ {
+ bool nillable;
+ store::Item_t typeName;
+ if (ntype.get_node_kind() == store::StoreConsts::elementNode)
+ {
+ schema->getInfoFromGlobalElementDecl(ntype.get_node_name(),
+ typeName,
+ nillable,
+ QueryLoc::null);
+ }
+ else
+ {
+ schema->getInfoFromGlobalAttributeDecl(ntype.get_node_name(),
+ typeName,
+ QueryLoc::null);
+ }
+ }
+ catch (ZorbaException& e)
+ {
+ if (e.diagnostic() == err::XPST0008)
+ return false;
+
+ throw;
+ }
+
#else
throw ZORBA_EXCEPTION(err::XQST0009);
#endif
=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt 2013-04-25 01:27:33 +0000
+++ test/fots/CMakeLists.txt 2013-04-25 09:51:29 +0000
@@ -134,6 +134,22 @@
EXPECTED_FOTS_FAILURE (DISPUTED prod-OrderByClause orderBy20 21619)
EXPECTED_FOTS_FAILURE (DISPUTED prod-OrderByClause orderBy21 21619)
EXPECTED_FOTS_FAILURE (DISPUTED misc-CombinedErrorCodes XQST0085 21730)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-001 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-003 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-005 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-007 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-009 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-012 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-013 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-015 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-017 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-019 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-021 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-023 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-025 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-027 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-029 21568)
+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-031 21568)
# Next three possibly unique to old RQ machine, but they need to be
# marked for the RQ to pass.
@@ -186,21 +202,6 @@
EXPECTED_FOTS_FAILURE (fn-generate-id generate-id-017 0)
EXPECTED_FOTS_FAILURE (fn-last last-24 0)
EXPECTED_FOTS_FAILURE (fn-matches cbcl-matches-038 1131304)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-33 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-35 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-37 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-38 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-39 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-41 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-44 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-45 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-46 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-47 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-50 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-51 0)
-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-52 0)
-EXPECTED_FOTS_FAILURE (fn-nilled cbcl-nilled-002 0)
-EXPECTED_FOTS_FAILURE (fn-nilled cbcl-nilled-005 0)
EXPECTED_FOTS_FAILURE (fn-normalize-space fn-normalize-space-23 0)
EXPECTED_FOTS_FAILURE (fn-normalize-space fn-normalize-space-25 0)
EXPECTED_FOTS_FAILURE (fn-normalize-unicode cbcl-fn-normalize-unicode-001 0)
@@ -320,22 +321,6 @@
EXPECTED_FOTS_FAILURE (prod-FunctionCall function-call-reserved-function-names-014 0)
EXPECTED_FOTS_FAILURE (prod-FunctionCall function-call-reserved-function-names-015 0)
EXPECTED_FOTS_FAILURE (prod-FunctionCall function-call-reserved-function-names-016 0)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-001 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-003 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-005 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-007 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-009 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-012 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-013 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-015 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-017 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-019 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-021 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-023 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-025 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-027 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-029 21568)
-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-031 21568)
EXPECTED_FOTS_FAILURE (prod-InstanceofExpr instanceof113 0)
EXPECTED_FOTS_FAILURE (prod-InstanceofExpr instanceof139 1160559)
EXPECTED_FOTS_FAILURE (prod-InstanceofExpr instanceof140 0)
=== modified file 'test/rbkt/Queries/zorba/schemas/books.xsd'
--- test/rbkt/Queries/zorba/schemas/books.xsd 2013-02-07 17:24:36 +0000
+++ test/rbkt/Queries/zorba/schemas/books.xsd 2013-04-25 09:51:29 +0000
@@ -5,8 +5,8 @@
elementFormDefault="qualified">
<!-- importing the XML namespace makes xml:id an ID attribute under lax validation -->
- <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
-
+ <xs:import namespace="http://www.w3.org/XML/1998/namespace"
+ schemaLocation="http://www.w3.org/2001/xml.xsd"/>
<xs:element name="BOOKLIST">
<xs:complexType>
=== modified file 'test/update/Scripts/Readme.txt'
--- test/update/Scripts/Readme.txt 2013-02-07 17:24:36 +0000
+++ test/update/Scripts/Readme.txt 2013-04-25 09:51:29 +0000
@@ -14,12 +14,13 @@
#
To generate a report for submitting to the W3C:
-0. For submitting reports to W3C one should compile Zorba with:
+0. For submitting reports to W3C one should compile Zorba with
ZORBA_WITH_BIG_INTEGER=ON
ZORBA_XQUERYX=ON
ZORBA_TEST_XQUERYX=ON
ZORBA_TEST_W3C_TO_SUBMIT_RESULTS=ON
ZORBA_WITH_JSON=OFF
+ And make sure you are using at least Xerces version 3.1.1.
1. Import XQUTS.
@@ -62,5 +63,3 @@
7. Modify /tmp/XQUTS_1_0_1/ReportingResults/Results.xml by adding a result node for every report you copied at step 5.
8. From /tmp/XQUTS_1_0_1/ReportingResults/ run 'ant -buildfile Build.xml' in order to generate XQUTSReport.html and XQUTSReportSimple.html
-
-
=== modified file 'test/update/updtestdriver.cpp'
--- test/update/updtestdriver.cpp 2013-03-14 08:01:06 +0000
+++ test/update/updtestdriver.cpp 2013-04-25 09:51:29 +0000
@@ -44,6 +44,9 @@
#include "system/properties.h"
#include "testdriver_comparator.h"
+//#define ZORBA_TEST_PLAN_SERIALIZATION
+
+
bool isErrorExpected(zorba::ZorbaException& e, State* aState)
{
if ( aState->hasErrors)