Merge lp:~zorba-coders/zorba/bug1147563 into lp:zorba

Proposed by Sorin Marian Nasoi
Status: Merged
Approved by: Sorin Marian Nasoi
Approved revision: 11316
Merged at revision: 11419
Proposed branch: lp:~zorba-coders/zorba/bug1147563
Merge into: lp:zorba
Diff against target: 1714 lines (+471/-337)
24 files modified
ChangeLog (+2/-0)
src/compiler/translator/translator.cpp (+4/-2)
src/runtime/accessors/accessors_impl.cpp (+10/-2)
src/runtime/core/path_iterators.cpp (+2/-2)
src/runtime/core/sequencetypes.cpp (+1/-1)
src/runtime/visitors/printer_visitor_impl.cpp (+19/-15)
src/store/api/item.h (+1/-1)
src/store/naive/item.cpp (+1/-1)
src/store/naive/node_items.cpp (+26/-24)
src/store/naive/node_items.h (+1/-7)
src/types/root_typemanager.cpp (+3/-0)
src/types/schema/schema.cpp (+85/-80)
src/types/schema/schema.h (+24/-21)
src/types/schema/validate.cpp (+16/-12)
src/types/typeimpl.cpp (+181/-88)
src/types/typeimpl.h (+24/-17)
src/types/typemanager.h (+4/-3)
src/types/typemanagerimpl.cpp (+14/-8)
src/types/typemanagerimpl.h (+4/-3)
src/types/typeops.cpp (+26/-14)
test/fots/CMakeLists.txt (+16/-31)
test/rbkt/Queries/zorba/schemas/books.xsd (+2/-2)
test/update/Scripts/Readme.txt (+2/-3)
test/update/updtestdriver.cpp (+3/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug1147563
Reviewer Review Type Date Requested Status
Sorin Marian Nasoi Approve
Chris Hillery Approve
Markos Zaharioudakis Approve
Cezar Andrei Approve
Review via email: mp+160839@code.launchpad.net

Commit message

Fixes for nilled function

Description of the change

Fixes for nilled function

To post a comment you must log in.
Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

there are 8 more schema & nillable items failures: please see

https://bugs.launchpad.net/zorba/+bug/1147563/comments/3

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug1147563-2013-04-25T09-55-48.874Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1, Needs Information < 1, Resubmit < 1. Got: 1 Approve, 4 Pending.

Revision history for this message
Cezar Andrei (cezar-andrei) :
review: Approve
Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

In case I was not clear enough in
https://bugs.launchpad.net/zorba/+bug/1147563/comments/3:

This merge, as it is now, passed all RQ tests as one can see in the logs above and thus can be merged "as is".

However, there are 8 more failing test-cases that seem to be connected to nilled function:
in "prod-SchemaImport" related to nillable elements:
cbcl-schema-element-1, cbcl-schema-element-2, cbcl-schema-element-4, cbcl-schema-element-5, cbcl-schema-element-8, cbcl-validated-schema-element-1, cbcl-validated-schema-element-3, cbcl-validated-schema-element-4

All these 8 failing test-cases are narked as EXPECTED_FOTS_FAILURE in this proposed branch:
http://bazaar.launchpad.net/~zorba-coders/zorba/bug1147563/view/head:/test/fots/CMakeLists.txt#L383

So, the question is do we either:
1) fix these 8 failures in this merge
2) or do we commit this merge and we open a new bug for the rest of 8 failures (even though they may be connected to nilled function)

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Cezar Andrei (cezar-andrei) wrote :

Let's get this is and open up a new bug for the 8 failures.

Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Attempt to merge into lp:zorba failed due to conflicts:

