Cezar Andrei has proposed merging lp:~zorba-coders/zorba/bug891209-xsiType into lp:zorba.
Requested reviews: Markos Zaharioudakis (markos-za) Matthias Brantner (matthias-brantner) Related bugs: Bug #891209 in Zorba: "validation with xsi:type returns untyped" https://bugs.launchpad.net/zorba/+bug/891209 For more details, see: https://code.launchpad.net/~zorba-coders/zorba/bug891209-xsiType/+merge/96001 Fix for bug 891209 : validation with xsi:type returns untyped. -- https://code.launchpad.net/~zorba-coders/zorba/bug891209-xsiType/+merge/96001 Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog' --- ChangeLog 2012-03-01 21:22:16 +0000 +++ ChangeLog 2012-03-05 20:57:43 +0000 @@ -58,6 +58,7 @@ * Fixed bug with unversioned modules with C++ external functions * Fixed bug #878508 (JSON Module not escaping escape characters) * Fixed bug #912579 (validate-in-place on non-root elements) + * Fixed bug #891209 (validation with xsi:type returns untyped) version 2.1 === modified file 'include/zorba/static_context_consts.h' --- include/zorba/static_context_consts.h 2011-10-07 21:22:20 +0000 +++ include/zorba/static_context_consts.h 2012-03-05 20:57:43 +0000 @@ -58,7 +58,7 @@ /** \brief Revalidation mode as defined in * http://www.w3.org/TR/xquery-update-10/#id-revalidation-declaration */ -typedef enum { validate_skip, validate_lax, validate_strict } validation_mode_t; +typedef enum { validate_skip, validate_lax, validate_lax_dtd, validate_strict } validation_mode_t; /** \brief Maintenance mode of an index as defined * in the XQuery Data Definition Facility === modified file 'src/api/staticcontextimpl.cpp' --- src/api/staticcontextimpl.cpp 2012-02-28 20:45:43 +0000 +++ src/api/staticcontextimpl.cpp 2012-03-05 20:57:43 +0000 @@ -1247,6 +1247,9 @@ case validate_lax: valMode = StaticContextConsts::lax_validation; break; + case validate_lax_dtd: + valMode = StaticContextConsts::lax_dtd_validation; + break; case validate_skip: valMode = StaticContextConsts::skip_validation; break; === modified file 'src/compiler/parser/parse_constants.h' --- src/compiler/parser/parse_constants.h 2011-06-14 17:26:33 +0000 +++ src/compiler/parser/parse_constants.h 2012-03-05 20:57:43 +0000 @@ -103,6 +103,7 @@ { val_strict, val_lax, + val_dtd_lax, val_typename }; === modified file 'src/context/static_context.cpp' --- src/context/static_context.cpp 2012-02-16 14:11:02 +0000 +++ src/context/static_context.cpp 2012-03-05 20:57:43 +0000 @@ -1735,10 +1735,19 @@ store::Item_t typeName; QueryLoc loc; - ParseConstants::validation_mode_t mode = - (validationMode == StaticContextConsts::strict_validation ? - ParseConstants::val_strict : - ParseConstants::val_lax ); + ParseConstants::validation_mode_t mode; + switch( validationMode ) + { + case StaticContextConsts::strict_validation: + mode = ParseConstants::val_strict; + break; + case StaticContextConsts::lax_dtd_validation: + mode = ParseConstants::val_dtd_lax; + break; + case StaticContextConsts::lax_validation: + default: + mode = ParseConstants::val_lax; + } return Validator::effectiveValidationValue(validatedResult, rootElement, === modified file 'src/context/static_context_consts.h' --- src/context/static_context_consts.h 2012-01-11 17:30:25 +0000 +++ src/context/static_context_consts.h 2012-03-05 20:57:43 +0000 @@ -90,6 +90,7 @@ validation_unknown, strict_validation, lax_validation, + lax_dtd_validation, skip_validation }; === modified file 'src/types/schema/EventSchemaValidator.cpp' --- src/types/schema/EventSchemaValidator.cpp 2011-08-19 03:26:59 +0000 +++ src/types/schema/EventSchemaValidator.cpp 2012-03-05 20:57:43 +0000 @@ -163,7 +163,7 @@ StrX typeName(theSchemaValidatorFilter->getTypeName()); StrX typeUri(theSchemaValidatorFilter->getTypeUri()); - //cout << " - getTypeQName: " << typeName << "@" << typeUri <<" "; + //cout << " - getTypeQName: " << typeName << " @ " << typeUri <<" "; store::Item_t typeQName; GENV_ITEMFACTORY->createQName(typeQName, @@ -172,7 +172,7 @@ typeName.localFormOrDefault ("untyped")); //cout << " : " << typeQName->getLocalName() << " @ " - // << typeQName->getNamespace() <<"\n"; + // << typeQName->getNamespace() <<"\n"; std::cout.flush(); return typeQName; } === modified file 'src/types/schema/SchemaValidatorFilter.cpp' --- src/types/schema/SchemaValidatorFilter.cpp 2011-06-14 17:26:33 +0000 +++ src/types/schema/SchemaValidatorFilter.cpp 2012-03-05 20:57:43 +0000 @@ -867,7 +867,7 @@ } --theAttrCount; // remove att from the list but still needs to be reported - //cout << " svf attrEvent: " << StrX(localname) << " T: " << + //std::cout << " svf attrEvent: " << StrX(localname) << " T: " << // StrX(typeName) << "\n"; theEventBuffer->attributeEvent(emptyToNull(prefix), emptyToNull(uri), localname, value, emptyToNull(typeURI), typeName); @@ -1062,7 +1062,9 @@ { const ElemStack::StackElem* topElem = fElemStack.topElement(); DatatypeValidator *currentDV = 0; - if(topElem->fThisElement->isDeclared()) + if(topElem->fThisElement->isDeclared() || + theXsiType // this is when there is no schema import but xsiType is used + ) { ComplexTypeInfo *currentTypeInfo = ((XercSchemaValidator*)fValidator)-> getCurrentTypeInfo(); === modified file 'src/types/schema/XercSchemaValidator.cpp' --- src/types/schema/XercSchemaValidator.cpp 2011-06-14 17:26:33 +0000 +++ src/types/schema/XercSchemaValidator.cpp 2012-03-05 20:57:43 +0000 @@ -23,7 +23,6 @@ // Includes // --------------------------------------------------------------------------- #include "stdafx.h" -#include "XercSchemaValidator.h" #include <xercesc/util/Janitor.hpp> #include <xercesc/framework/XMLDocumentHandler.hpp> @@ -54,7 +53,8 @@ #include "diagnostics/assert.h" -//#include "StrX.h" +#include "StrX.h" +#include "XercSchemaValidator.h" using namespace XERCES_CPP_NAMESPACE; === modified file 'src/types/schema/validate.cpp' --- src/types/schema/validate.cpp 2011-09-22 21:50:20 +0000 +++ src/types/schema/validate.cpp 2012-03-05 20:57:43 +0000 @@ -54,7 +54,7 @@ #include "diagnostics/assert.h" #include "zorba/store_consts.h" -using namespace std; +//using namespace std; namespace zorba { @@ -145,15 +145,21 @@ //cout << "No schema: isNode() " << sourceNode->isNode() << " nodeKind: "<< // sourceNode->getNodeKind() << endl; - if ( validationMode == ParseConstants::val_strict ) - { - throw XQUERY_EXCEPTION( err::XQDY0084, ERROR_LOC( loc ) ); - } - else - { - // no schema available - items remain the same + if ( validationMode == ParseConstants::val_dtd_lax) + { + // when dtd validation enabled avoid using schema object result = sourceNode; - return true; + return true; + } + else + { + // if we got here it basicaly means that there was no import but + // validation is used so we need to set up schema in the typeManager anyway + // validation has to work for xsiType and built-in types + + TypeManagerImpl *typeManagerImpl = static_cast<TypeManagerImpl*>(typeManager); + typeManagerImpl->initializeSchema(); + schema = typeManager->getSchema(); } } @@ -382,8 +388,8 @@ ZORBA_ASSERT(attribute->isNode()); ZORBA_ASSERT(attribute->getNodeKind() == store::StoreConsts::attributeNode); - //cout << " v - attr: " << attribute->getNodeName()->getLocalName()-> - // c_str() << "\n"; cout.flush(); + //cout << " v - attr: " << attribute->getNodeName()->getLocalName() << ":" << + // attribute->getStringValue() << "\n"; cout.flush(); store::Item_t attName = attribute->getNodeName(); schemaValidator.attr(attName, attribute->getStringValue()); @@ -472,9 +478,9 @@ { if ( child->isNode() ) { - //cout << " > child: " << child->getNodeKind() << " " << - // (child->getType() != NULL ? child->getType()->getLocalName() - // : "type_NULL" ) << "\n"; cout.flush(); + //cout << " > child: " << (long)child->getNodeKind() << " " << + // //(child->getType() != NULL ? child->getType()->getLocalName() : "type_NULL" ) << + // "\n"; cout.flush(); switch ( child->getNodeKind() ) { @@ -515,7 +521,7 @@ cout << " - text: '" << childStringValue << "' T: " << typeQName->getLocalName() << "\n"; cout.flush(); cout << " xqT: " << xqType->toString() << " content_kind: " << - xqType->content_kind() << " tKind:" << xqType->type_kind() << " \n"; + (long)xqType->content_kind() << " tKind:" << (long)xqType->type_kind() << " \n"; cout.flush(); } else @@ -649,9 +655,9 @@ xqtref_t type = typeManager->create_named_type(typeQName.getp(), TypeConstants::QUANT_ONE); - //cout << " - processTextValue: " << typeQName->getPrefix()->str() - // << ":" << typeQName->getLocalName()->str() << "@" - // << typeQName->getNamespace()->str() ; cout.flush(); + //cout << " - processTextValue: " << typeQName->getPrefix() + // << ":" << typeQName->getLocalName() << "@" + // << typeQName->getNamespace() ; cout.flush(); //cout << " type: " << (type==NULL ? "NULL" : type->toString()) << "\n"; cout.flush(); // TODO: we probably need the ns bindings from the static context === modified file 'src/types/typemanagerimpl.cpp' --- src/types/typemanagerimpl.cpp 2012-01-26 19:56:14 +0000 +++ src/types/typemanagerimpl.cpp 2012-03-05 20:57:43 +0000 @@ -336,11 +336,11 @@ { if (error != zerr::ZXQP0000_NO_ERROR) { - throw XQUERY_EXCEPTION_VAR( - error, - ERROR_PARAMS(qname->getStringValue(), ZED(NotAmongInScopeSchemaTypes)), - ERROR_LOC( loc ) - ); + throw XQUERY_EXCEPTION_VAR( + error, + ERROR_PARAMS(qname->getStringValue(), ZED(NotAmongInScopeSchemaTypes)), + ERROR_LOC( loc ) + ); } else { === added file 'test/rbkt/ExpQueryResults/zorba/schemas/val-xsiType-noSchemaImport.xml.res' --- test/rbkt/ExpQueryResults/zorba/schemas/val-xsiType-noSchemaImport.xml.res 1970-01-01 00:00:00 +0000 +++ test/rbkt/ExpQueryResults/zorba/schemas/val-xsiType-noSchemaImport.xml.res 2012-03-05 20:57:43 +0000 @@ -0,0 +1,1 @@ +xs:integer === added file 'test/rbkt/Queries/zorba/schemas/val-xsiType-noSchemaImport.xq' --- test/rbkt/Queries/zorba/schemas/val-xsiType-noSchemaImport.xq 1970-01-01 00:00:00 +0000 +++ test/rbkt/Queries/zorba/schemas/val-xsiType-noSchemaImport.xq 2012-03-05 20:57:43 +0000 @@ -0,0 +1,11 @@ +import module namespace schema = "http://www.zorba-xquery.com/modules/schema"; + +schema:schema-type( + data( + validate lax { + <a + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="xs:integer">2</a> } + ) +) === modified file 'test/rbkt/testdriver_common.cpp' --- test/rbkt/testdriver_common.cpp 2012-01-11 17:30:25 +0000 +++ test/rbkt/testdriver_common.cpp 2012-03-05 20:57:43 +0000 @@ -439,7 +439,7 @@ assert (lDoc.getNodeKind() == zorba::store::StoreConsts::documentNode); zorba::Item lValidatedDoc; - sctx->validate(lDoc, lValidatedDoc, zorba::validate_lax); + sctx->validate(lDoc, lValidatedDoc, zorba::validate_lax_dtd); lDocMgr->put(val, lValidatedDoc); lDoc = lDocMgr->document(val);
-- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp