in src/xercesc/validators/datatype/AbstractStringValidator.cpp [269:470]
void AbstractStringValidator::inspectFacetBase(MemoryManager* const manager)
{
AbstractStringValidator *pBaseValidator = (AbstractStringValidator*) getBaseValidator();
int thisFacetsDefined = getFacetsDefined();
if ( (!thisFacetsDefined && !fEnumeration) ||
(!pBaseValidator) )
return;
int baseFacetsDefined = pBaseValidator->getFacetsDefined();
XMLSize_t thisLength = getLength();
XMLSize_t thisMinLength = getMinLength();
XMLSize_t thisMaxLength = getMaxLength();
XMLSize_t baseLength = pBaseValidator->getLength();
XMLSize_t baseMinLength = pBaseValidator->getMinLength();
XMLSize_t baseMaxLength = pBaseValidator->getMaxLength();
int baseFixed = pBaseValidator->getFixed();
/***
check facets against base.facets
Note: later we need to check the "fix" option of the base type
and apply that to every individual facet.
***/
/***
Non coexistence of derived' length and base' (minLength | maxLength)
base' length and derived' (minLength | maxLength)
E2-35
It is an error for both length and either of minLength or maxLength to be members of {facets},
unless they are specified in different derivation steps in which case the following must be true:
the {value} of minLength <= the {value} of length <= the {value} of maxLength
***/
// error: length > base.maxLength
// length < base.minLength
if ((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) !=0)
{
if (((baseFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) !=0) &&
(thisLength > baseMaxLength) )
{
REPORT_FACET_ERROR(thisLength
, baseMaxLength
, XMLExcepts::FACET_Len_baseMaxLen
, manager)
}
if (((baseFacetsDefined & DatatypeValidator::FACET_MINLENGTH) !=0) &&
(thisLength < baseMinLength) )
{
REPORT_FACET_ERROR(thisLength
, baseMinLength
, XMLExcepts::FACET_Len_baseMinLen
, manager)
}
}
// error: baseLength > maxLength
// baseLength < minLength
if ((baseFacetsDefined & DatatypeValidator::FACET_LENGTH) !=0)
{
if (((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) !=0) &&
(baseLength > thisMaxLength) )
{
REPORT_FACET_ERROR(thisMaxLength
, baseLength
, XMLExcepts::FACET_maxLen_baseLen
, manager)
}
if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) !=0) &&
(baseLength < thisMinLength) )
{
REPORT_FACET_ERROR(thisMinLength
, baseLength
, XMLExcepts::FACET_minLen_baseLen
, manager)
}
}
// check 4.3.1.c2 error: length != base.length
if (((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) !=0) &&
((baseFacetsDefined & DatatypeValidator::FACET_LENGTH) !=0))
{
if ( thisLength != baseLength )
{
REPORT_FACET_ERROR(thisLength
, baseLength
, XMLExcepts::FACET_Len_baseLen
, manager)
}
}
/***
|--- derived ---|
base.minLength <= minLength <= maxLength <= base.maxLength
|------------------- base -------------------|
***/
// check 4.3.2.c1 must: minLength <= base.maxLength
if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH ) != 0) &&
((baseFacetsDefined & DatatypeValidator::FACET_MAXLENGTH ) != 0))
{
if ( thisMinLength > baseMaxLength )
{
REPORT_FACET_ERROR(thisMinLength
, baseMaxLength
, XMLExcepts::FACET_minLen_basemaxLen
, manager)
}
}
// check 4.3.2.c2 error: minLength < base.minLength
if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) !=0) &&
((baseFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0))
{
if ((baseFixed & DatatypeValidator::FACET_MINLENGTH) !=0)
{
if ( thisMinLength != baseMinLength )
{
REPORT_FACET_ERROR(thisMinLength
, baseMinLength
, XMLExcepts::FACET_minLen_base_fixed
, manager)
}
}
else
{
if ( thisMinLength < baseMinLength )
{
REPORT_FACET_ERROR(thisMinLength
, baseMinLength
, XMLExcepts::FACET_minLen_baseminLen
, manager)
}
}
}
// check 4.3.2.c1 must: base.minLength <= maxLength
if (((baseFacetsDefined & DatatypeValidator::FACET_MINLENGTH) !=0) &&
((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) !=0))
{
if ( baseMinLength > thisMaxLength )
{
REPORT_FACET_ERROR(thisMaxLength
, baseMinLength
, XMLExcepts::FACET_maxLen_baseminLen
, manager)
}
}
// check 4.3.3.c1 error: maxLength > base.maxLength
if (((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) !=0) &&
((baseFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) !=0))
{
if ((baseFixed & DatatypeValidator::FACET_MAXLENGTH) !=0)
{
if ( thisMaxLength != baseMaxLength )
{
REPORT_FACET_ERROR(thisMaxLength
, baseMaxLength
, XMLExcepts::FACET_maxLen_base_fixed
, manager)
}
}
else
{
if ( thisMaxLength > baseMaxLength )
{
REPORT_FACET_ERROR(thisMaxLength
, baseMaxLength
, XMLExcepts::FACET_maxLen_basemaxLen
, manager)
}
}
}
// check 4.3.5.c0 must: enumeration values from the value space of base
if ( ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0) &&
(getEnumeration() !=0))
{
XMLSize_t i = 0;
XMLSize_t enumLength = getEnumeration()->size();
for ( ; i < enumLength; i++)
{
// ask parent do a complete check
pBaseValidator->checkContent(getEnumeration()->elementAt(i), (ValidationContext*)0, false, manager);
#if 0
// spec says that only base has to checkContent
// enum shall pass this->checkContent() as well.
checkContent(getEnumeration()->elementAt(i), (ValidationContext*)0, false, manager);
#endif
}
}
checkAdditionalFacetConstraints(manager);
} //end of inspectFacetBase