text conflict in src/compiler/translator/translator.cpp
text conflict in test/fots/CMakeLists.txt

Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/bug1147563 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bug1147563-2013-04-30T19-59-49.898Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/bug1147563 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bug1147563-2013-04-30T20-17-46.51Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/bug1147563 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bug1147563-2013-04-30T20-48-46.113Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug1147563-2013-04-30T21-01-02.777Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-04-30 18:31:49 +0000
3+++ ChangeLog 2013-04-30 21:00:38 +0000
4@@ -49,6 +49,8 @@
5 * Fixed bug #1124273 (xqdoc crash because of annotation literals)
6 * Fixed bug #1085408 (xs:date(): casting large year values)
7 * Fixed bug #867027 (XQST0059 error messages inconsistent)
8+ * Fixed fn:nilled function
9+ * Fixed bug concerning nillability during sequnce type matching.
10 * Fixed bug in handling the type declaration of a FOR variable that allows empty.
11 * Fixed bug #1095889 (Improve error message for xml-parsing error).
12 * Fixed bug #1131984 (apparently invalid regex in queries)
13
14=== modified file 'src/compiler/translator/translator.cpp'
15--- src/compiler/translator/translator.cpp 2013-04-30 18:31:49 +0000
16+++ src/compiler/translator/translator.cpp 2013-04-30 21:00:38 +0000
17@@ -14298,13 +14298,15 @@
18
19 if (axisExpr != NULL)
20 {
21+ bool nillable;
22 store::Item_t typeQNameItem;
23- CTX_TM->get_schema_element_typename(elemQNameItem, typeQNameItem, loc);
24+ CTX_TM->get_schema_element_typeinfo(elemQNameItem, typeQNameItem, nillable, loc);
25
26 match_expr* match = theExprManager->create_match_expr(theRootSctx, theUDF, loc);
27 match->setTestKind(match_xs_elem_test);
28 match->setQName(elemQNameItem);
29 match->setTypeName(typeQNameItem);
30+ match->setNilledAllowed(nillable);
31
32 axisExpr->setTest(match);
33 }
34@@ -14422,7 +14424,7 @@
35 if (axisExpr != NULL)
36 {
37 store::Item_t typeQNameItem;
38- CTX_TM->get_schema_attribute_typename(attrQNameItem, typeQNameItem, loc);
39+ CTX_TM->get_schema_attribute_typeinfo(attrQNameItem, typeQNameItem, loc);
40
41 match_expr* match = theExprManager->create_match_expr(theRootSctx, theUDF, loc);
42 match->setTestKind(match_xs_attr_test);
43
44=== modified file 'src/runtime/accessors/accessors_impl.cpp'
45--- src/runtime/accessors/accessors_impl.cpp 2013-03-15 08:22:41 +0000
46+++ src/runtime/accessors/accessors_impl.cpp 2013-04-30 21:00:38 +0000
47@@ -105,8 +105,15 @@
48 {
49 if (inNode->isNode())
50 {
51- result = inNode->getNilled();
52- STACK_PUSH(result != NULL, state);
53+ if (inNode->getNodeKind() == store::StoreConsts::elementNode)
54+ {
55+ GENV_ITEMFACTORY->createBoolean(result, inNode->getNilled());
56+ STACK_PUSH(true, state);
57+ }
58+ else
59+ {
60+ STACK_PUSH(false, state);
61+ }
62 }
63 else
64 {
65@@ -240,6 +247,7 @@
66 }
67
68 state->theTypedValueIter = 0; // TODO remove???
69+
70 STACK_END(state);
71 }
72
73
74=== modified file 'src/runtime/core/path_iterators.cpp'
75--- src/runtime/core/path_iterators.cpp 2013-04-08 15:07:13 +0000
76+++ src/runtime/core/path_iterators.cpp 2013-04-30 21:00:38 +0000
77@@ -313,7 +313,7 @@
78
79 if ((!TypeOps::is_subtype(sctx->get_typemanager(), *atype, *theType)) ||
80 (theNilledAllowed == false &&
81- node->getNilled()->getBooleanValue() == true))
82+ node->getNilled() == true))
83 {
84 return false;
85 }
86@@ -338,7 +338,7 @@
87
88 if ((!TypeOps::is_subtype(sctx->get_typemanager(), *atype, *theType)) ||
89 (theNilledAllowed == false &&
90- node->getNilled()->getBooleanValue() == true))
91+ node->getNilled() == true))
92 return false;
93
94 return true;
95
96=== modified file 'src/runtime/core/sequencetypes.cpp'
97--- src/runtime/core/sequencetypes.cpp 2013-04-18 08:47:43 +0000
98+++ src/runtime/core/sequencetypes.cpp 2013-04-30 21:00:38 +0000
99@@ -84,7 +84,7 @@
100 store::Item_t item;
101 TypeConstants::quantifier_t quant;
102 bool res = false;
103-
104+ store::Item_t temp;
105 const TypeManager* tm = theSctx->get_typemanager();
106
107 PlanIteratorState* state;
108
109=== modified file 'src/runtime/visitors/printer_visitor_impl.cpp'
110--- src/runtime/visitors/printer_visitor_impl.cpp 2013-03-27 07:55:14 +0000
111+++ src/runtime/visitors/printer_visitor_impl.cpp 2013-04-30 21:00:38 +0000
112@@ -208,21 +208,6 @@
113 thePrinter.endEndVisit();
114 }
115
116-void PrinterVisitor::beginVisit ( const TreatIterator& a )
117-{
118- thePrinter.startBeginVisit("TreatIterator", ++theId);
119- if (a.theCheckPrime)
120- thePrinter.addAttribute("type", a.theTreatType->toString());
121- thePrinter.addAttribute("quant", TypeOps::decode_quantifier(a.theQuantifier));
122- printCommons( &a, theId );
123- thePrinter.endBeginVisit(theId);
124-}
125-
126-void PrinterVisitor::endVisit ( const TreatIterator& )
127-{
128- thePrinter.startEndVisit();
129- thePrinter.endEndVisit();
130-}
131
132 void PrinterVisitor::beginVisit ( const NumArithIterator<AddOperation>& a )
133 {
134@@ -1176,6 +1161,7 @@
135 thePrinter.endEndVisit();
136 }
137
138+
139 void PrinterVisitor::beginVisit(const PromoteIterator& a)
140 {
141 thePrinter.startBeginVisit("PromoteIterator", ++theId);
142@@ -1192,6 +1178,24 @@
143 thePrinter.endEndVisit();
144 }
145
146+
147+void PrinterVisitor::beginVisit ( const TreatIterator& a )
148+{
149+ thePrinter.startBeginVisit("TreatIterator", ++theId);
150+ if (a.theCheckPrime)
151+ thePrinter.addAttribute("type", a.theTreatType->toString());
152+ thePrinter.addAttribute("quant", TypeOps::decode_quantifier(a.theQuantifier));
153+ printCommons( &a, theId );
154+ thePrinter.endBeginVisit(theId);
155+}
156+
157+void PrinterVisitor::endVisit ( const TreatIterator& )
158+{
159+ thePrinter.startEndVisit();
160+ thePrinter.endEndVisit();
161+}
162+
163+
164 void PrinterVisitor::beginVisit(const CastableIterator& a)
165 {
166 thePrinter.startBeginVisit("CastableIterator", ++theId);
167
168=== modified file 'src/store/api/item.h'
169--- src/store/api/item.h 2013-04-08 00:44:26 +0000
170+++ src/store/api/item.h 2013-04-30 21:00:38 +0000
171@@ -674,7 +674,7 @@
172 /** Accessor for element node
173 * @return boolean?
174 */
175- virtual Item_t
176+ virtual bool
177 getNilled() const;
178
179 /** Accessor for document node, element node, attribute node, namespace node,
180
181=== modified file 'src/store/naive/item.cpp'
182--- src/store/naive/item.cpp 2013-04-08 00:44:26 +0000
183+++ src/store/naive/item.cpp 2013-04-30 21:00:38 +0000
184@@ -976,7 +976,7 @@
185 }
186
187
188-store::Item_t Item::getNilled() const
189+bool Item::getNilled() const
190 {
191 throw ZORBA_EXCEPTION(
192 zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
193
194=== modified file 'src/store/naive/node_items.cpp'
195--- src/store/naive/node_items.cpp 2013-04-17 12:37:36 +0000
196+++ src/store/naive/node_items.cpp 2013-04-30 21:00:38 +0000
197@@ -2968,6 +2968,17 @@
198 {
199 zstring rch;
200 getStringValue2(rch);
201+
202+ if (rch.empty())
203+ {
204+ if (getNilled())
205+ {
206+ val = NULL;
207+ iter = NULL;
208+ return;
209+ }
210+ }
211+
212 GET_FACTORY().createUntypedAtomic(val, rch);
213 }
214 }
215@@ -3048,17 +3059,15 @@
216 /*******************************************************************************
217
218 ********************************************************************************/
219-store::Item_t ElementNode::getNilled() const
220+bool ElementNode::getNilled() const
221 {
222 store::Item_t val;
223
224 if (getType()->equals(GET_STORE().XS_UNTYPED_QNAME))
225- {
226- GET_FACTORY().createBoolean(val, false);
227- return val;
228- }
229+ return false;
230
231- bool nilled = true;
232+ if (!isValidated())
233+ return false;
234
235 const_iterator ite = childrenBegin();
236 const_iterator end = childrenEnd();
237@@ -3068,38 +3077,31 @@
238 if ((*ite)->getNodeKind() == store::StoreConsts::elementNode ||
239 (*ite)->getNodeKind() == store::StoreConsts::textNode)
240 {
241- nilled = false;
242- break;
243+ return false;
244 }
245 }
246
247- if (!nilled)
248- {
249- GET_FACTORY().createBoolean(val, false);
250- return val;
251- }
252-
253- nilled = false;
254-
255- //const char* xsi = "http://www.w3.org/2001/XMLSchema-instance";
256- //ulong xsilen = strlen(xsi);
257-
258 ite = attrsBegin();
259 end = attrsEnd();
260
261 for (; ite != end; ++ite)
262 {
263 XmlNode* attr = *ite;
264- if (ZSTREQ(attr->getNodeName()->getNamespace(), "xsi") &&
265- ZSTREQ(attr->getNodeName()->getLocalName(), "nil"))
266+
267+ zstring strval;
268+ attr->getStringValue2(strval);
269+
270+ if (ZSTREQ(attr->getNodeName()->getNamespace(),
271+ "http://www.w3.org/2001/XMLSchema-instance") &&
272+ ZSTREQ(attr->getNodeName()->getLocalName(), "nil") &&
273+ (ZSTREQ(strval, "true") || ZSTREQ(strval, "1") ))
274 {
275- nilled = true;
276+ return true;
277 break;
278 }
279 }
280
281- GET_FACTORY().createBoolean(val, nilled);
282- return val;
283+ return false;
284 }
285
286
287
288=== modified file 'src/store/naive/node_items.h'
289--- src/store/naive/node_items.h 2013-03-07 10:10:10 +0000
290+++ src/store/naive/node_items.h 2013-04-30 21:00:38 +0000
291@@ -500,12 +500,6 @@
292
293 store::Item* copy(store::Item* parent, const store::CopyMode& copymode) const;
294
295- virtual store::Item_t getNilled() const
296- {
297- assert(!isConnectorNode());
298- return 0;
299- }
300-
301 virtual bool isId() const
302 {
303 assert(!isConnectorNode());
304@@ -1072,7 +1066,7 @@
305
306 void appendStringValue(zstring& buf) const;
307
308- store::Item_t getNilled() const;
309+ bool getNilled() const;
310
311 store::Iterator_t getAttributes() const;
312
313
314=== modified file 'src/types/root_typemanager.cpp'
315--- src/types/root_typemanager.cpp 2013-03-20 18:39:54 +0000
316+++ src/types/root_typemanager.cpp 2013-04-30 21:00:38 +0000
317@@ -386,18 +386,21 @@
318 #undef ATOMIC_TYPE_DEFN
319
320 XS_NMTOKENS_TYPE = new UserDefinedXQType(this,
321+ false,
322 XS_NMTOKENS_QNAME,
323 NULL,
324 NMTOKEN_TYPE_ONE.getp(),
325 true);
326
327 XS_ENTITIES_TYPE = new UserDefinedXQType(this,
328+ false,
329 XS_ENTITIES_QNAME,
330 NULL,
331 ENTITY_TYPE_ONE.getp(),
332 true);
333
334 XS_IDREFS_TYPE = new UserDefinedXQType(this,
335+ false,
336 XS_IDREFS_QNAME,
337 NULL,
338 IDREF_TYPE_ONE.getp(),
339
340=== modified file 'src/types/schema/schema.cpp'
341--- src/types/schema/schema.cpp 2013-04-16 21:12:12 +0000
342+++ src/types/schema/schema.cpp 2013-04-30 21:00:38 +0000
343@@ -259,7 +259,8 @@
344
345 return lRetval;
346 }
347- else {
348+ else
349+ {
350 // We didn't find it. If we return NULL here, Xerces will try to
351 // resolve it its own way, which we don't want to happen.
352 throw XQUERY_EXCEPTION(
353@@ -271,7 +272,8 @@
354 );
355 }
356 }
357- catch (ZorbaException const& e) {
358+ catch (ZorbaException const& e)
359+ {
360 TRACE("!!! ZorbaException: " << e );
361 if ( e.diagnostic() == zerr::ZXQP0029_URI_ACCESS_DENIED ||
362 e.diagnostic() == err::XQST0059 )
363@@ -518,82 +520,71 @@
364
365
366 /*******************************************************************************
367- For the given element name find out its declared schema type
368+ Find a global element declaration for a given element name and return the name
369+ of the associated schema type and whether the element can be nillable.
370+ Raise an error if no global element declaration is found for the given name.
371 *******************************************************************************/
372-void Schema::getTypeNameFromElementName(
373+void Schema::getInfoFromGlobalElementDecl(
374 const store::Item* qname,
375 store::Item_t& typeName,
376+ bool& nillable,
377 const QueryLoc& loc)
378 {
379- XSTypeDefinition* typeDef = getTypeDefForElement(qname);
380+ XSElementDeclaration* decl = getDeclForElement(qname);
381
382- if (!typeDef)
383+ if (!decl)
384 {
385 RAISE_ERROR(err::XPST0008, loc,
386 ERROR_PARAMS(ZED(XPST0008_SchemaElementName_2), qname->getStringValue()));
387 }
388
389- const XMLCh* typeNameStr = typeDef->getName();
390- const XMLCh* typeUri = typeDef->getNamespace();
391-
392- GENV_ITEMFACTORY->createQName(typeName,
393- StrX(typeUri).localForm(),
394- "",
395- StrX(typeNameStr).localForm());
396-}
397-
398-
399-/*******************************************************************************
400- For a given global attribute find out its declared schema type
401-*******************************************************************************/
402-void Schema::getTypeNameFromAttributeName(
403- const store::Item* qname,
404- store::Item_t& typeName,
405- const QueryLoc& loc)
406-{
407- XSTypeDefinition* typeDef = getTypeDefForAttribute(qname);
408-
409- if (!typeDef)
410- {
411- RAISE_ERROR(err::XPST0008, loc,
412- ERROR_PARAMS(ZED(XPST0008_SchemaAttributeName_2), qname->getStringValue()));
413- }
414-
415- const XMLCh* typeNameStr = typeDef->getName();
416- const XMLCh* typeUri = typeDef->getNamespace();
417-
418- GENV_ITEMFACTORY->createQName(typeName,
419- StrX(typeUri).localForm(),
420- "",
421- StrX(typeNameStr).localForm());
422-}
423-
424-
425-/*******************************************************************************
426- Returns an XQType for a global schema element definition if defined,
427- otherwise NULL
428-*******************************************************************************/
429-xqtref_t Schema::createXQTypeFromElementName(
430+ XSTypeDefinition* typeDef = decl->getTypeDefinition();
431+
432+ const XMLCh* typeNameStr = typeDef->getName();
433+ const XMLCh* typeUri = typeDef->getNamespace();
434+
435+ GENV_ITEMFACTORY->createQName(typeName,
436+ StrX(typeUri).localForm(),
437+ "",
438+ StrX(typeNameStr).localForm());
439+
440+ nillable = decl->getNillable();
441+}
442+
443+
444+/*******************************************************************************
445+ Find a global element declaration for a given element name and return an
446+ XQType for the associated schema type and whether the element can be nillable.
447+ Raise an error if the raiseErrors param is true and no global element
448+ declaration is found for the given name.
449+*******************************************************************************/
450+xqtref_t Schema::createXQTypeFromGlobalElementDecl(
451 const TypeManager* typeManager,
452 const store::Item* qname,
453- const bool riseErrors,
454+ const bool raiseErrors,
455+ bool& nillable,
456 const QueryLoc& loc)
457 {
458 TRACE("qn:" << qname->getLocalName() << " @ " <<
459 qname->getNamespace() );
460
461- XSTypeDefinition* typeDef = getTypeDefForElement(qname);
462+ XSElementDeclaration* decl = getDeclForElement(qname);
463
464- if (!riseErrors && !typeDef)
465+ if (!raiseErrors && !decl)
466 return NULL;
467
468- if (!typeDef)
469+ if (!decl)
470 {
471 RAISE_ERROR(err::XPST0008, loc,
472 ERROR_PARAMS(ZED(XPST0008_SchemaElementName_2), qname->getStringValue()));
473 }
474
475+ nillable = decl->getNillable();
476+
477+ XSTypeDefinition* typeDef = decl->getTypeDefinition();
478+
479 xqtref_t res = createXQTypeFromTypeDefinition(typeManager, typeDef);
480+
481 TRACE("res:" << res->get_qname()->getLocalName() << " @ " <<
482 res->get_qname()->getNamespace());
483
484@@ -602,18 +593,46 @@
485
486
487 /*******************************************************************************
488+ Find a global attribute declaration for a given attribute name and return the
489+ name of the associated schema type. Raise an error if no global attribute
490+ declaration is found for the given name.
491+*******************************************************************************/
492+void Schema::getInfoFromGlobalAttributeDecl(
493+ const store::Item* qname,
494+ store::Item_t& typeName,
495+ const QueryLoc& loc)
496+{
497+ XSTypeDefinition* typeDef = getTypeDefForAttribute(qname);
498+
499+ if (!typeDef)
500+ {
501+ RAISE_ERROR(err::XPST0008, loc,
502+ ERROR_PARAMS(ZED(XPST0008_SchemaAttributeName_2), qname->getStringValue()));
503+ }
504+
505+ const XMLCh* typeNameStr = typeDef->getName();
506+ const XMLCh* typeUri = typeDef->getNamespace();
507+
508+ GENV_ITEMFACTORY->createQName(typeName,
509+ StrX(typeUri).localForm(),
510+ "",
511+ StrX(typeNameStr).localForm());
512+}
513+
514+
515+/*******************************************************************************
516 Returns an XQType for a global schema attribute definition if defined,
517 otherwise NULL
518 *******************************************************************************/
519-xqtref_t Schema::createXQTypeFromAttributeName(
520+xqtref_t Schema::createXQTypeFromGlobalAttributeDecl(
521 const TypeManager* typeManager,
522 const store::Item* qname,
523- const bool riseErrors,
524+ const bool raiseErrors,
525 const QueryLoc& loc)
526 {
527 XSTypeDefinition* typeDef = getTypeDefForAttribute(qname);
528
529- if (!riseErrors && !typeDef)
530+ if (!raiseErrors && !typeDef)
531 return NULL;
532
533 if (!typeDef)
534@@ -744,12 +763,10 @@
535
536
537 /*******************************************************************************
538- Get the type definition for a globally declared element
539+ Get the declaration for a globally declared element
540 *******************************************************************************/
541-XSTypeDefinition* Schema::getTypeDefForElement(const store::Item* qname)
542+XSElementDeclaration* Schema::getDeclForElement(const store::Item* qname)
543 {
544- XSTypeDefinition* typeDef = NULL;
545-
546 TRACE(" element qname: " << qname->getLocalName() << "@" <<
547 qname->getNamespace());
548
549@@ -762,25 +779,7 @@
550 bool xsModelWasChanged;
551 XSModel* model = theGrammarPool->getXSModel(xsModelWasChanged);
552
553- XSElementDeclaration* decl = model->getElementDeclaration(local, uri);
554-
555- if (decl)
556- {
557- typeDef = decl->getTypeDefinition();
558-
559- // this works only on the element that is a substitution,
560- // not on substitution base element
561- //XSElementDeclaration * substGroup =
562- // decl->getSubstitutionGroupAffiliation();
563-
564- //if ( substGroup )
565- //{
566- // TRACE(" substitutionGroup qname: " << StrX(substGroup->getName()) <<
567- // "@" << StrX(substGroup->getNamespace()) << "\n");
568- //}
569- }
570-
571- return typeDef;
572+ return model->getElementDeclaration(local, uri);
573 }
574
575
576@@ -868,6 +867,7 @@
577 xqtref_t baseXQType = createXQTypeFromTypeDefinition(tm, baseTypeDef);
578
579 xqtref_t xqType = new UserDefinedXQType(tm,
580+ xsTypeDef->getAnonymous(),
581 qname,
582 baseXQType,
583 TypeConstants::QUANT_ONE,
584@@ -903,6 +903,7 @@
585 // << endl; cout.flush();
586
587 xqtref_t xqType = new UserDefinedXQType(tm,
588+ xsTypeDef->getAnonymous(),
589 qname,
590 NULL,
591 itemXQType.getp());
592@@ -958,6 +959,7 @@
593 //std::cout << std::endl; std::cout.flush();
594
595 xqtref_t xqType = new UserDefinedXQType(tm,
596+ xsTypeDef->getAnonymous(),
597 qname,
598 baseXQType,
599 TypeConstants::QUANT_ONE,
600@@ -1059,6 +1061,7 @@
601 }
602
603 xqtref_t xqType = new UserDefinedXQType(tm,
604+ xsTypeDef->getAnonymous(),
605 qname,
606 baseXQType,
607 TypeConstants::QUANT_ONE,
608@@ -1310,9 +1313,10 @@
609 bool xsModelWasChanged;
610 XSModel* model = theGrammarPool->getXSModel(xsModelWasChanged);
611
612- XSNamedMap<XSObject> * typeDefs =
613- model->getComponents(XSConstants::TYPE_DEFINITION);
614- for( uint i = 0; i<typeDefs->getLength(); i++)
615+ XSNamedMap<XSObject>* typeDefs =
616+ model->getComponents(XSConstants::TYPE_DEFINITION);
617+
618+ for( uint i = 0; i < typeDefs->getLength(); i++)
619 {
620 XSTypeDefinition* typeDef = (XSTypeDefinition*)(typeDefs->item(i));
621 checkForAnonymousTypesInType(typeManager, typeDef);
622@@ -1529,6 +1533,7 @@
623
624 xqtref_t xqType =
625 xqtref_t(new UserDefinedXQType(typeManager,
626+ xsTypeDef->getAnonymous(),
627 qname,
628 baseXQType,
629 TypeConstants::QUANT_ONE,
630
631=== modified file 'src/types/schema/schema.h'
632--- src/types/schema/schema.h 2013-02-07 17:24:36 +0000
633+++ src/types/schema/schema.h 2013-04-30 21:00:38 +0000
634@@ -43,6 +43,7 @@
635 namespace XERCES_CPP_NAMESPACE {
636 class InputSource;
637 class XSTypeDefinition;
638+ class XSElementDeclaration;
639 class XSParticle;
640 class XMLGrammarPool;
641 }
642@@ -106,31 +107,33 @@
643
644 void registerXSD(
645 const char* xsdURL,
646- static_context * aSctx,
647- internal::StreamResource* aStreamResource,
648+ static_context* sctx,
649+ internal::StreamResource* streamResource,
650 const QueryLoc& loc);
651
652 void getSubstitutionHeadForElement(
653 const store::Item* qname,
654 store::Item_t& result);
655
656- void getTypeNameFromElementName(
657- const store::Item* qname,
658- store::Item_t& typeName,
659- const QueryLoc& loc);
660-
661- void getTypeNameFromAttributeName(
662- const store::Item* qname,
663- store::Item_t& typeName,
664- const QueryLoc& loc);
665-
666- xqtref_t createXQTypeFromElementName(
667+ void getInfoFromGlobalElementDecl(
668+ const store::Item* qname,
669+ store::Item_t& typeName,
670+ bool& nillable,
671+ const QueryLoc& loc);
672+
673+ xqtref_t createXQTypeFromGlobalElementDecl(
674 const TypeManager* typeManager,
675 const store::Item* qname,
676- const bool riseErrors,
677- const QueryLoc& loc);
678-
679- xqtref_t createXQTypeFromAttributeName(
680+ const bool raiseErrors,
681+ bool& nillable,
682+ const QueryLoc& loc);
683+
684+ void getInfoFromGlobalAttributeDecl(
685+ const store::Item* qname,
686+ store::Item_t& typeName,
687+ const QueryLoc& loc);
688+
689+ xqtref_t createXQTypeFromGlobalAttributeDecl(
690 const TypeManager* typeManager,
691 const store::Item* qname,
692 const bool riseErrors,
693@@ -194,11 +197,11 @@
694 private:
695
696 #ifndef ZORBA_NO_XMLSCHEMA
697- XERCES_CPP_NAMESPACE::XSTypeDefinition*
698- getTypeDefForElement(const store::Item* qname);
699+ XERCES_CPP_NAMESPACE::XSElementDeclaration* getDeclForElement(
700+ const store::Item* qname);
701
702- XERCES_CPP_NAMESPACE::XSTypeDefinition*
703- getTypeDefForAttribute(const store::Item* qname);
704+ XERCES_CPP_NAMESPACE::XSTypeDefinition* getTypeDefForAttribute(
705+ const store::Item* qname);
706
707 xqtref_t createXQTypeFromTypeDefinition(
708 const TypeManager* typeManager,
709
710=== modified file 'src/types/schema/validate.cpp'
711--- src/types/schema/validate.cpp 2013-02-07 17:24:36 +0000
712+++ src/types/schema/validate.cpp 2013-04-30 21:00:38 +0000
713@@ -193,20 +193,22 @@
714 {
715 schemaValidator.startDoc();
716
717- // ask for the type of the root element to populate
718- // the cache with anonymous types
719 store::Iterator_t children = sourceNode->getChildren();
720 store::Item_t child;
721 while ( children->next(child) )
722 {
723+ // ask for the type of the element. We don't really need this type here,
724+ // but a side-effect of this call is to add the type to the cache.
725 if ( child->isNode() &&
726 child->getNodeKind()==store::StoreConsts::elementNode )
727 {
728+ bool nillable;
729 typeManager->getSchema()->
730- createXQTypeFromElementName(typeManager,
731- child->getNodeName(),
732- false,
733- loc);
734+ createXQTypeFromGlobalElementDecl(typeManager,
735+ child->getNodeName(),
736+ false,
737+ nillable,
738+ loc);
739 break;
740 }
741 }
742@@ -259,13 +261,15 @@
743 //cout << "Validate element" << "\n"; cout.flush();
744 schemaValidator.startDoc();
745
746- // ask for the type of the root element to populate the cache
747- // with anonymous types
748+ // ask for the type of the element. We don't really need this type here,
749+ // but a side-effect of this call is to add the type to the cache.
750+ bool nillable;
751 typeManager->getSchema()->
752- createXQTypeFromElementName(typeManager,
753- sourceNode->getNodeName(),
754- false,
755- loc);
756+ createXQTypeFromGlobalElementDecl(typeManager,
757+ sourceNode->getNodeName(),
758+ false,
759+ nillable,
760+ loc);
761 }
762
763 store::Item_t newElem = processElement(sctx,
764
765=== modified file 'src/types/typeimpl.cpp'
766--- src/types/typeimpl.cpp 2013-03-22 00:38:18 +0000
767+++ src/types/typeimpl.cpp 2013-04-30 21:00:38 +0000
768@@ -29,6 +29,7 @@
769 #include "zorbaserialization/serialize_template_types.h"
770 #include "zorbaserialization/serialize_zorba_types.h"
771
772+#include "store/api/iterator.h"
773
774 namespace zorba
775 {
776@@ -718,11 +719,11 @@
777 bool builtin)
778 :
779 XQType(manager, NODE_TYPE_KIND, quantifier, builtin),
780- m_node_kind(nodeKind),
781- m_node_name(nodeName),
782+ theNodeKind(nodeKind),
783+ theNodeName(nodeName),
784 theContentType(contentType),
785- m_nillable(nillable),
786- m_schema_test(schematest)
787+ theNillable(nillable),
788+ theIsSchemaTest(schematest)
789 {
790 assert(contentType == NULL ||
791 (nodeKind == store::StoreConsts::documentNode &&
792@@ -754,11 +755,11 @@
793 TypeConstants::quantifier_t quantifier)
794 :
795 XQType(source.theManager, NODE_TYPE_KIND, quantifier, false),
796- m_node_kind(source.m_node_kind),
797- m_node_name(source.m_node_name),
798+ theNodeKind(source.theNodeKind),
799+ theNodeName(source.theNodeName),
800 theContentType(source.theContentType),
801- m_nillable(source.m_nillable),
802- m_schema_test(source.m_schema_test)
803+ theNillable(source.theNillable),
804+ theIsSchemaTest(source.theIsSchemaTest)
805 {
806 }
807
808@@ -769,11 +770,11 @@
809 void NodeXQType::serialize(::zorba::serialization::Archiver& ar)
810 {
811 serialize_baseclass(ar, (XQType*)this);
812- SERIALIZE_ENUM(store::StoreConsts::NodeKind, m_node_kind);
813- ar & m_node_name;
814+ SERIALIZE_ENUM(store::StoreConsts::NodeKind, theNodeKind);
815+ ar & theNodeName;
816 ar & theContentType;
817- ar & m_nillable;
818- ar & m_schema_test;
819+ ar & theNillable;
820+ ar & theIsSchemaTest;
821 }
822
823
824@@ -791,15 +792,15 @@
825 ********************************************************************************/
826 bool NodeXQType::is_equal(const TypeManager* tm, const NodeXQType& other) const
827 {
828- if (m_node_kind != other.m_node_kind)
829+ if (theNodeKind != other.theNodeKind)
830 return false;
831
832- if (m_node_name != other.m_node_name)
833+ if (theNodeName != other.theNodeName)
834 {
835- if (m_node_name == NULL || other.m_node_name == NULL)
836+ if (theNodeName == NULL || other.theNodeName == NULL)
837 return false;
838
839- if (!m_node_name->equals(other.m_node_name))
840+ if (!theNodeName->equals(other.theNodeName))
841 return false;
842 }
843
844@@ -829,7 +830,7 @@
845 const NodeXQType& supertype,
846 const QueryLoc& loc) const
847 {
848- if (supertype.m_node_kind == store::StoreConsts::anyNode)
849+ if (supertype.theNodeKind == store::StoreConsts::anyNode)
850 {
851 if (supertype.theContentType != NULL &&
852 supertype.theContentType->type_kind() == XQType::UNTYPED_KIND)
853@@ -841,17 +842,17 @@
854 return true;
855 }
856
857- if (supertype.m_node_kind != m_node_kind)
858+ if (supertype.theNodeKind != theNodeKind)
859 return false;
860
861- if (supertype.m_node_name != NULL)
862+ if (supertype.theNodeName != NULL)
863 {
864- if (m_node_name == NULL)
865+ if (theNodeName == NULL)
866 return false;
867
868- if (!m_node_name->equals(supertype.m_node_name))
869+ if (!theNodeName->equals(supertype.theNodeName))
870 {
871- if (supertype.m_schema_test)
872+ if (supertype.theIsSchemaTest)
873 {
874 Schema* schema = supertype.theManager->getSchema();
875 ZORBA_ASSERT(schema != NULL);
876@@ -859,11 +860,11 @@
877 store::Item_t headName;
878
879 #ifndef ZORBA_NO_XMLSCHEMA
880- schema->getSubstitutionHeadForElement(m_node_name.getp(), headName);
881+ schema->getSubstitutionHeadForElement(theNodeName.getp(), headName);
882
883 while (headName != NULL)
884 {
885- if (headName->equals(supertype.m_node_name))
886+ if (headName->equals(supertype.theNodeName))
887 {
888 break;
889 }
890@@ -883,10 +884,18 @@
891 }
892
893 if (theContentType == supertype.theContentType)
894+ {
895+ if (supertype.theNillable == false && theNillable == true)
896+ return false;
897+
898 return true;
899+ }
900
901 if (theContentType != NULL && supertype.theContentType != NULL)
902 {
903+ if (supertype.theNillable == false && theNillable == true)
904+ return false;
905+
906 return TypeOps::is_subtype(tm, *theContentType, *supertype.theContentType);
907 }
908 else if (supertype.theContentType == NULL)
909@@ -912,7 +921,7 @@
910 {
911 assert(subitem->isNode());
912
913- if (m_node_kind == store::StoreConsts::anyNode)
914+ if (theNodeKind == store::StoreConsts::anyNode)
915 {
916 if (theContentType != NULL &&
917 theContentType->type_kind() == XQType::UNTYPED_KIND)
918@@ -923,74 +932,152 @@
919 return true;
920 }
921
922- if (m_node_kind != subitem->getNodeKind())
923+ if (theNodeKind != subitem->getNodeKind())
924 return false;
925
926- if (m_node_name != NULL)
927- {
928- if (!subitem->getNodeName()->equals(m_node_name))
929- {
930- if (m_schema_test)
931+ switch (theNodeKind)
932+ {
933+ case store::StoreConsts::textNode:
934+ case store::StoreConsts::commentNode:
935+ case store::StoreConsts::namespaceNode:
936+ {
937+ return true;
938+ }
939+ case store::StoreConsts::piNode:
940+ {
941+ if (theNodeName != NULL && !subitem->getNodeName()->equals(theNodeName))
942+ return false;
943+
944+ return true;
945+ }
946+ case store::StoreConsts::attributeNode:
947+ {
948+ assert(!theIsSchemaTest || (theNodeName && theContentType));
949+
950+ if (theNodeName != NULL && !subitem->getNodeName()->equals(theNodeName))
951+ return false;
952+
953+ if (theContentType != NULL)
954+ {
955+ xqtref_t subContentType =
956+ tm->create_named_type(subitem->getType(), TypeConstants::QUANT_ONE, loc, true);
957+
958+ return TypeOps::is_subtype(tm, *subContentType, *theContentType);
959+ }
960+
961+ return true;
962+ }
963+ case store::StoreConsts::elementNode:
964+ {
965+ if (theIsSchemaTest)
966+ {
967+ assert(theNodeName != NULL);
968+
969+ if (!subitem->getNodeName()->equals(theNodeName))
970 {
971 Schema* schema = theManager->getSchema();
972 ZORBA_ASSERT(schema != NULL);
973-
974+
975 store::Item_t headName;
976-
977+
978 #ifndef ZORBA_NO_XMLSCHEMA
979 schema->getSubstitutionHeadForElement(subitem->getNodeName(), headName);
980-
981+
982 while (headName != NULL)
983 {
984- if (headName->equals(m_node_name))
985- {
986+ if (headName->equals(theNodeName))
987 break;
988- }
989-
990+
991 schema->getSubstitutionHeadForElement(headName.getp(), headName);
992 }
993 #endif // ZORBA_NO_XMLSCHEMA
994-
995+
996 if (headName == NULL)
997 return false;
998 }
999- else
1000+
1001+ if (theContentType == NULL ||
1002+ theContentType->type_kind() == XQType::ANY_TYPE_KIND)
1003+ return true;
1004+
1005+ xqtref_t subContentType = tm->create_named_type(subitem->getType(),
1006+ TypeConstants::QUANT_ONE,
1007+ loc,
1008+ true);
1009+
1010+ if (!TypeOps::is_subtype(tm, *subContentType, *theContentType))
1011+ return false;
1012+
1013+ bool nillable;
1014+ store::Item_t typeName;
1015+ tm->get_schema_element_typeinfo(subitem->getNodeName(), typeName, nillable, loc);
1016+
1017+ if (!nillable && subitem->getNilled())
1018+ return false;
1019+
1020+ return true;
1021+ }
1022+ else
1023+ {
1024+ if (theNodeName != NULL && !subitem->getNodeName()->equals(theNodeName))
1025+ return false;
1026+
1027+ if (!theNillable && subitem->getNilled())
1028+ return false;
1029+
1030+ if (theContentType == NULL ||
1031+ theContentType->type_kind() == XQType::ANY_TYPE_KIND)
1032+ return true;
1033+
1034+ xqtref_t subContentType =
1035+ tm->create_named_type(subitem->getType(), TypeConstants::QUANT_ONE, loc, true);
1036+
1037+ return TypeOps::is_subtype(tm, *subContentType, *theContentType);
1038+ }
1039+ }
1040+ case store::StoreConsts::documentNode:
1041+ {
1042+ if (theContentType == NULL ||
1043+ theContentType->type_kind() == XQType::ANY_TYPE_KIND)
1044+ return true;
1045+
1046+ if (theContentType->type_kind() == XQType::UNTYPED_KIND)
1047+ {
1048+ return !subitem->isValidated();
1049+ }
1050+
1051+ ZORBA_ASSERT(theContentType->type_kind() == XQType::NODE_TYPE_KIND);
1052+
1053+ store::Iterator_t childrenIte = subitem->getChildren();
1054+ store::Item_t child;
1055+ store::Item_t elemChild;
1056+ csize numElemChildren = 0;
1057+ childrenIte->open();
1058+ while (childrenIte->next(child))
1059+ {
1060+ if (child->getNodeKind() == store::StoreConsts::elementNode)
1061 {
1062- return false;
1063+ if (numElemChildren == 0)
1064+ elemChild.transfer(child);
1065+
1066+ ++numElemChildren;
1067 }
1068 }
1069+ childrenIte->close();
1070+
1071+ if (numElemChildren != 1)
1072+ return false;
1073+
1074+ const NodeXQType* elemTestType =
1075+ static_cast<const NodeXQType*>(theContentType.getp());
1076+
1077+ return elemTestType->is_supertype(tm, elemChild, loc);
1078 }
1079-
1080- // document-node(E) matches any document node that contains exactly one element
1081- // node, optionally accompanied by one or more comment and processing instruction
1082- // nodes, if E is an ElementTest or SchemaElementTest that matches the element node.
1083- bool is_element_test = (
1084- m_node_kind == store::StoreConsts::documentNode &&
1085- theContentType != NULL &&
1086- theContentType->type_kind() == XQType::NODE_TYPE_KIND &&
1087- static_cast<const NodeXQType*>(theContentType.getp())->m_schema_test == false);
1088-
1089- if (m_node_kind != store::StoreConsts::elementNode &&
1090- m_node_kind != store::StoreConsts::attributeNode &&
1091- !is_element_test)
1092- return true;
1093-
1094- if (theContentType == NULL ||
1095- theContentType->type_kind() == XQType::ANY_TYPE_KIND)
1096- return true;
1097-
1098- if (is_element_test)
1099+ default:
1100 {
1101- xqtref_t documentNodeType = tm->create_value_type(subitem, loc);
1102- return TypeOps::is_subtype(tm, *documentNodeType, *this);
1103- }
1104-
1105- xqtref_t subContentType = tm->create_named_type(subitem->getType(),
1106- TypeConstants::QUANT_ONE,
1107- loc,
1108- true);
1109-
1110- return TypeOps::is_subtype(tm, *subContentType, *theContentType);
1111+ ZORBA_ASSERT(false);
1112+ }
1113+ }
1114 }
1115
1116
1117@@ -999,16 +1086,16 @@
1118 ********************************************************************************/
1119 std::ostream& NodeXQType::serialize_ostream(std::ostream& os) const
1120 {
1121- store::StoreConsts::NodeKind node_kind = m_node_kind;
1122+ store::StoreConsts::NodeKind node_kind = theNodeKind;
1123 xqtref_t content_type = get_content_type();
1124
1125 os << "[NodeXQType " << store::StoreConsts::toString(node_kind)
1126 << TypeOps::decode_quantifier(get_quantifier());
1127
1128- if (m_node_name != NULL)
1129+ if (theNodeName != NULL)
1130 {
1131- os << " nametest=[uri: " << m_node_name->getNamespace()
1132- << ", local: " << m_node_name->getLocalName() << "]";
1133+ os << " nametest=[uri: " << theNodeName->getNamespace()
1134+ << ", local: " << theNodeName->getLocalName() << "]";
1135 }
1136
1137 if (content_type != NULL)
1138@@ -1025,7 +1112,7 @@
1139 {
1140 std::ostringstream os;
1141
1142- if (m_node_kind == store::StoreConsts::documentNode)
1143+ if (theNodeKind == store::StoreConsts::documentNode)
1144 {
1145 os << "document-node(";
1146
1147@@ -1035,26 +1122,26 @@
1148 os << ", " << theContentType->toSchemaString();
1149 }
1150 }
1151- else if (m_schema_test)
1152+ else if (theIsSchemaTest)
1153 {
1154 assert(theContentType != NULL);
1155
1156 os << "schema-" << store::StoreConsts::toSchemaString(get_node_kind()) << "("
1157- << m_node_name->getStringValue();
1158+ << theNodeName->getStringValue();
1159 }
1160 else
1161 {
1162 os << store::StoreConsts::toSchemaString(get_node_kind()) << "(";
1163
1164- if (m_node_name != NULL)
1165+ if (theNodeName != NULL)
1166 {
1167- os << m_node_name->getStringValue();
1168+ os << theNodeName->getStringValue();
1169
1170 if (theContentType != NULL)
1171 {
1172 os << ", " << theContentType->toSchemaString();
1173
1174- if (m_nillable)
1175+ if (theNillable)
1176 os << "?";
1177 }
1178 }
1179@@ -1062,7 +1149,7 @@
1180 {
1181 os << "*, " << theContentType->toSchemaString();
1182
1183- if (m_nillable)
1184+ if (theNillable)
1185 os << "?";
1186 }
1187 }
1188@@ -1238,6 +1325,7 @@
1189 ********************************************************************************/
1190 UserDefinedXQType::UserDefinedXQType(
1191 const TypeManager* manager,
1192+ bool isAnonymous,
1193 store::Item_t qname,
1194 const xqtref_t& baseType,
1195 TypeConstants::quantifier_t quantifier,
1196@@ -1246,8 +1334,9 @@
1197 bool builtin)
1198 :
1199 XQType(manager, USER_DEFINED_KIND, quantifier, builtin),
1200+ theIsAnonymous(isAnonymous),
1201 theQName(qname),
1202- m_baseType(baseType),
1203+ theBaseType(baseType),
1204 theUDTKind(udtKind),
1205 m_contentKind(contentKind)
1206 {
1207@@ -1267,14 +1356,16 @@
1208 ********************************************************************************/
1209 UserDefinedXQType::UserDefinedXQType(
1210 const TypeManager* manager,
1211+ bool isAnonymous,
1212 store::Item_t qname,
1213 const xqtref_t& baseType,
1214 const XQType* listItemType,
1215 bool builtin)
1216 :
1217 XQType(manager, USER_DEFINED_KIND, TypeConstants::QUANT_STAR, builtin),
1218+ theIsAnonymous(isAnonymous),
1219 theQName(qname),
1220- m_baseType(baseType),
1221+ theBaseType(baseType),
1222 theUDTKind(LIST_UDT),
1223 m_contentKind(SIMPLE_CONTENT_KIND),
1224 m_listItemType(listItemType)
1225@@ -1288,6 +1379,7 @@
1226 ********************************************************************************/
1227 UserDefinedXQType::UserDefinedXQType(
1228 const TypeManager* manager,
1229+ bool isAnonymous,
1230 store::Item_t qname,
1231 const xqtref_t& baseType,
1232 TypeConstants::quantifier_t quantifier,
1233@@ -1295,8 +1387,9 @@
1234 bool builtin)
1235 :
1236 XQType(manager, USER_DEFINED_KIND, quantifier, builtin),
1237+ theIsAnonymous(isAnonymous),
1238 theQName(qname),
1239- m_baseType(baseType),
1240+ theBaseType(baseType),
1241 theUDTKind(UNION_UDT),
1242 m_contentKind(SIMPLE_CONTENT_KIND),
1243 m_unionItemTypes(unionItemTypes)
1244@@ -1317,7 +1410,7 @@
1245 {
1246 serialize_baseclass(ar, (XQType*)this);
1247 ar & theQName;
1248- ar & m_baseType;
1249+ ar & theBaseType;
1250 SERIALIZE_ENUM(UDTKind, theUDTKind);
1251 SERIALIZE_ENUM(content_kind_t, m_contentKind);
1252 ar & m_listItemType;
1253@@ -1330,7 +1423,7 @@
1254 ********************************************************************************/
1255 xqtref_t UserDefinedXQType::getBaseBuiltinType() const
1256 {
1257- xqtref_t builtinType = m_baseType;
1258+ xqtref_t builtinType = theBaseType;
1259
1260 while (builtinType->type_kind() == XQType::USER_DEFINED_KIND)
1261 {
1262@@ -1501,7 +1594,7 @@
1263 << theQName->getNamespace() << " "
1264 << info.str()
1265 << " base:"
1266- << ( m_baseType ? m_baseType->toString() : "NULL" )
1267+ << ( theBaseType ? theBaseType->toString() : "NULL" )
1268 << "]";
1269 }
1270
1271
1272=== modified file 'src/types/typeimpl.h'
1273--- src/types/typeimpl.h 2013-03-08 15:03:58 +0000
1274+++ src/types/typeimpl.h 2013-04-30 21:00:38 +0000
1275@@ -375,6 +375,8 @@
1276
1277 int card() const;
1278
1279+ virtual bool isAnonymous() const { return false; }
1280+
1281 bool isComplex() const;
1282
1283 bool isList() const;
1284@@ -567,11 +569,11 @@
1285 friend class XQType;
1286
1287 private:
1288- store::StoreConsts::NodeKind m_node_kind;
1289- store::Item_t m_node_name;
1290+ store::StoreConsts::NodeKind theNodeKind;
1291+ store::Item_t theNodeName;
1292 xqtref_t theContentType;
1293- bool m_nillable;
1294- bool m_schema_test;
1295+ bool theNillable;
1296+ bool theIsSchemaTest;
1297
1298 public:
1299 SERIALIZABLE_CLASS(NodeXQType)
1300@@ -589,19 +591,17 @@
1301 bool schematest,
1302 bool builtin = false);
1303
1304- NodeXQType(
1305- const NodeXQType& source,
1306- TypeConstants::quantifier_t quantifier);
1307-
1308- store::StoreConsts::NodeKind get_node_kind() const { return m_node_kind; }
1309-
1310- store::Item* get_node_name() const { return m_node_name.getp(); }
1311-
1312- bool is_schema_test() const { return m_schema_test; }
1313+ NodeXQType(const NodeXQType& source, TypeConstants::quantifier_t quant);
1314+
1315+ store::StoreConsts::NodeKind get_node_kind() const { return theNodeKind; }
1316+
1317+ store::Item* get_node_name() const { return theNodeName.getp(); }
1318+
1319+ bool is_schema_test() const { return theIsSchemaTest; }
1320
1321 const XQType* get_content_type() const { return theContentType.getp(); }
1322
1323- bool get_nillable() const { return m_nillable; }
1324+ bool get_nillable() const { return theNillable; }
1325
1326 bool is_untyped() const;
1327
1328@@ -718,7 +718,7 @@
1329 ------------
1330 The baseType of this type. NULL for list or union types.
1331
1332- m_typeCategory:
1333+ theUDTKind:
1334 ---------------
1335 Whether this is an atomic, list, union, or complex type.
1336
1337@@ -743,9 +743,11 @@
1338
1339
1340 private:
1341+ bool theIsAnonymous;
1342+
1343 store::Item_t theQName;
1344
1345- xqtref_t m_baseType;
1346+ xqtref_t theBaseType;
1347
1348 UDTKind theUDTKind;
1349
1350@@ -767,6 +769,7 @@
1351 // constructor for Atomic and Complex types
1352 UserDefinedXQType(
1353 const TypeManager* manager,
1354+ bool isAnonymous,
1355 store::Item_t qname,
1356 const xqtref_t& baseType,
1357 TypeConstants::quantifier_t quantifier,
1358@@ -777,6 +780,7 @@
1359 // Constructor for List types
1360 UserDefinedXQType(
1361 const TypeManager* manager,
1362+ bool isAnonymous,
1363 store::Item_t qname,
1364 const xqtref_t& baseType,
1365 const XQType* listItemType,
1366@@ -785,6 +789,7 @@
1367 // Constructor for Union types
1368 UserDefinedXQType(
1369 const TypeManager* manager,
1370+ bool isAnonymous,
1371 store::Item_t qname,
1372 const xqtref_t& baseType,
1373 TypeConstants::quantifier_t quantifier,
1374@@ -793,11 +798,13 @@
1375
1376 virtual ~UserDefinedXQType() {}
1377
1378+ virtual bool isAnonymous() const { return theIsAnonymous; }
1379+
1380 virtual content_kind_t content_kind() const { return m_contentKind; };
1381
1382 UDTKind getUDTKind() const { return theUDTKind; }
1383
1384- xqtref_t getBaseType() const { return m_baseType; }
1385+ xqtref_t getBaseType() const { return theBaseType; }
1386
1387 xqtref_t getBaseBuiltinType() const;
1388
1389
1390=== modified file 'src/types/typemanager.h'
1391--- src/types/typemanager.h 2013-02-07 17:24:36 +0000
1392+++ src/types/typemanager.h 2013-04-30 21:00:38 +0000
1393@@ -159,17 +159,18 @@
1394 TypeConstants::quantifier_t quant,
1395 const QueryLoc& loc) const = 0;
1396
1397- virtual void get_schema_element_typename(
1398+ virtual void get_schema_element_typeinfo(
1399 const store::Item* elemName,
1400 store::Item_t& typeName,
1401- const QueryLoc& loc) = 0;
1402+ bool& nillable,
1403+ const QueryLoc& loc) const = 0;
1404
1405 virtual xqtref_t create_schema_attribute_type(
1406 const store::Item_t& aName,
1407 TypeConstants::quantifier_t quant,
1408 const QueryLoc& loc) const = 0;
1409
1410- virtual void get_schema_attribute_typename(
1411+ virtual void get_schema_attribute_typeinfo(
1412 const store::Item* attrName,
1413 store::Item_t& typeName,
1414 const QueryLoc& loc) = 0;
1415
1416=== modified file 'src/types/typemanagerimpl.cpp'
1417--- src/types/typemanagerimpl.cpp 2013-04-16 07:39:27 +0000
1418+++ src/types/typemanagerimpl.cpp 2013-04-30 21:00:38 +0000
1419@@ -893,14 +893,16 @@
1420 ERROR_PARAMS(ZED(XPST0008_SchemaElementName_2), elemName->getStringValue()));
1421 }
1422
1423+ bool nillable;
1424+
1425 xqtref_t contentType =
1426- m_schema->createXQTypeFromElementName(this, elemName, true, loc);
1427+ m_schema->createXQTypeFromGlobalElementDecl(this, elemName, true, nillable, loc);
1428
1429 return create_node_type(store::StoreConsts::elementNode,
1430 elemName,
1431 contentType,
1432 quant,
1433- false, // nillable
1434+ nillable,
1435 true); // schematest
1436 }
1437
1438@@ -908,10 +910,11 @@
1439 /***************************************************************************//**
1440 Get the name of the type associated with a given globally declared element name.
1441 ********************************************************************************/
1442-void TypeManagerImpl::get_schema_element_typename(
1443+void TypeManagerImpl::get_schema_element_typeinfo(
1444 const store::Item* elemName,
1445 store::Item_t& typeName,
1446- const QueryLoc& loc)
1447+ bool& nillable,
1448+ const QueryLoc& loc) const
1449 {
1450 if (m_schema == NULL)
1451 {
1452@@ -919,7 +922,7 @@
1453 ERROR_PARAMS(ZED(XPST0008_SchemaElementName_2), elemName->getStringValue()));
1454 }
1455
1456- m_schema->getTypeNameFromElementName(elemName, typeName, loc);
1457+ m_schema->getInfoFromGlobalElementDecl(elemName, typeName, nillable, loc);
1458 }
1459
1460
1461@@ -941,7 +944,7 @@
1462 }
1463
1464 xqtref_t contentType =
1465- m_schema->createXQTypeFromAttributeName(this, attrName, true, loc);
1466+ m_schema->createXQTypeFromGlobalAttributeDecl(this, attrName, true, loc);
1467
1468 return create_node_type(store::StoreConsts::attributeNode,
1469 attrName,
1470@@ -956,7 +959,7 @@
1471 Get the name of the type associated with a given globally declared attribute
1472 name.
1473 ********************************************************************************/
1474-void TypeManagerImpl::get_schema_attribute_typename(
1475+void TypeManagerImpl::get_schema_attribute_typeinfo(
1476 const store::Item* attrName,
1477 store::Item_t& typeName,
1478 const QueryLoc& loc)
1479@@ -967,7 +970,7 @@
1480 ERROR_PARAMS(ZED(XPST0008_SchemaAttributeName_2), attrName->getStringValue()));
1481 }
1482
1483- m_schema->getTypeNameFromAttributeName(attrName, typeName, loc);
1484+ m_schema->getInfoFromGlobalAttributeDecl(attrName, typeName, loc);
1485 }
1486
1487
1488@@ -1062,6 +1065,7 @@
1489 if (udt.isList())
1490 {
1491 return new UserDefinedXQType(this,
1492+ udt.isAnonymous(),
1493 udt.getQName(),
1494 udt.getBaseType(),
1495 udt.getListItemType());
1496@@ -1069,6 +1073,7 @@
1497 else if (udt.isUnion())
1498 {
1499 return new UserDefinedXQType(this,
1500+ udt.isAnonymous(),
1501 udt.getQName(),
1502 udt.getBaseType(),
1503 quantifier,
1504@@ -1077,6 +1082,7 @@
1505 else
1506 {
1507 return new UserDefinedXQType(this,
1508+ udt.isAnonymous(),
1509 udt.getQName(),
1510 udt.getBaseType(),
1511 quantifier,
1512
1513=== modified file 'src/types/typemanagerimpl.h'
1514--- src/types/typemanagerimpl.h 2013-02-07 17:24:36 +0000
1515+++ src/types/typemanagerimpl.h 2013-04-30 21:00:38 +0000
1516@@ -148,17 +148,18 @@
1517 TypeConstants::quantifier_t quant,
1518 const QueryLoc& loc) const;
1519
1520- void get_schema_element_typename(
1521+ void get_schema_element_typeinfo(
1522 const store::Item* elemName,
1523 store::Item_t& typeName,
1524- const QueryLoc& loc);
1525+ bool& nillable,
1526+ const QueryLoc& loc) const;
1527
1528 xqtref_t create_schema_attribute_type(
1529 const store::Item_t& attrName,
1530 TypeConstants::quantifier_t quant,
1531 const QueryLoc& loc) const;
1532
1533- void get_schema_attribute_typename(
1534+ void get_schema_attribute_typeinfo(
1535 const store::Item* attrName,
1536 store::Item_t& typeName,
1537 const QueryLoc& loc);
1538
1539=== modified file 'src/types/typeops.cpp'
1540--- src/types/typeops.cpp 2013-03-16 08:48:16 +0000
1541+++ src/types/typeops.cpp 2013-04-30 21:00:38 +0000
1542@@ -131,20 +131,32 @@
1543 return false;
1544
1545 #ifndef ZORBA_NO_XMLSCHEMA
1546- if (ntype.get_node_kind() == store::StoreConsts::elementNode)
1547- {
1548- return (schema->createXQTypeFromElementName(tm,
1549- ntype.get_node_name(),
1550- false,
1551- QueryLoc::null) != NULL);
1552- }
1553- else
1554- {
1555- return (schema->createXQTypeFromAttributeName(tm,
1556- ntype.get_node_name(),
1557- false,
1558- QueryLoc::null) != NULL);
1559- }
1560+ try
1561+ {
1562+ bool nillable;
1563+ store::Item_t typeName;
1564+ if (ntype.get_node_kind() == store::StoreConsts::elementNode)
1565+ {
1566+ schema->getInfoFromGlobalElementDecl(ntype.get_node_name(),
1567+ typeName,
1568+ nillable,
1569+ QueryLoc::null);
1570+ }
1571+ else
1572+ {
1573+ schema->getInfoFromGlobalAttributeDecl(ntype.get_node_name(),
1574+ typeName,
1575+ QueryLoc::null);
1576+ }
1577+ }
1578+ catch (ZorbaException& e)
1579+ {
1580+ if (e.diagnostic() == err::XPST0008)
1581+ return false;
1582+
1583+ throw;
1584+ }
1585+
1586 #else
1587 throw ZORBA_EXCEPTION(err::XQST0009);
1588 #endif
1589
1590=== modified file 'test/fots/CMakeLists.txt'
1591--- test/fots/CMakeLists.txt 2013-04-30 18:31:49 +0000
1592+++ test/fots/CMakeLists.txt 2013-04-30 21:00:38 +0000
1593@@ -134,6 +134,22 @@
1594 EXPECTED_FOTS_FAILURE (DISPUTED prod-OrderByClause orderBy20 21619)
1595 EXPECTED_FOTS_FAILURE (DISPUTED prod-OrderByClause orderBy21 21619)
1596 EXPECTED_FOTS_FAILURE (DISPUTED misc-CombinedErrorCodes XQST0085 21730)
1597+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-001 21568)
1598+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-003 21568)
1599+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-005 21568)
1600+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-007 21568)
1601+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-009 21568)
1602+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-012 21568)
1603+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-013 21568)
1604+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-015 21568)
1605+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-017 21568)
1606+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-019 21568)
1607+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-021 21568)
1608+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-023 21568)
1609+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-025 21568)
1610+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-027 21568)
1611+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-029 21568)
1612+EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-031 21568)
1613 EXPECTED_FOTS_FAILURE (DISPUTED prod-VarDefaultValue extvardef-006b 21832)
1614
1615 # Next three possibly unique to old RQ machine, but they need to be
1616@@ -186,21 +202,6 @@
1617 EXPECTED_FOTS_FAILURE (fn-generate-id generate-id-015 0)
1618 EXPECTED_FOTS_FAILURE (fn-generate-id generate-id-017 0)
1619 EXPECTED_FOTS_FAILURE (fn-matches cbcl-matches-038 1131304)
1620-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-33 0)
1621-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-35 0)
1622-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-37 0)
1623-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-38 0)
1624-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-39 0)
1625-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-41 0)
1626-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-44 0)
1627-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-45 0)
1628-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-46 0)
1629-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-47 0)
1630-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-50 0)
1631-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-51 0)
1632-EXPECTED_FOTS_FAILURE (fn-nilled fn-nilled-52 0)
1633-EXPECTED_FOTS_FAILURE (fn-nilled cbcl-nilled-002 0)
1634-EXPECTED_FOTS_FAILURE (fn-nilled cbcl-nilled-005 0)
1635 EXPECTED_FOTS_FAILURE (fn-normalize-space fn-normalize-space-23 0)
1636 EXPECTED_FOTS_FAILURE (fn-normalize-space fn-normalize-space-25 0)
1637 EXPECTED_FOTS_FAILURE (fn-normalize-unicode cbcl-fn-normalize-unicode-001 0)
1638@@ -309,22 +310,6 @@
1639 EXPECTED_FOTS_FAILURE (prod-FunctionCall function-call-reserved-function-names-014 0)
1640 EXPECTED_FOTS_FAILURE (prod-FunctionCall function-call-reserved-function-names-015 0)
1641 EXPECTED_FOTS_FAILURE (prod-FunctionCall function-call-reserved-function-names-016 0)
1642-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-001 21568)
1643-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-003 21568)
1644-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-005 21568)
1645-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-007 21568)
1646-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-009 21568)
1647-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-012 21568)
1648-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-013 21568)
1649-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-015 21568)
1650-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-017 21568)
1651-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-019 21568)
1652-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-021 21568)
1653-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-023 21568)
1654-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-025 21568)
1655-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-027 21568)
1656-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-029 21568)
1657-EXPECTED_FOTS_FAILURE (DISPUTED prod-FunctionDecl function-decl-reserved-function-names-031 21568)
1658 EXPECTED_FOTS_FAILURE (prod-InstanceofExpr instanceof113 0)
1659 EXPECTED_FOTS_FAILURE (prod-InstanceofExpr instanceof139 1160559)
1660 EXPECTED_FOTS_FAILURE (prod-InstanceofExpr instanceof140 0)
1661
1662=== modified file 'test/rbkt/Queries/zorba/schemas/books.xsd'
1663--- test/rbkt/Queries/zorba/schemas/books.xsd 2013-02-07 17:24:36 +0000
1664+++ test/rbkt/Queries/zorba/schemas/books.xsd 2013-04-30 21:00:38 +0000
1665@@ -5,8 +5,8 @@
1666 elementFormDefault="qualified">
1667
1668 <!-- importing the XML namespace makes xml:id an ID attribute under lax validation -->
1669- <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
1670-
1671+ <xs:import namespace="http://www.w3.org/XML/1998/namespace"
1672+ schemaLocation="http://www.w3.org/2001/xml.xsd"/>
1673
1674 <xs:element name="BOOKLIST">
1675 <xs:complexType>
1676
1677=== modified file 'test/update/Scripts/Readme.txt'
1678--- test/update/Scripts/Readme.txt 2013-02-07 17:24:36 +0000
1679+++ test/update/Scripts/Readme.txt 2013-04-30 21:00:38 +0000
1680@@ -14,12 +14,13 @@
1681 #
1682 To generate a report for submitting to the W3C:
1683
1684-0. For submitting reports to W3C one should compile Zorba with:
1685+0. For submitting reports to W3C one should compile Zorba with
1686 ZORBA_WITH_BIG_INTEGER=ON
1687 ZORBA_XQUERYX=ON
1688 ZORBA_TEST_XQUERYX=ON
1689 ZORBA_TEST_W3C_TO_SUBMIT_RESULTS=ON
1690 ZORBA_WITH_JSON=OFF
1691+ And make sure you are using at least Xerces version 3.1.1.
1692
1693 1. Import XQUTS.
1694
1695@@ -62,5 +63,3 @@
1696 7. Modify /tmp/XQUTS_1_0_1/ReportingResults/Results.xml by adding a result node for every report you copied at step 5.
1697
1698 8. From /tmp/XQUTS_1_0_1/ReportingResults/ run 'ant -buildfile Build.xml' in order to generate XQUTSReport.html and XQUTSReportSimple.html
1699-
1700-
1701
1702=== modified file 'test/update/updtestdriver.cpp'
1703--- test/update/updtestdriver.cpp 2013-03-14 08:01:06 +0000
1704+++ test/update/updtestdriver.cpp 2013-04-30 21:00:38 +0000
1705@@ -44,6 +44,9 @@
1706 #include "system/properties.h"
1707 #include "testdriver_comparator.h"
1708
1709+//#define ZORBA_TEST_PLAN_SERIALIZATION
1710+
1711+
1712 bool isErrorExpected(zorba::ZorbaException& e, State* aState)
1713 {
1714 if ( aState->hasErrors)

Subscribers

People subscribed via source and target branches