Merge lp:~zorba-coders/zorba/bug891209-xsiType into lp:zorba

Proposed by Cezar Andrei
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/bug891209-xsiType
Merge into: lp:zorba
Diff against target: 205 lines (+54/-30)
7 files modified
src/types/schema/EventSchemaValidator.cpp (+2/-2)
src/types/schema/SchemaValidatorFilter.cpp (+4/-2)
src/types/schema/XercSchemaValidator.cpp (+2/-2)
src/types/schema/validate.cpp (+29/-19)
src/types/typemanagerimpl.cpp (+5/-5)
test/rbkt/ExpQueryResults/zorba/schemas/val-xsiType-noSchemaImport.xml.res (+1/-0)
test/rbkt/Queries/zorba/schemas/val-xsiType-noSchemaImport.xq (+11/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug891209-xsiType
Reviewer Review Type Date Requested Status
Matthias Brantner Pending
Review via email: mp+95475@code.launchpad.net

This proposal has been superseded by a proposal from 2012-03-01.

Commit message

Fix for bug 891209 : validation with xsi:type returns untyped.

Description of the change

Fix for bug 891209 : validation with xsi:type returns untyped.

To post a comment you must log in.
10686. By Cezar Andrei

Add entry in Changelog.

10687. By Cezar Andrei <email address hidden>

Dtd validation based on no schema imports, now has it's own option.

10688. By Cezar Andrei <email address hidden>

Merge from trunk.

10689. By Cezar Andrei <email address hidden>

Make sure only when dtds are involved dtd_lax val mode is used.

10690. By Cezar Andrei <email address hidden>

Adding documentation for the new added validation mode.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/types/schema/EventSchemaValidator.cpp'
2--- src/types/schema/EventSchemaValidator.cpp 2011-08-19 03:26:59 +0000
3+++ src/types/schema/EventSchemaValidator.cpp 2012-03-01 21:39:21 +0000
4@@ -163,7 +163,7 @@
5 StrX typeName(theSchemaValidatorFilter->getTypeName());
6 StrX typeUri(theSchemaValidatorFilter->getTypeUri());
7
8- //cout << " - getTypeQName: " << typeName << "@" << typeUri <<" ";
9+ //cout << " - getTypeQName: " << typeName << " @ " << typeUri <<" ";
10
11 store::Item_t typeQName;
12 GENV_ITEMFACTORY->createQName(typeQName,
13@@ -172,7 +172,7 @@
14 typeName.localFormOrDefault ("untyped"));
15
16 //cout << " : " << typeQName->getLocalName() << " @ "
17- // << typeQName->getNamespace() <<"\n";
18+ // << typeQName->getNamespace() <<"\n"; std::cout.flush();
19
20 return typeQName;
21 }
22
23=== modified file 'src/types/schema/SchemaValidatorFilter.cpp'
24--- src/types/schema/SchemaValidatorFilter.cpp 2011-06-14 17:26:33 +0000
25+++ src/types/schema/SchemaValidatorFilter.cpp 2012-03-01 21:39:21 +0000
26@@ -867,7 +867,7 @@
27 }
28 --theAttrCount; // remove att from the list but still needs to be reported
29
30- //cout << " svf attrEvent: " << StrX(localname) << " T: " <<
31+ //std::cout << " svf attrEvent: " << StrX(localname) << " T: " <<
32 // StrX(typeName) << "\n";
33 theEventBuffer->attributeEvent(emptyToNull(prefix), emptyToNull(uri),
34 localname, value, emptyToNull(typeURI), typeName);
35@@ -1062,7 +1062,9 @@
36 {
37 const ElemStack::StackElem* topElem = fElemStack.topElement();
38 DatatypeValidator *currentDV = 0;
39- if(topElem->fThisElement->isDeclared())
40+ if(topElem->fThisElement->isDeclared() ||
41+ theXsiType // this is when there is no schema import but xsiType is used
42+ )
43 {
44 ComplexTypeInfo *currentTypeInfo = ((XercSchemaValidator*)fValidator)->
45 getCurrentTypeInfo();
46
47=== modified file 'src/types/schema/XercSchemaValidator.cpp'
48--- src/types/schema/XercSchemaValidator.cpp 2011-06-14 17:26:33 +0000
49+++ src/types/schema/XercSchemaValidator.cpp 2012-03-01 21:39:21 +0000
50@@ -23,7 +23,6 @@
51 // Includes
52 // ---------------------------------------------------------------------------
53 #include "stdafx.h"
54-#include "XercSchemaValidator.h"
55
56 #include <xercesc/util/Janitor.hpp>
57 #include <xercesc/framework/XMLDocumentHandler.hpp>
58@@ -54,7 +53,8 @@
59
60
61 #include "diagnostics/assert.h"
62-//#include "StrX.h"
63+#include "StrX.h"
64+#include "XercSchemaValidator.h"
65
66 using namespace XERCES_CPP_NAMESPACE;
67
68
69=== modified file 'src/types/schema/validate.cpp'
70--- src/types/schema/validate.cpp 2011-09-22 21:50:20 +0000
71+++ src/types/schema/validate.cpp 2012-03-01 21:39:21 +0000
72@@ -54,7 +54,7 @@
73 #include "diagnostics/assert.h"
74 #include "zorba/store_consts.h"
75
76-using namespace std;
77+//using namespace std;
78
79 namespace zorba
80 {
81@@ -145,16 +145,26 @@
82 //cout << "No schema: isNode() " << sourceNode->isNode() << " nodeKind: "<<
83 // sourceNode->getNodeKind() << endl;
84
85- if ( validationMode == ParseConstants::val_strict )
86- {
87- throw XQUERY_EXCEPTION( err::XQDY0084, ERROR_LOC( loc ) );
88- }
89- else
90- {
91+ // if we got here it basicaly means that there was no import but
92+ // validation is used so we need to set up schema in the typeManager anyway
93+ // validation has to work for xsiType and built-in types
94+
95+ TypeManagerImpl *typeManagerImpl = static_cast<TypeManagerImpl*>(typeManager);
96+ typeManagerImpl->initializeSchema();
97+ schema = typeManager->getSchema();
98+
99+
100+
101+// if ( validationMode == ParseConstants::val_strict )
102+// {
103+// throw XQUERY_EXCEPTION( err::XQDY0084, ERROR_LOC( loc ) );
104+// }
105+// else
106+// {
107 // no schema available - items remain the same
108- result = sourceNode;
109- return true;
110- }
111+// result = sourceNode;
112+// return true;
113+// }
114 }
115
116 #ifndef ZORBA_NO_XMLSCHEMA
117@@ -382,8 +392,8 @@
118 ZORBA_ASSERT(attribute->isNode());
119 ZORBA_ASSERT(attribute->getNodeKind() == store::StoreConsts::attributeNode);
120
121- //cout << " v - attr: " << attribute->getNodeName()->getLocalName()->
122- // c_str() << "\n"; cout.flush();
123+ //cout << " v - attr: " << attribute->getNodeName()->getLocalName() << ":" <<
124+ // attribute->getStringValue() << "\n"; cout.flush();
125
126 store::Item_t attName = attribute->getNodeName();
127 schemaValidator.attr(attName, attribute->getStringValue());
128@@ -472,9 +482,9 @@
129 {
130 if ( child->isNode() )
131 {
132- //cout << " > child: " << child->getNodeKind() << " " <<
133- // (child->getType() != NULL ? child->getType()->getLocalName()
134- // : "type_NULL" ) << "\n"; cout.flush();
135+ //cout << " > child: " << (long)child->getNodeKind() << " " <<
136+ // //(child->getType() != NULL ? child->getType()->getLocalName() : "type_NULL" ) <<
137+ // "\n"; cout.flush();
138
139 switch ( child->getNodeKind() )
140 {
141@@ -515,7 +525,7 @@
142 cout << " - text: '" << childStringValue << "' T: " <<
143 typeQName->getLocalName() << "\n"; cout.flush();
144 cout << " xqT: " << xqType->toString() << " content_kind: " <<
145- xqType->content_kind() << " tKind:" << xqType->type_kind() << " \n";
146+ (long)xqType->content_kind() << " tKind:" << (long)xqType->type_kind() << " \n";
147 cout.flush();
148 }
149 else
150@@ -649,9 +659,9 @@
151 xqtref_t type = typeManager->create_named_type(typeQName.getp(),
152 TypeConstants::QUANT_ONE);
153
154- //cout << " - processTextValue: " << typeQName->getPrefix()->str()
155- // << ":" << typeQName->getLocalName()->str() << "@"
156- // << typeQName->getNamespace()->str() ; cout.flush();
157+ //cout << " - processTextValue: " << typeQName->getPrefix()
158+ // << ":" << typeQName->getLocalName() << "@"
159+ // << typeQName->getNamespace() ; cout.flush();
160 //cout << " type: " << (type==NULL ? "NULL" : type->toString()) << "\n"; cout.flush();
161
162 // TODO: we probably need the ns bindings from the static context
163
164=== modified file 'src/types/typemanagerimpl.cpp'
165--- src/types/typemanagerimpl.cpp 2012-01-26 19:56:14 +0000
166+++ src/types/typemanagerimpl.cpp 2012-03-01 21:39:21 +0000
167@@ -336,11 +336,11 @@
168 {
169 if (error != zerr::ZXQP0000_NO_ERROR)
170 {
171- throw XQUERY_EXCEPTION_VAR(
172- error,
173- ERROR_PARAMS(qname->getStringValue(), ZED(NotAmongInScopeSchemaTypes)),
174- ERROR_LOC( loc )
175- );
176+ throw XQUERY_EXCEPTION_VAR(
177+ error,
178+ ERROR_PARAMS(qname->getStringValue(), ZED(NotAmongInScopeSchemaTypes)),
179+ ERROR_LOC( loc )
180+ );
181 }
182 else
183 {
184
185=== added file 'test/rbkt/ExpQueryResults/zorba/schemas/val-xsiType-noSchemaImport.xml.res'
186--- test/rbkt/ExpQueryResults/zorba/schemas/val-xsiType-noSchemaImport.xml.res 1970-01-01 00:00:00 +0000
187+++ test/rbkt/ExpQueryResults/zorba/schemas/val-xsiType-noSchemaImport.xml.res 2012-03-01 21:39:21 +0000
188@@ -0,0 +1,1 @@
189+xs:integer
190
191=== added file 'test/rbkt/Queries/zorba/schemas/val-xsiType-noSchemaImport.xq'
192--- test/rbkt/Queries/zorba/schemas/val-xsiType-noSchemaImport.xq 1970-01-01 00:00:00 +0000
193+++ test/rbkt/Queries/zorba/schemas/val-xsiType-noSchemaImport.xq 2012-03-01 21:39:21 +0000
194@@ -0,0 +1,11 @@
195+import module namespace schema = "http://www.zorba-xquery.com/modules/schema";
196+
197+schema:schema-type(
198+ data(
199+ validate lax {
200+ <a
201+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
202+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
203+ xsi:type="xs:integer">2</a> }
204+ )
205+)

Subscribers

People subscribed via source and target branches