From 16a16480e8378bb84c671a95dc3f86ce8ff967ce Mon Sep 17 00:00:00 2001 From: Khaled Noaman <knoaman@apache.org> Date: Tue, 20 Nov 2001 20:32:52 +0000 Subject: [PATCH] Bypass validating element's simple content if it's empty and element is nillable. git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173258 13f79535-47bb-0310-9956-ffa450edef68 --- src/validators/schema/SchemaValidator.cpp | 12 +++++++++--- src/validators/schema/identity/ValueStore.cpp | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/validators/schema/SchemaValidator.cpp b/src/validators/schema/SchemaValidator.cpp index 97acb2b31..d1a7f51e9 100644 --- a/src/validators/schema/SchemaValidator.cpp +++ b/src/validators/schema/SchemaValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.24 2001/11/20 20:32:52 knoaman + * Bypass validating element's simple content if it's empty and element is nillable. + * * Revision 1.23 2001/11/13 13:25:08 tng * Deprecate function XMLValidator::checkRootElement. * @@ -278,9 +281,12 @@ int SchemaValidator::checkContent (XMLElementDecl* const elemDecl } else { // no default value, then check nillable - if (fNil) { - if (XMLString::compareString(value, XMLUni::fgZeroLenString)) - emitError(XMLValid::NilAttrNotEmpty, elemDecl->getFullName()); + if (!XMLString::compareString(value, XMLUni::fgZeroLenString)) { + if ((((SchemaElementDecl*)elemDecl)->getMiscFlags() & SchemaSymbols::NILLABLE) == 0) + fCurrentDV->validate(value); + } + else if (fNil) { + emitError(XMLValid::NilAttrNotEmpty, elemDecl->getFullName()); } else fCurrentDV->validate(value); diff --git a/src/validators/schema/identity/ValueStore.cpp b/src/validators/schema/identity/ValueStore.cpp index acebb328f..ebaf2818c 100644 --- a/src/validators/schema/identity/ValueStore.cpp +++ b/src/validators/schema/identity/ValueStore.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.2 2001/11/20 20:32:52 knoaman + * Bypass validating element's simple content if it's empty and element is nillable. + * * Revision 1.1 2001/11/02 14:08:40 knoaman * Add support for identity constraints. * @@ -246,6 +249,22 @@ bool ValueStore::isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const return ((XMLString::compareString(val1, val2)) == 0); } + unsigned int val1Len = XMLString::stringLen(val1); + unsigned int val2Len = XMLString::stringLen(val2); + + if (!val1Len && !val2Len) { + + if (dv1 == dv2) { + return true; + } + + return false; + } + + if (!val1Len || !val2Len) { + return false; + } + // are the validators equal? // As always we are obliged to compare by reference... if (dv1 == dv2) { -- GitLab