Merge lp:~zorba-coders/zorba/bug924987 into lp:zorba
- bug924987
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~zorba-coders/zorba/bug924987 |
Merge into: | lp:zorba |
Diff against target: |
811 lines (+563/-31) 13 files modified
include/zorba/identtypes.h (+16/-2) include/zorba/typeident.h (+34/-1) src/api/CMakeLists.txt (+1/-0) src/api/identtypesimpl.cpp (+60/-0) src/api/typeidentimpl.cpp (+116/-5) src/types/typemanagerimpl.cpp (+32/-0) src/types/typeops.cpp (+55/-22) src/types/typeops.h (+2/-1) test/unit/CMakeLists.txt (+4/-0) test/unit/module5.xq (+20/-0) test/unit/module6.xq (+38/-0) test/unit/schema1.xsd (+21/-0) test/unit/staticcollectionmanager.cpp (+164/-0) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/bug924987 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Needs Fixing | ||
Till Westmann | Approve | ||
Review via email: mp+91144@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-03-06.
Commit message
fixes bug 924987
- extended TypeIdentifier to also support schema-element, schema-attribute
and namespace-node sequence types
- fixed TypeOps:
- added a test to the staticcollectio
- added operator<< for TypeIdentifier
Description of the change
fixes bug 924987
- extended TypeIdentifier to also support schema-element, schema-attribute
and namespace-node sequence types
- fixed TypeOps:
- added a test to the staticcollectio
- added operator<< for TypeIdentifier
Till Westmann (tillw) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug924987-2012-02-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Approve, 2 Pending.
Markos Zaharioudakis (markos-za) wrote : | # |
1. Zorba does not support the (optional) namespace nodes and associated sequence types. So, the releted code should be removed.
2. Why do the createSchemaEle
3. Just curious: why doesn't the emit() method print out the type using the w3c sequence type syntax?
4. An XQType of USER_DEFINED_KIND (i.e., an instance of the UserDefinedXQType class) represents a sequence type only if the type is atomic. So, in TypeOps:
5. To be complete, the TypeManagerImpl
Markos Zaharioudakis (markos-za) : | # |
Till Westmann (tillw) wrote : | # |
1. ok
2. I see your point, but I think that I need information about the content type. Is there a way to get that from the public API? (I looked over the public static context and didn't see something obvious.)
3. Good question. Actually, the type doesn't really reflect the structure of a sequence type. But as it is, it is an extension of the existing on and thus probably compatible.
4. That's interesting. It seems that the schema types also end up there. At least that's how I used it. I had a "as schema-
5. I'll look at that, but first we need to make sure that points 2-4 are clarified.
Zorba Build Bot (zorba-buildbot) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
- 10646. By Markos Zaharioudakis
-
TypeManagerImpl
::create_ type() method - 10647. By Markos Zaharioudakis
-
fix in TypeIdentifier:
:emitItemType( ) method + cosmetic
Unmerged revisions
Preview Diff
1 | === modified file 'include/zorba/identtypes.h' |
2 | --- include/zorba/identtypes.h 2011-09-21 14:49:55 +0000 |
3 | +++ include/zorba/identtypes.h 2012-03-06 03:27:34 +0000 |
4 | @@ -17,6 +17,7 @@ |
5 | #define ZORBA_TYPEIDENT_TYPES_API_H |
6 | |
7 | #include <zorba/config.h> |
8 | +#include <iostream> |
9 | |
10 | namespace zorba { |
11 | class ZORBA_DLL_PUBLIC IdentTypes { |
12 | @@ -32,17 +33,30 @@ |
13 | ANY_NODE_TYPE, // node() |
14 | ITEM_TYPE, // item() |
15 | EMPTY_TYPE, // empty-sequence() |
16 | - INVALID_TYPE, |
17 | + SCHEMA_ELEMENT_TYPE, |
18 | + SCHEMA_ATTRIBUTE_TYPE, |
19 | + INVALID_TYPE |
20 | } kind_t; |
21 | + |
22 | + static char const *const kind_string_of[]; |
23 | |
24 | typedef enum { |
25 | QUANT_ONE, |
26 | QUANT_QUESTION, |
27 | QUANT_PLUS, |
28 | - QUANT_STAR, |
29 | + QUANT_STAR |
30 | } quantifier_t; |
31 | + |
32 | + static char const *const quantifier_string_of[]; |
33 | }; |
34 | } |
35 | |
36 | +namespace std { |
37 | + |
38 | +ZORBA_DLL_PUBLIC ostream& operator<<(ostream& o, const zorba::IdentTypes::kind_t ik); |
39 | +ZORBA_DLL_PUBLIC ostream& operator<<(ostream& o, const zorba::IdentTypes::quantifier_t iq); |
40 | + |
41 | +} |
42 | + |
43 | #endif |
44 | /* vim:set et sw=2 ts=2: */ |
45 | |
46 | === modified file 'include/zorba/typeident.h' |
47 | --- include/zorba/typeident.h 2011-06-14 17:26:33 +0000 |
48 | +++ include/zorba/typeident.h 2012-03-06 03:27:34 +0000 |
49 | @@ -20,6 +20,7 @@ |
50 | #include <zorba/api_shared_types.h> |
51 | #include <zorba/identtypes.h> |
52 | #include <zorba/zorba_string.h> |
53 | +#include <iostream> |
54 | |
55 | namespace zorba { |
56 | |
57 | @@ -61,7 +62,7 @@ |
58 | createAttributeType( |
59 | const String& uri, |
60 | bool uriWildcard, |
61 | - const String& localNameName, |
62 | + const String& localName, |
63 | bool localNameWildcard, |
64 | TypeIdentifier_t contentType, |
65 | IdentTypes::quantifier_t quantifier = IdentTypes::QUANT_ONE |
66 | @@ -108,6 +109,22 @@ |
67 | TypeIdentifier_t |
68 | createEmptyType(); |
69 | |
70 | + static |
71 | + TypeIdentifier_t |
72 | + createSchemaElementType( |
73 | + const String& uri, |
74 | + const String& localName, |
75 | + IdentTypes::quantifier_t quantifier = IdentTypes::QUANT_ONE |
76 | + ); |
77 | + |
78 | + static |
79 | + TypeIdentifier_t |
80 | + createSchemaAttributeType( |
81 | + const String& uri, |
82 | + const String& localName, |
83 | + IdentTypes::quantifier_t quantifier = IdentTypes::QUANT_ONE |
84 | + ); |
85 | + |
86 | IdentTypes::kind_t |
87 | getKind() const; |
88 | |
89 | @@ -129,9 +146,18 @@ |
90 | TypeIdentifier_t |
91 | getContentType() const; |
92 | |
93 | + std::ostream& |
94 | + emit(std::ostream&) const; |
95 | + |
96 | private: |
97 | TypeIdentifier(); |
98 | |
99 | + std::ostream& |
100 | + emitItemType(std::ostream&) const; |
101 | + |
102 | + std::ostream& |
103 | + emitName(std::ostream&) const; |
104 | + |
105 | IdentTypes::kind_t m_kind; |
106 | IdentTypes::quantifier_t m_quantifier; |
107 | String m_uri; |
108 | @@ -148,5 +174,12 @@ |
109 | |
110 | } /* namespace zorba */ |
111 | |
112 | +namespace std { |
113 | + |
114 | +ZORBA_DLL_PUBLIC ostream& operator<<(ostream& o, const zorba::TypeIdentifier& ti); |
115 | +ZORBA_DLL_PUBLIC ostream& operator<<(ostream& o, const zorba::TypeIdentifier_t ti); |
116 | + |
117 | +} |
118 | + |
119 | #endif /* ZORBA_TYPES_TYPEIDENT_H */ |
120 | /* vim:set et sw=2 ts=2: */ |
121 | |
122 | === modified file 'src/api/CMakeLists.txt' |
123 | --- src/api/CMakeLists.txt 2012-02-16 14:11:02 +0000 |
124 | +++ src/api/CMakeLists.txt 2012-03-06 03:27:34 +0000 |
125 | @@ -27,6 +27,7 @@ |
126 | zorba_string.cpp |
127 | itemfactoryimpl.cpp |
128 | item.cpp |
129 | + identtypesimpl.cpp |
130 | typeidentimpl.cpp |
131 | unmarshaller.cpp |
132 | xmldatamanagerimpl.cpp |
133 | |
134 | === added file 'src/api/identtypesimpl.cpp' |
135 | --- src/api/identtypesimpl.cpp 1970-01-01 00:00:00 +0000 |
136 | +++ src/api/identtypesimpl.cpp 2012-03-06 03:27:34 +0000 |
137 | @@ -0,0 +1,60 @@ |
138 | +/* |
139 | + * Copyright 2006-2008 The FLWOR Foundation. |
140 | + * |
141 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
142 | + * you may not use this file except in compliance with the License. |
143 | + * You may obtain a copy of the License at |
144 | + * |
145 | + * http://www.apache.org/licenses/LICENSE-2.0 |
146 | + * |
147 | + * Unless required by applicable law or agreed to in writing, software |
148 | + * distributed under the License is distributed on an "AS IS" BASIS, |
149 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
150 | + * See the License for the specific language governing permissions and |
151 | + * limitations under the License. |
152 | + */ |
153 | + |
154 | +#include <zorba/identtypes.h> |
155 | + |
156 | +namespace zorba { |
157 | + |
158 | +char const *const IdentTypes::kind_string_of[] = { |
159 | + "NAMED", |
160 | + "element", |
161 | + "attribute", |
162 | + "document-node", |
163 | + "processing-instruction", |
164 | + "text", |
165 | + "comment", |
166 | + "node", |
167 | + "item", |
168 | + "empty-sequence", |
169 | + "schema-element", |
170 | + "schema-attribute", |
171 | + "INVALID", |
172 | + 0 |
173 | +}; |
174 | + |
175 | +char const *const IdentTypes::quantifier_string_of[] = { |
176 | + "", |
177 | + "?", |
178 | + "+", |
179 | + "*", |
180 | + 0 |
181 | +}; |
182 | + |
183 | +} |
184 | + |
185 | +namespace std { |
186 | + |
187 | +ostream& operator<<(ostream& o, const zorba::IdentTypes::kind_t ik) { |
188 | + return o << zorba::IdentTypes::kind_string_of[ik]; |
189 | +} |
190 | + |
191 | +ostream& operator<<(ostream& o, const zorba::IdentTypes::quantifier_t iq) { |
192 | + return o << zorba::IdentTypes::quantifier_string_of[iq]; |
193 | +} |
194 | + |
195 | +} |
196 | + |
197 | +/* vim:set et sw=2 ts=2: */ |
198 | |
199 | === modified file 'src/api/typeidentimpl.cpp' |
200 | --- src/api/typeidentimpl.cpp 2011-09-15 11:46:01 +0000 |
201 | +++ src/api/typeidentimpl.cpp 2012-03-06 03:27:34 +0000 |
202 | @@ -20,6 +20,8 @@ |
203 | |
204 | #include <zorba/typeident.h> |
205 | |
206 | +#include "diagnostics/assert.h" |
207 | + |
208 | namespace zorba { |
209 | |
210 | TypeIdentifier::TypeIdentifier() |
211 | @@ -101,6 +103,9 @@ |
212 | TypeIdentifier_t contentType, |
213 | IdentTypes::quantifier_t quantifier) |
214 | { |
215 | + // not sure why those were 2 different flags, we maintain 2 flags for |
216 | + // compatibility, but they always need to be the same |
217 | + ZORBA_ASSERT(uriWildcard == localNameWildcard); |
218 | TypeIdentifier_t ti(new TypeIdentifier()); |
219 | ti->m_kind = IdentTypes::ELEMENT_TYPE; |
220 | ti->m_quantifier = quantifier; |
221 | @@ -122,6 +127,9 @@ |
222 | TypeIdentifier_t contentType, |
223 | IdentTypes::quantifier_t quantifier) |
224 | { |
225 | + // not sure why those were 2 different flags, we maintain 2 flags for |
226 | + // compatibility, but they always need to be the same |
227 | + ZORBA_ASSERT(uriWildcard == localNameWildcard); |
228 | TypeIdentifier_t ti(new TypeIdentifier()); |
229 | ti->m_kind = IdentTypes::ATTRIBUTE_TYPE; |
230 | ti->m_quantifier = quantifier; |
231 | @@ -202,11 +210,114 @@ |
232 | { |
233 | TypeIdentifier_t ti(new TypeIdentifier()); |
234 | ti->m_kind = IdentTypes::EMPTY_TYPE; |
235 | - |
236 | - return ti; |
237 | -} |
238 | - |
239 | -} |
240 | + ti->m_quantifier = IdentTypes::QUANT_ONE; |
241 | + |
242 | + return ti; |
243 | +} |
244 | + |
245 | +TypeIdentifier_t TypeIdentifier::createSchemaElementType( |
246 | + const String& uri, |
247 | + const String& localName, |
248 | + IdentTypes::quantifier_t quantifier) |
249 | +{ |
250 | + TypeIdentifier_t ti(new TypeIdentifier()); |
251 | + ti->m_kind = IdentTypes::SCHEMA_ELEMENT_TYPE; |
252 | + ti->m_quantifier = quantifier; |
253 | + ti->m_uri = uri; |
254 | + ti->m_uriWildcard = false; |
255 | + ti->m_localName = localName; |
256 | + ti->m_localNameWildcard = false; |
257 | + |
258 | + return ti; |
259 | +} |
260 | + |
261 | + |
262 | +TypeIdentifier_t TypeIdentifier::createSchemaAttributeType( |
263 | + const String& uri, |
264 | + const String& localName, |
265 | + IdentTypes::quantifier_t quantifier) |
266 | +{ |
267 | + TypeIdentifier_t ti(new TypeIdentifier()); |
268 | + ti->m_kind = IdentTypes::SCHEMA_ATTRIBUTE_TYPE; |
269 | + ti->m_quantifier = quantifier; |
270 | + ti->m_uri = uri; |
271 | + ti->m_uriWildcard = false; |
272 | + ti->m_localName = localName; |
273 | + ti->m_localNameWildcard = false; |
274 | + |
275 | + return ti; |
276 | +} |
277 | + |
278 | + |
279 | +std::ostream& TypeIdentifier::emit(std::ostream& os) const { |
280 | + emitItemType(os); |
281 | + return os << m_quantifier; |
282 | +} |
283 | + |
284 | + |
285 | +std::ostream& TypeIdentifier::emitItemType(std::ostream& os) const { |
286 | + if (m_kind == IdentTypes::NAMED_TYPE) { |
287 | + return emitName(os); |
288 | + } |
289 | + os << m_kind; |
290 | + switch (m_kind) { |
291 | + case IdentTypes::DOCUMENT_TYPE: |
292 | + return os << "(" << m_contentType << ")"; |
293 | + |
294 | + case IdentTypes::ELEMENT_TYPE: |
295 | + case IdentTypes::ATTRIBUTE_TYPE: |
296 | + os << "("; |
297 | + if (m_uriWildcard) { |
298 | + os << "*"; |
299 | + } else { |
300 | + emitName(os); |
301 | + } |
302 | + if (! m_contentType.isNull()) { |
303 | + os << "," << m_contentType; |
304 | + } |
305 | + return os << ")"; |
306 | + |
307 | + case IdentTypes::SCHEMA_ELEMENT_TYPE: |
308 | + case IdentTypes::SCHEMA_ATTRIBUTE_TYPE: |
309 | + os << "("; |
310 | + emitName(os); |
311 | + return os << ")"; |
312 | + |
313 | + case IdentTypes::ANY_NODE_TYPE: |
314 | + case IdentTypes::COMMENT_TYPE: |
315 | + case IdentTypes::EMPTY_TYPE: |
316 | + case IdentTypes::ITEM_TYPE: |
317 | + case IdentTypes::PI_TYPE: |
318 | + case IdentTypes::TEXT_TYPE: |
319 | + return os << "()"; |
320 | + |
321 | + case IdentTypes::INVALID_TYPE: |
322 | + return os; |
323 | + |
324 | + case IdentTypes::NAMED_TYPE: |
325 | + default: |
326 | + ZORBA_ASSERT(false); |
327 | + } |
328 | +} |
329 | + |
330 | +std::ostream& TypeIdentifier::emitName(std::ostream& os) const { |
331 | + return os << "{" << m_uri << "}" << m_localName; |
332 | +} |
333 | + |
334 | +} |
335 | + |
336 | +namespace std { |
337 | + |
338 | +ostream& operator<<(ostream& o, const zorba::TypeIdentifier& ti) { |
339 | + return ti.emit(o); |
340 | +} |
341 | + |
342 | +ostream& operator<<(ostream& o, const zorba::TypeIdentifier_t ti) { |
343 | + return ti->emit(o); |
344 | +} |
345 | + |
346 | +} |
347 | + |
348 | |
349 | #endif |
350 | /* vim:set et sw=2 ts=2: */ |
351 | |
352 | === modified file 'src/types/typemanagerimpl.cpp' |
353 | --- src/types/typemanagerimpl.cpp 2012-01-26 19:56:14 +0000 |
354 | +++ src/types/typemanagerimpl.cpp 2012-03-06 03:27:34 +0000 |
355 | @@ -1045,6 +1045,38 @@ |
356 | case IdentTypes::EMPTY_TYPE: |
357 | return create_empty_type(); |
358 | |
359 | + case IdentTypes::SCHEMA_ELEMENT_TYPE: |
360 | + { |
361 | + store::Item_t ename; |
362 | + GENV_ITEMFACTORY->createQName(ename, |
363 | + ident.getUri().c_str(), |
364 | + NULL, |
365 | + ident.getLocalName().c_str()); |
366 | + |
367 | + return create_node_type(store::StoreConsts::elementNode, |
368 | + ename.getp(), |
369 | + 0, |
370 | + q, |
371 | + false, |
372 | + true); |
373 | + } |
374 | + |
375 | + case IdentTypes::SCHEMA_ATTRIBUTE_TYPE: |
376 | + { |
377 | + store::Item_t aname; |
378 | + GENV_ITEMFACTORY->createQName(aname, |
379 | + ident.getUri().c_str(), |
380 | + NULL, |
381 | + ident.getLocalName().c_str()); |
382 | + |
383 | + return create_node_type(store::StoreConsts::attributeNode, |
384 | + aname.getp(), |
385 | + 0, |
386 | + q, |
387 | + false, |
388 | + true); |
389 | + } |
390 | + |
391 | default: |
392 | break; |
393 | } |
394 | |
395 | === modified file 'src/types/typeops.cpp' |
396 | --- src/types/typeops.cpp 2012-01-30 15:23:21 +0000 |
397 | +++ src/types/typeops.cpp 2012-03-06 03:27:34 +0000 |
398 | @@ -1179,7 +1179,8 @@ |
399 | ********************************************************************************/ |
400 | type_ident_ref_t TypeOps::get_type_identifier( |
401 | const TypeManager* tm, |
402 | - const XQType& type) |
403 | + const XQType& type, |
404 | + bool nested) |
405 | { |
406 | RootTypeManager& rtm = GENV_TYPESYSTEM; |
407 | |
408 | @@ -1201,7 +1202,7 @@ |
409 | const NodeXQType& nt = static_cast<const NodeXQType&>(type); |
410 | |
411 | type_ident_ref_t content_type = (nt.get_content_type() != NULL ? |
412 | - get_type_identifier(tm, *nt.get_content_type()) : |
413 | + get_type_identifier(tm, *nt.get_content_type(), true) : |
414 | type_ident_ref_t()); |
415 | |
416 | const store::Item* nodeName = nt.get_node_name(); |
417 | @@ -1224,29 +1225,53 @@ |
418 | return TypeIdentifier::createDocumentType(content_type, q); |
419 | |
420 | case store::StoreConsts::elementNode: |
421 | - { |
422 | - String uri( Unmarshaller::newString( nodeName->getNamespace() ) ); |
423 | - String local( Unmarshaller::newString( nodeName->getLocalName() ) ); |
424 | - |
425 | - return TypeIdentifier::createElementType(uri, |
426 | - nodeName == NULL, |
427 | - local, |
428 | - nodeName == NULL, |
429 | - content_type, |
430 | - q); |
431 | - } |
432 | - case store::StoreConsts::attributeNode: |
433 | - { |
434 | - String uri( Unmarshaller::newString( nodeName->getNamespace() ) ); |
435 | - String local( Unmarshaller::newString( nodeName->getLocalName() ) ); |
436 | - |
437 | - return TypeIdentifier::createAttributeType(uri, |
438 | + if (nt.is_schema_test()) |
439 | + { |
440 | + ZORBA_ASSERT(nodeName); |
441 | + String uri( Unmarshaller::newString( nodeName->getNamespace() ) ); |
442 | + String local( Unmarshaller::newString( nodeName->getLocalName() ) ); |
443 | + return TypeIdentifier::createSchemaElementType(uri, local, q); |
444 | + } |
445 | + else |
446 | + { |
447 | + String uri; |
448 | + String local; |
449 | + if (nodeName) |
450 | + { |
451 | + uri = nodeName->getNamespace().c_str(); |
452 | + local = nodeName->getLocalName().c_str(); |
453 | + } |
454 | + return TypeIdentifier::createElementType(uri, |
455 | nodeName == NULL, |
456 | local, |
457 | nodeName == NULL, |
458 | content_type, |
459 | - q); |
460 | - } |
461 | + q); |
462 | + } |
463 | + case store::StoreConsts::attributeNode: |
464 | + if (nt.is_schema_test()) |
465 | + { |
466 | + ZORBA_ASSERT(nodeName); |
467 | + String uri( Unmarshaller::newString( nodeName->getNamespace() ) ); |
468 | + String local( Unmarshaller::newString( nodeName->getLocalName() ) ); |
469 | + return TypeIdentifier::createSchemaAttributeType(uri, local, q); |
470 | + } |
471 | + else |
472 | + { |
473 | + String uri; |
474 | + String local; |
475 | + if (nodeName) |
476 | + { |
477 | + uri = nodeName->getNamespace().c_str(); |
478 | + local = nodeName->getLocalName().c_str(); |
479 | + } |
480 | + return TypeIdentifier::createAttributeType(uri, |
481 | + nodeName == NULL, |
482 | + local, |
483 | + nodeName == NULL, |
484 | + content_type, |
485 | + q); |
486 | + } |
487 | default: |
488 | // cannot happen |
489 | ZORBA_ASSERT(false); |
490 | @@ -1281,7 +1306,15 @@ |
491 | return TypeIdentifier::createEmptyType(); |
492 | |
493 | case XQType::USER_DEFINED_KIND: |
494 | - //TODO for Vinayak return type identifier |
495 | + { |
496 | + ZORBA_ASSERT(nested || is_atomic(tm, type)); |
497 | + store::Item* lQname = type.get_qname().getp(); |
498 | + return TypeIdentifier::createNamedType( |
499 | + Unmarshaller::newString( lQname->getNamespace() ), |
500 | + Unmarshaller::newString( lQname->getLocalName() ), |
501 | + q |
502 | + ); |
503 | + } |
504 | default: |
505 | break; |
506 | } |
507 | |
508 | === modified file 'src/types/typeops.h' |
509 | --- src/types/typeops.h 2012-01-11 10:30:49 +0000 |
510 | +++ src/types/typeops.h 2012-03-06 03:27:34 +0000 |
511 | @@ -256,7 +256,8 @@ |
512 | */ |
513 | static type_ident_ref_t get_type_identifier( |
514 | const TypeManager* tm, |
515 | - const XQType& type); |
516 | + const XQType& type, |
517 | + bool nested = false); |
518 | |
519 | /* |
520 | * Writes a textual representation of the given type to the output stream. |
521 | |
522 | === modified file 'test/unit/CMakeLists.txt' |
523 | --- test/unit/CMakeLists.txt 2012-02-27 14:46:27 +0000 |
524 | +++ test/unit/CMakeLists.txt 2012-03-06 03:27:34 +0000 |
525 | @@ -71,6 +71,10 @@ |
526 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/module2.xq ${CMAKE_CURRENT_BINARY_DIR}/module2.xq) |
527 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/module3.xq ${CMAKE_CURRENT_BINARY_DIR}/module3.xq) |
528 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/module4.xq ${CMAKE_CURRENT_BINARY_DIR}/module4.xq) |
529 | +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/module5.xq ${CMAKE_CURRENT_BINARY_DIR}/module5.xq) |
530 | +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/module6.xq ${CMAKE_CURRENT_BINARY_DIR}/module6.xq) |
531 | + |
532 | +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/schema1.xsd ${CMAKE_CURRENT_BINARY_DIR}/schema1.xsd) |
533 | |
534 | SET(UNIT_TESTS_SRCS |
535 | path_resolver.cpp |
536 | |
537 | === added file 'test/unit/module5.xq' |
538 | --- test/unit/module5.xq 1970-01-01 00:00:00 +0000 |
539 | +++ test/unit/module5.xq 2012-03-06 03:27:34 +0000 |
540 | @@ -0,0 +1,20 @@ |
541 | +(: |
542 | + : Copyright 2006-2009 The FLWOR Foundation. |
543 | + : |
544 | + : Licensed under the Apache License, Version 2.0 (the "License"); |
545 | + : you may not use this file except in compliance with the License. |
546 | + : You may obtain a copy of the License at |
547 | + : |
548 | + : http://www.apache.org/licenses/LICENSE-2.0 |
549 | + : |
550 | + : Unless required by applicable law or agreed to in writing, software |
551 | + : distributed under the License is distributed on an "AS IS" BASIS, |
552 | + : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
553 | + : See the License for the specific language governing permissions and |
554 | + : limitations under the License. |
555 | +:) |
556 | + |
557 | +import module namespace mod6 = "http://www.mod6.com/" at "file:///${CMAKE_CURRENT_BINARY_DIR}/module6.xq"; |
558 | + |
559 | +1+1 |
560 | + |
561 | |
562 | === added file 'test/unit/module6.xq' |
563 | --- test/unit/module6.xq 1970-01-01 00:00:00 +0000 |
564 | +++ test/unit/module6.xq 2012-03-06 03:27:34 +0000 |
565 | @@ -0,0 +1,38 @@ |
566 | +(: |
567 | + : Copyright 2006-2009 The FLWOR Foundation. |
568 | + : |
569 | + : Licensed under the Apache License, Version 2.0 (the "License"); |
570 | + : you may not use this file except in compliance with the License. |
571 | + : You may obtain a copy of the License at |
572 | + : |
573 | + : http://www.apache.org/licenses/LICENSE-2.0 |
574 | + : |
575 | + : Unless required by applicable law or agreed to in writing, software |
576 | + : distributed under the License is distributed on an "AS IS" BASIS, |
577 | + : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
578 | + : See the License for the specific language governing permissions and |
579 | + : limitations under the License. |
580 | +:) |
581 | + |
582 | +module namespace mod6 = "http://www.mod6.com/"; |
583 | + |
584 | +declare namespace ann = "http://www.zorba-xquery.com/annotations"; |
585 | + |
586 | +import schema namespace s = "http://www.zorba-xquery.com/schemas/simple" at "file:///${CMAKE_CURRENT_BINARY_DIR}/schema1.xsd"; |
587 | + |
588 | +declare collection mod6:coll01 as document-node(element(s:product))*; |
589 | +declare collection mod6:coll02 as document-node(element(*, s:ProductType))*; |
590 | +declare collection mod6:coll03 as document-node(schema-element(s:product))*; |
591 | + |
592 | +declare collection mod6:coll04 as element(s:product)*; |
593 | +declare collection mod6:coll05 as element(*, s:ProductType)*; |
594 | +declare collection mod6:coll06 as schema-element(s:product)*; |
595 | + |
596 | +declare collection mod6:coll07 as attribute(s:zip-code)*; |
597 | +declare collection mod6:coll08 as attribute(*, s:ZipType)*; |
598 | +declare collection mod6:coll09 as schema-attribute(s:zip-code)*; |
599 | + |
600 | +declare collection mod6:coll10 as comment(); |
601 | +declare collection mod6:coll11 as processing-instruction()?; |
602 | +declare collection mod6:coll12 as text()+; |
603 | +declare collection mod6:coll13 as node()*; |
604 | |
605 | === added file 'test/unit/schema1.xsd' |
606 | --- test/unit/schema1.xsd 1970-01-01 00:00:00 +0000 |
607 | +++ test/unit/schema1.xsd 2012-03-06 03:27:34 +0000 |
608 | @@ -0,0 +1,21 @@ |
609 | +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" |
610 | + targetNamespace="http://www.zorba-xquery.com/schemas/simple" |
611 | + xmlns="http://www.zorba-xquery.com/schemas/simple" |
612 | + elementFormDefault="qualified"> |
613 | + |
614 | + <xs:element name="product" type="ProductType"/> |
615 | + |
616 | + <xs:complexType name="ProductType"> |
617 | + <xs:attribute name="data" type="xs:base64Binary"/> |
618 | + <xs:attribute name="string" type="xs:string"/> |
619 | + </xs:complexType> |
620 | + |
621 | + <xs:attribute name="zip-code" type="ZipType"/> |
622 | + |
623 | + <xs:simpleType name="ZipType"> |
624 | + <xs:restriction base="xs:string"> |
625 | + <xs:pattern value="[0-9][0-9][0-9][0-9][0-9]"/> |
626 | + </xs:restriction> |
627 | + </xs:simpleType> |
628 | + |
629 | +</xs:schema> |
630 | \ No newline at end of file |
631 | |
632 | === modified file 'test/unit/staticcollectionmanager.cpp' |
633 | --- test/unit/staticcollectionmanager.cpp 2012-01-11 17:30:25 +0000 |
634 | +++ test/unit/staticcollectionmanager.cpp 2012-03-06 03:27:34 +0000 |
635 | @@ -259,6 +259,165 @@ |
636 | return i == 1; |
637 | } |
638 | |
639 | +bool |
640 | +check_types(StaticCollectionManager* aColMgr, |
641 | + ItemFactory* aFac, |
642 | + const char* const aCollName, |
643 | + int aDepth, |
644 | + IdentTypes::kind_t someKinds[], |
645 | + IdentTypes::quantifier_t someQuantifiers[]) |
646 | +{ |
647 | + Item lCollName = aFac->createQName("http://www.mod6.com/", aCollName); |
648 | + if (! aColMgr->isDeclaredCollection(lCollName)) { |
649 | + std::cout << "no collection " |
650 | + << lCollName.getStringValue().c_str() |
651 | + << std::endl; |
652 | + return false; |
653 | + } |
654 | + aColMgr->createCollection(lCollName); |
655 | + Collection_t lCollection = aColMgr->getCollection(lCollName); |
656 | + zorba::TypeIdentifier_t lType = lCollection->getType(); |
657 | + std::cout << lType << std::endl; |
658 | + |
659 | + for (int i = 0; i < aDepth; ++i) { |
660 | + if (lType->getKind() != someKinds[i]) { |
661 | + std::cout << lType << std::endl; |
662 | + return false; |
663 | + } |
664 | + if (lType->getQuantifier() != someQuantifiers[i]) { |
665 | + std::cout << lType << std::endl; |
666 | + return false; |
667 | + } |
668 | + lType = lType->getContentType(); |
669 | + } |
670 | + assert(lType.isNull()); |
671 | + |
672 | + aColMgr->deleteCollection(lCollName); |
673 | + return true; |
674 | +} |
675 | + |
676 | +bool |
677 | +staticcollectionamanger5(zorba::Zorba* z) |
678 | +{ |
679 | + std::ifstream lIn("module5.xq"); |
680 | + zorba::XQuery_t lQuery = z->createQuery(); |
681 | + |
682 | + try { |
683 | + Zorba_CompilerHints lHints; |
684 | + lQuery->compile(lIn, lHints); |
685 | + } catch (zorba::XQueryException &e) { |
686 | + std::cout << e << std::endl; |
687 | + return false; |
688 | + } catch (...) { |
689 | + std::cout << "compilation failed" << std::endl; |
690 | + return false; |
691 | + } |
692 | + |
693 | + StaticCollectionManager* lColMgr = lQuery->getStaticCollectionManager(); |
694 | + ItemFactory* lFac = z->getItemFactory(); |
695 | + |
696 | + IdentTypes::kind_t lC01Kinds[] = { IdentTypes::DOCUMENT_TYPE, |
697 | + IdentTypes::ELEMENT_TYPE, |
698 | + IdentTypes::NAMED_TYPE }; |
699 | + IdentTypes::quantifier_t lC01Quants[] = { IdentTypes::QUANT_STAR, |
700 | + IdentTypes::QUANT_ONE, |
701 | + // this '*' is probably a bug |
702 | + IdentTypes::QUANT_STAR }; |
703 | + if (!check_types(lColMgr, lFac, "coll01", 3, lC01Kinds, lC01Quants)) { |
704 | + return false; |
705 | + } |
706 | + |
707 | + IdentTypes::kind_t lC02Kinds[] = { IdentTypes::DOCUMENT_TYPE, |
708 | + IdentTypes::ELEMENT_TYPE, |
709 | + IdentTypes::NAMED_TYPE }; |
710 | + IdentTypes::quantifier_t lC02Quants[] = { IdentTypes::QUANT_STAR, |
711 | + IdentTypes::QUANT_ONE, |
712 | + IdentTypes::QUANT_ONE }; |
713 | + if (!check_types(lColMgr, lFac, "coll02", 3, lC02Kinds, lC02Quants)) { |
714 | + return false; |
715 | + } |
716 | + |
717 | + IdentTypes::kind_t lC03Kinds[] = { IdentTypes::DOCUMENT_TYPE, |
718 | + IdentTypes::SCHEMA_ELEMENT_TYPE }; |
719 | + IdentTypes::quantifier_t lC03Quants[] = { IdentTypes::QUANT_STAR, |
720 | + IdentTypes::QUANT_ONE }; |
721 | + if (!check_types(lColMgr, lFac, "coll03", 2, lC03Kinds, lC03Quants)) { |
722 | + return false; |
723 | + } |
724 | + |
725 | + IdentTypes::kind_t lC04Kinds[] = { IdentTypes::ELEMENT_TYPE, |
726 | + IdentTypes::NAMED_TYPE }; |
727 | + IdentTypes::quantifier_t lC04Quants[] = { IdentTypes::QUANT_STAR, |
728 | + // this '*' is probably a bug |
729 | + IdentTypes::QUANT_STAR }; |
730 | + if (!check_types(lColMgr, lFac, "coll04", 2, lC04Kinds, lC04Quants)) { |
731 | + return false; |
732 | + } |
733 | + |
734 | + IdentTypes::kind_t lC05Kinds[] = { IdentTypes::ELEMENT_TYPE, |
735 | + IdentTypes::NAMED_TYPE }; |
736 | + IdentTypes::quantifier_t lC05Quants[] = { IdentTypes::QUANT_STAR, |
737 | + IdentTypes::QUANT_ONE }; |
738 | + if (!check_types(lColMgr, lFac, "coll05", 2, lC05Kinds, lC05Quants)) { |
739 | + return false; |
740 | + } |
741 | + |
742 | + IdentTypes::kind_t lC06Kinds[] = { IdentTypes::SCHEMA_ELEMENT_TYPE }; |
743 | + IdentTypes::quantifier_t lC06Quants[] = { IdentTypes::QUANT_STAR }; |
744 | + if (!check_types(lColMgr, lFac, "coll06", 1, lC06Kinds, lC06Quants)) { |
745 | + return false; |
746 | + } |
747 | + |
748 | + IdentTypes::kind_t lC07Kinds[] = { IdentTypes::ATTRIBUTE_TYPE, |
749 | + IdentTypes::NAMED_TYPE }; |
750 | + IdentTypes::quantifier_t lC07Quants[] = { IdentTypes::QUANT_STAR, |
751 | + // this '*' is probably a bug |
752 | + IdentTypes::QUANT_STAR }; |
753 | + if (!check_types(lColMgr, lFac, "coll07", 2, lC07Kinds, lC07Quants)) { |
754 | + return false; |
755 | + } |
756 | + |
757 | + IdentTypes::kind_t lC08Kinds[] = { IdentTypes::ATTRIBUTE_TYPE, |
758 | + IdentTypes::NAMED_TYPE }; |
759 | + IdentTypes::quantifier_t lC08Quants[] = { IdentTypes::QUANT_STAR, |
760 | + IdentTypes::QUANT_ONE }; |
761 | + if (!check_types(lColMgr, lFac, "coll08", 2, lC08Kinds, lC08Quants)) { |
762 | + return false; |
763 | + } |
764 | + |
765 | + IdentTypes::kind_t lC09Kinds[] = { IdentTypes::SCHEMA_ATTRIBUTE_TYPE }; |
766 | + IdentTypes::quantifier_t lC09Quants[] = { IdentTypes::QUANT_STAR }; |
767 | + if (!check_types(lColMgr, lFac, "coll09", 1, lC09Kinds, lC09Quants)) { |
768 | + return false; |
769 | + } |
770 | + |
771 | + IdentTypes::kind_t lC10Kinds[] = { IdentTypes::COMMENT_TYPE }; |
772 | + IdentTypes::quantifier_t lC10Quants[] = { IdentTypes::QUANT_ONE }; |
773 | + if (!check_types(lColMgr, lFac, "coll10", 1, lC10Kinds, lC10Quants)) { |
774 | + return false; |
775 | + } |
776 | + |
777 | + IdentTypes::kind_t lC11Kinds[] = { IdentTypes::PI_TYPE }; |
778 | + IdentTypes::quantifier_t lC11Quants[] = { IdentTypes::QUANT_QUESTION }; |
779 | + if (!check_types(lColMgr, lFac, "coll11", 1, lC11Kinds, lC11Quants)) { |
780 | + return false; |
781 | + } |
782 | + |
783 | + IdentTypes::kind_t lC12Kinds[] = { IdentTypes::TEXT_TYPE }; |
784 | + IdentTypes::quantifier_t lC12Quants[] = { IdentTypes::QUANT_PLUS }; |
785 | + if (!check_types(lColMgr, lFac, "coll12", 1, lC12Kinds, lC12Quants)) { |
786 | + return false; |
787 | + } |
788 | + |
789 | + IdentTypes::kind_t lC13Kinds[] = { IdentTypes::ANY_NODE_TYPE }; |
790 | + IdentTypes::quantifier_t lC13Quants[] = { IdentTypes::QUANT_STAR }; |
791 | + if (!check_types(lColMgr, lFac, "coll13", 1, lC13Kinds, lC13Quants)) { |
792 | + return false; |
793 | + } |
794 | + |
795 | + return true; |
796 | +} |
797 | + |
798 | int |
799 | staticcollectionmanager(int argc, char* argv[]) |
800 | { |
801 | @@ -287,6 +446,11 @@ |
802 | return 4; |
803 | std::cout << std::endl; |
804 | |
805 | + std::cout << "executing example 5" << std::endl; |
806 | + if (!staticcollectionamanger5(z)) |
807 | + return 5; |
808 | + std::cout << std::endl; |
809 | + |
810 | return 0; |
811 | } |
812 |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ bug924987- 2012-02- 01T22-33- 57.831Z/ log.html
Log at: http://