zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #17709
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
Cezar Andrei has proposed merging lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba.
Commit message:
Fix for bug1023362-xsi:Type Ignored during lax validation.
Requested reviews:
Zorba Coders (zorba-coders)
Related bugs:
Bug #1023362 in Zorba: "xsi:type attribute ignored during validation"
https://bugs.launchpad.net/zorba/+bug/1023362
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug1023362-xsiTypeIgnored/+merge/146224
Fix for bug1023362-xsi:Type Ignored during lax validation.
--
https://code.launchpad.net/~zorba-coders/zorba/bug1023362-xsiTypeIgnored/+merge/146224
Your team Zorba Coders is requested to review the proposed merge of lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba.
=== modified file 'src/types/schema/EventSchemaValidator.cpp'
--- src/types/schema/EventSchemaValidator.cpp 2012-09-19 21:16:15 +0000
+++ src/types/schema/EventSchemaValidator.cpp 2013-02-01 20:55:25 +0000
@@ -94,7 +94,7 @@
void EventSchemaValidator::startElem(store::Item_t elemName)
{
- //cout << " sv SElem: " << elemName->getLocalName() << "\n";
+ //cout << "\n esv SElem: " << elemName->getLocalName() << "\n"; std::cout.flush();
XMLChArray prefix(elemName->getPrefix());
XMLChArray uri(elemName->getNamespace());
@@ -105,7 +105,7 @@
void EventSchemaValidator::endElem(store::Item_t elemName)
{
- //cout << " sv EElem: " << elemName->getLocalName() << "\n";
+ //cout << " esv EElem: " << elemName->getLocalName() << "\n"; std::cout.flush();
XMLChArray prefix(elemName->getPrefix());
XMLChArray uri(elemName->getNamespace());
@@ -118,8 +118,8 @@
void EventSchemaValidator::attr(store::Item_t attrName, const zstring& textValue)
{
- //cout << " sv Attr: " << attrName->getPrefix() << ":"
- // << attrName->getLocalName() << " = '" << textValue << "'\n";
+ //cout << " esv Attr: " << attrName->getPrefix() << ":"
+ // << attrName->getLocalName() << " = '" << textValue << "'\n"; std::cout.flush();
XMLChArray prefix(attrName->getPrefix());
XMLChArray uri(attrName->getNamespace());
@@ -133,14 +133,14 @@
void EventSchemaValidator::endAttrs()
{
- //cout << " sv endAttrs \n";
+ //cout << " esv endAttrs \n"; std::cout.flush();
theSchemaValidatorFilter->endAttributesEvent();
}
void EventSchemaValidator::text(const zstring& textValue)
{
- //cout << " sv Text: '" << textValue << "'\n";
+ //cout << " esv Text: '" << textValue << "'\n"; std::cout.flush();
XMLChArray value(textValue);
theSchemaValidatorFilter->textEvent(value);
@@ -163,7 +163,7 @@
StrX typeName(theSchemaValidatorFilter->getTypeName());
StrX typeUri(theSchemaValidatorFilter->getTypeUri());
- //cout << " - getTypeQName: " << typeName << " @ " << typeUri <<" ";
+ //cout << " esv - : getTypeQName: " << typeName << " @ " << typeUri <<"\n"; std::cout.flush();
store::Item_t typeQName;
GENV_ITEMFACTORY->createQName(typeQName,
@@ -171,8 +171,8 @@
"",
typeName.localFormOrDefault ("untyped"));
- //cout << " : " << typeQName->getLocalName() << " @ "
- // << typeQName->getNamespace() <<"\n"; std::cout.flush();
+ //cout << " " << typeQName->getLocalName() << " @ "
+ // << typeQName->getNamespace() <<"\n"; std::cout.flush(); std::cout.flush();
return typeQName;
}
@@ -183,7 +183,7 @@
StrX typeName(theSchemaValidatorFilter->getTypeName());
StrX typeUri(theSchemaValidatorFilter->getTypeUri());
- //cout << " - getType: " << typeName << "@" << typeUri <<"\n";
+ //cout << " esv - : getType: " << typeName << "@" << typeUri <<"\n"; std::cout.flush();
store::Item_t typeQName;
GENV_ITEMFACTORY->createQName(typeQName,
@@ -191,7 +191,7 @@
"",
typeName.localFormOrDefault ("untyped"));
- xqtref_t type = theTypeManager->create_named_type(typeQName,
+ xqtref_t type = theTypeManager->create_named_type(typeQName,
TypeConstants::QUANT_ONE,
QueryLoc::null);
return type;
@@ -229,7 +229,7 @@
XMLChArray localname(typeQName->getLocalName());
//cout << " SType: " << typeQName->getLocalName() << " @ "
- // << typeQName->getNamespace() << "\n";
+ // << typeQName->getNamespace() << "\n"; std::cout.flush();
theSchemaValidatorFilter->startTypeEvent(uri, localname);
}
@@ -237,7 +237,7 @@
void EventSchemaValidator::endType()
{
- //cout << " EType \n";
+ //cout << " EType \n"; std::cout.flush();
theSchemaValidatorFilter->endTypeEvent();
}
=== modified file 'src/types/schema/SchemaValidatorFilter.cpp'
--- src/types/schema/SchemaValidatorFilter.cpp 2012-09-19 21:16:15 +0000
+++ src/types/schema/SchemaValidatorFilter.cpp 2013-02-01 20:55:25 +0000
@@ -200,7 +200,7 @@
const XMLCh *uri,
const XMLCh *localname)
{
- //cout << " svf startElememntEvent: " << StrX(localname) << " @ " << StrX(uri) << "\n";
+ //cout << " svf startElememntEvent: " << StrX(localname) << " @ " << StrX(uri) << "\n";
if(theElementToProcess)
processStartElement();
@@ -229,12 +229,14 @@
void SchemaValidatorFilter::processStartElement()
{
+ //std::cout << " svf - : processStartElement " << StrX(theLocalname.getRawBuffer()) << " v: " << fValidate << "\n"; std::cout.flush();
bool isRoot = theParentStack == 0;
unsigned int uriId = fURIStringPool->addOrFind(theUri.getRawBuffer());
- // Handle xsi:type
- if( theXsiType )
+ if (theXsiType)
{
+ // Handle xsi:type
+ //std::cout << " svf - : procStartElemEvent2 xsi: " << StrX(theXsiType) << " v: " << fValidate << "\n"; std::cout.flush();
int colonPos = -1;
unsigned int atUriId = resolveQName(theXsiType,
fPrefixBuf,
@@ -247,7 +249,6 @@
}
bool isProcessorStipulatedTypeName = false;
-
if( theProcessorStipulatedTypeName && isRoot )
{
isProcessorStipulatedTypeName = true;
@@ -334,7 +335,7 @@
getSubstitutionGroupElem();
if (substitutedElem)
{
- //cout << " svf substitutedElem: " <<
+ //cout << " svf substitutedElem: " <<
// StrX(substitutedElem->getFullName()) << "\n";
theSubstitutedElemName = substitutedElem->getBaseName();
theSubstitutedElemUri = (XMLCh*)fURIStringPool->
@@ -342,7 +343,6 @@
}
}
-
if(fValidate)
{
if (isProcessorStipulatedTypeName)
@@ -355,11 +355,17 @@
fValidator->validateElement(elemDecl);
}
}
+ else if (theXsiType)
+ {
+ //validate element even if lax but has xsi:type
+ fValidator->validateElement(elemDecl);
+ }
+
ComplexTypeInfo* typeinfo =
(fValidate ?
- ((XercSchemaValidator*)fValidator)->getCurrentTypeInfo() :
- ((SchemaElementDecl*)elemDecl)->getComplexTypeInfo());
+ ((XercSchemaValidator*)fValidator)->getCurrentTypeInfo() :
+ ((SchemaElementDecl*)elemDecl)->getComplexTypeInfo());
if(typeinfo)
{
@@ -452,7 +458,7 @@
unsigned int uriId = attr->getURIId();
const XMLCh *uri = getURIText(uriId);
- //cout << " svf: processAttrs: " << StrX(localname) << "@" << StrX(uri) <<
+ //cout << " svf: processAttrs: " << StrX(localname) << "@" << StrX(uri) <<
// " ='" << StrX(value) << "'" << endl;
bool attrValid = true;
@@ -714,8 +720,8 @@
if(theElementToProcess)
processStartElement();
- //cout << " svf: endElementEvent: " << StrX(localname) << "@" << StrX(uri) <<
- // " type: " << StrX(typeName) << " @" << StrX(typeURI) << endl;
+// std::cout << " svf: endElementEvent1: " << StrX(localname) << "@" << StrX(uri) <<
+// " type: " << StrX(typeName) << " @" << StrX(typeURI) << " v: " << fValidate << std::endl;
typeURI = SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
typeName = SchemaSymbols::fgATTVAL_ANYTYPE;
@@ -726,7 +732,7 @@
// We commandeer fCommentOrPISeen to keep _errorOccurred in
theErrorOccurred = topElem->fCommentOrPISeen;
- if(fValidate)
+ if(fValidate || theXsiType)
{
DatatypeValidator *currentDV = 0;
if(topElem->fThisElement->isDeclared())
@@ -867,7 +873,7 @@
}
--theAttrCount; // remove att from the list but still needs to be reported
- //std::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);
@@ -898,7 +904,8 @@
while(*end) ++end;
unsigned int len = (unsigned int)(end - chars);
- if(fValidate)
+ // Also handle xsi:type
+ if(fValidate || theXsiType)
{
// Get the character data opts for the current element
XMLElementDecl::CharDataOpts charOpts = XMLElementDecl::AllCharData;
@@ -1011,7 +1018,7 @@
const XMLCh *typeURI = NULL;
- if(fValidate)
+ if(fValidate || theXsiType)
{
if (theProcessorStipulatedTypeName && theParentStack == 0)
{
@@ -1051,7 +1058,7 @@
const XMLCh *typeName = NULL;
- if(fValidate)
+ if(fValidate || theXsiType)
{
//cout << " - getTypeQName: theElemDepth:" << theElemDepth << "\n";
if (theProcessorStipulatedTypeName && theElemDepth == 0 )
@@ -1582,7 +1589,7 @@
}
}
- //std::cout << "SchemaValidatorFilter::error " << XMLString::transcode(exc_msg.getRawBuffer()) << std::endl;
+ //std::cout << "SchemaValidatorFilter::error " << XMLString::transcode(exc_msg.getRawBuffer()) << std::endl; std::cout.flush();
throw XQUERY_EXCEPTION(
err::XQDY0027,
ERROR_PARAMS( StrX(exc_msg.getRawBuffer()).localForm() ),
=== modified file 'src/types/schema/XercSchemaValidator.cpp'
--- src/types/schema/XercSchemaValidator.cpp 2012-11-26 23:23:13 +0000
+++ src/types/schema/XercSchemaValidator.cpp 2013-02-01 20:55:25 +0000
@@ -91,6 +91,7 @@
{
fTrailingSeenNonWhiteSpace.flags = 0;
fTypeStack = new (fMemoryManager) ValueStackOf<ComplexTypeInfo*>(8, fMemoryManager);
+ //std::cout << " xsv - : constructor \n"; std::cout.flush();
}
XercSchemaValidator::~XercSchemaValidator()
@@ -129,6 +130,7 @@
}
ComplexTypeInfo* currType = fTypeStack->pop();
+ //std::cout << " xsv - : checkcontent pop \n"; std::cout.flush();
const SchemaElementDecl::ModelTypes modelType = (currType)
? (SchemaElementDecl::ModelTypes)(currType->getContentType())
@@ -370,6 +372,8 @@
fTrailingSeenNonWhiteSpace.flags = 0;
fSeenId = false;
fTypeStack->removeAllElements();
+ //std::cout << " xsv - : reset \n"; std::cout.flush();
+
delete fXsiType;
fXsiType = 0;
fCurrentDatatypeValidator = 0;
@@ -560,6 +564,7 @@
{
ComplexTypeInfo* elemTypeInfo = ((SchemaElementDecl*)elemDef)->getComplexTypeInfo();
fTypeStack->push(elemTypeInfo);
+ //std::cout << " xsv - : valElem1 push eti " << (elemTypeInfo ? StrX(elemTypeInfo->getTypeLocalName()).localForm() : "_") << "\n"; std::cout.flush();
fCurrentDatatypeValidator = (elemTypeInfo)
? elemTypeInfo->getDatatypeValidator()
: ((SchemaElementDecl*)elemDef)->getDatatypeValidator();
@@ -580,7 +585,7 @@
// retrieve Grammar for the uri
const XMLCh* uriStr = getScanner()->getURIText(uri);
- //std::cout << " xsv: fXsiType: " << zorba::StrX(localPart) << " @ " << zorba::StrX(uriStr) << "\n"; std::cout.flush();
+ //std::cout << " xsv - : valElem2 fXsiType: " << zorba::StrX(localPart) << " @ " << zorba::StrX(uriStr) << "\n"; std::cout.flush();
SchemaGrammar* sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(uriStr);
if (!sGrammar) {
@@ -691,7 +696,9 @@
if (!fErrorOccurred)
{
fTypeStack->pop();
+ //std::cout << " xsv - : valElem2 pop \n"; std::cout.flush();
fTypeStack->push(typeInfo);
+ //std::cout << " xsv - : valElem3 push " << (typeInfo ? StrX(typeInfo->getTypeLocalName()).localForm() : "_") << "\n"; std::cout.flush();
fCurrentDatatypeValidator = typeInfo->getDatatypeValidator();
}
}
@@ -863,6 +870,7 @@
{
fTypeStack->push(typeInfo);
fCurrentDatatypeValidator = typeInfo->getDatatypeValidator();
+ //std::cout << " xsv - : valElem4 push " << (typeInfo ? StrX(typeInfo->getTypeLocalName()).localForm() : "_") << "\n"; std::cout.flush();
}
}
}
=== modified file 'src/types/schema/XercSchemaValidator.h'
--- src/types/schema/XercSchemaValidator.h 2012-09-19 21:16:15 +0000
+++ src/types/schema/XercSchemaValidator.h 2013-02-01 20:55:25 +0000
@@ -1,12 +1,12 @@
/*
* Copyright 2006-2008 The FLWOR Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -114,7 +114,7 @@
DatatypeValidator* fCurrentDatatypeValidator;
XMLBuffer* fNotationBuf;
XMLBuffer fDatatypeBuffer;
-
+
#if _XERCES_VERSION >= 30000
// Only for 3.0.1.
//
@@ -158,7 +158,7 @@
XMLElementDecl* const elemDecl,
XERCES_CPP_NAMESPACE::QName** const children,
const unsigned int childCount);
-#endif
+#endif
virtual void faultInAttr(
XMLAttr& toFill,
@@ -194,7 +194,7 @@
// Virtual DTD handler interface.
// -----------------------------------------------------------------------
virtual bool handlesDTD() const;
-
+
// -----------------------------------------------------------------------
// Virtual Schema handler interface. handlesSchema() always return false.
// -----------------------------------------------------------------------
@@ -394,12 +394,12 @@
ContentSpecNode* getNonUnaryGroup(ContentSpecNode* const pNode);
};
-
-
+
+
// ---------------------------------------------------------------------------
// XercSchemaValidator: Setter methods
// ---------------------------------------------------------------------------
-inline void XercSchemaValidator::setGrammarResolver(GrammarResolver* grammarResolver)
+inline void XercSchemaValidator::setGrammarResolver(GrammarResolver* grammarResolver)
{
fGrammarResolver = grammarResolver;
}
@@ -413,16 +413,17 @@
delete fXsiType;
fXsiType = new (fMemoryManager)
XERCES_CPP_NAMESPACE::QName(prefix, localPart, uriId, fMemoryManager);
+ //std::cout << " xsv::setXsiType " << StrX(prefix) << ":" << StrX(localPart) << " " << uriId << "\n"; std::cout.flush();
}
-inline void XercSchemaValidator::setNillable(bool isNil)
+inline void XercSchemaValidator::setNillable(bool isNil)
{
fNil = isNil;
}
-inline void XercSchemaValidator::setExitOnFirstFatal(const bool newValue)
+inline void XercSchemaValidator::setExitOnFirstFatal(const bool newValue)
{
fSchemaErrorReporter.setExitOnFirstFatal(newValue);
}
@@ -443,7 +444,7 @@
// ---------------------------------------------------------------------------
// XercSchemaValidator: Getter methods
// ---------------------------------------------------------------------------
-inline ComplexTypeInfo* XercSchemaValidator::getCurrentTypeInfo() const
+inline ComplexTypeInfo* XercSchemaValidator::getCurrentTypeInfo() const
{
if (fTypeStack->empty())
return 0;
@@ -467,19 +468,19 @@
// ---------------------------------------------------------------------------
// Virtual interface
// ---------------------------------------------------------------------------
-inline Grammar* XercSchemaValidator::getGrammar() const
+inline Grammar* XercSchemaValidator::getGrammar() const
{
return fSchemaGrammar;
}
-inline void XercSchemaValidator::setGrammar(Grammar* aGrammar)
+inline void XercSchemaValidator::setGrammar(Grammar* aGrammar)
{
fSchemaGrammar = (SchemaGrammar*) aGrammar;
}
-inline void XercSchemaValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
+inline void XercSchemaValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
{
XMLValidator::setErrorReporter(errorReporter);
fSchemaErrorReporter.setErrorReporter(errorReporter);
@@ -512,7 +513,7 @@
const int min1,
const int max1,
const int min2,
- const int max2)
+ const int max2)
{
if (min1 >= min2 &&
(max2 == SchemaSymbols::XSD_UNBOUNDED ||
=== added file 'test/rbkt/ExpQueryResults/zorba/schemas/val-laxXsiType.xml.res'
--- test/rbkt/ExpQueryResults/zorba/schemas/val-laxXsiType.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/schemas/val-laxXsiType.xml.res 2013-02-01 20:55:25 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+xs:long xs:integer xs:untypedAtomic
=== added file 'test/rbkt/Queries/zorba/schemas/val-laxXsiType.xq'
--- test/rbkt/Queries/zorba/schemas/val-laxXsiType.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/schemas/val-laxXsiType.xq 2013-02-01 20:55:25 +0000
@@ -0,0 +1,18 @@
+import module namespace schema = "http://www.zorba-xquery.com/modules/schema";;
+
+declare variable $doc :=
+<numbers xmlns:xs="http://www.w3.org/2001/XMLSchema";
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+<xs_long xsi:type="xs:long">1</xs_long>
+<xs_long xsi:type="xs:integer">2</xs_long>
+<xs_long>3</xs_long>
+</numbers>
+;
+
+declare variable $vdoc := validate lax { $doc };
+
+(
+schema:schema-type(fn:data(($vdoc//xs_long)[1])),
+schema:schema-type(fn:data(($vdoc//xs_long)[2])),
+schema:schema-type(fn:data(($vdoc//xs_long)[3]))
+)
Follow ups
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: noreply, 2013-02-08
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Zorba Build Bot, 2013-02-08
-
Re: [Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Matthias Brantner, 2013-02-08
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Zorba Build Bot, 2013-02-08
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Cezar Andrei, 2013-02-08
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Zorba Build Bot, 2013-02-06
-
Re: [Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Zorba Build Bot, 2013-02-06
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Cezar Andrei, 2013-02-06
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Zorba Build Bot, 2013-02-06
-
Re: [Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Zorba Build Bot, 2013-02-06
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Cezar Andrei, 2013-02-06
-
Re: [Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Cezar Andrei, 2013-02-06
-
Re: [Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Markos Zaharioudakis, 2013-02-06
-
Re: [Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Matthias Brantner, 2013-02-05
-
Re: [Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Cezar Andrei, 2013-02-01
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Zorba Build Bot, 2013-02-01
-
Re: [Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Zorba Build Bot, 2013-02-01
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Zorba Build Bot, 2013-02-01
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Zorba Build Bot, 2013-02-01
-
[Merge] lp:~zorba-coders/zorba/bug1023362-xsiTypeIgnored into lp:zorba
From: Cezar Andrei, 2013-02-01