当前位置: 首页>>代码示例>>C++>>正文


C++ DatatypeValidator::validate方法代码示例

本文整理汇总了C++中DatatypeValidator::validate方法的典型用法代码示例。如果您正苦于以下问题:C++ DatatypeValidator::validate方法的具体用法?C++ DatatypeValidator::validate怎么用?C++ DatatypeValidator::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DatatypeValidator的用法示例。


在下文中一共展示了DatatypeValidator::validate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createFloatOrDerived

/** create a xs:float with a MAPM */
ATFloatOrDerived::Ptr ItemFactoryImpl::createFloatOrDerived(const XMLCh* typeURI, 
                                                              const XMLCh* typeName,
                                                              const MAPM value, 
                                                              const DynamicContext* context)
{ 
  ATFloatOrDerived::Ptr retVal = new ATFloatOrDerivedImpl(typeURI, typeName, value, context);

  // check if it's a valid instance
  DatatypeValidator* validator = context->getDocumentCache()->getDatatypeValidator(typeURI, typeName);
  if(!validator) {
    XMLBuffer buf(1023, context->getMemoryManager());
    buf.append(X("Type "));
    buf.append(typeURI);
    buf.append(chColon);
    buf.append(typeName);
    buf.append(X(" not found"));
    XQThrow2(TypeNotFoundException, X("ItemFactoryImpl::createDoubleOrDerived"), buf.getRawBuffer());
  }
  try {
    validator->validate(retVal->asString(context), 0, context->getMemoryManager());
  } catch (XMLException &e) {
    XMLBuffer buf(1023, context->getMemoryManager());
    buf.append(e.getMessage());
    buf.append(X(" [err:FORG0001]"));
    XQThrow2(InvalidLexicalSpaceException, X("ItemFactoryImpl::createDoubleOrDerived"), buf.getRawBuffer());
  }

  return retVal;
}
开发者ID:xubingyue,项目名称:xqilla,代码行数:30,代码来源:ItemFactoryImpl.cpp

示例2: getCanonicalRepresentation

/**
 * Canonical Representation
 *
 */
const XMLCh* DatatypeValidator::getCanonicalRepresentation(const XMLCh*         const rawData
                                                          ,      MemoryManager* const memMgr
                                                          ,      bool                 toValidate) const
{
    MemoryManager* toUse = memMgr? memMgr : fMemoryManager;

    if (toValidate)
    {
        DatatypeValidator *temp = (DatatypeValidator*) this;

        try
        {
            temp->validate(rawData, 0, toUse);    
        }
        catch (...)
        {
            return 0;
        }
    }

    return XMLString::replicate(rawData, toUse);
}
开发者ID:ksmyth,项目名称:xerces-c,代码行数:26,代码来源:DatatypeValidator.cpp

示例3: checkContent

//
// here content is a list of items
//
void ListDatatypeValidator::checkContent(       BaseRefVectorOf<XMLCh>*       tokenVector
                                        , const XMLCh*                  const content
                                        ,       ValidationContext*      const context
                                        ,       bool                          asBase
                                        ,       MemoryManager*          const manager)
{
    DatatypeValidator* bv = getBaseValidator();

    if (bv->getType() == DatatypeValidator::List)
        ((ListDatatypeValidator*)bv)->checkContent(tokenVector, content, context, true, manager);
    else
    {   // the ultimate itemType DTV
        for (unsigned int i = 0; i < tokenVector->size(); i++)
            bv->validate(tokenVector->elementAt(i), context, manager);
    }

    int thisFacetsDefined = getFacetsDefined();

    // we check pattern first
    if ( (thisFacetsDefined & DatatypeValidator::FACET_PATTERN ) != 0 )
    {
        // lazy construction
        if (getRegex() == 0)
        {
            try {
                setRegex(new (fMemoryManager) RegularExpression(getPattern(), SchemaSymbols::fgRegEx_XOption, fMemoryManager));            	
            }
            catch (XMLException &e)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), manager);
            }
        }

        //check every item in the list as a whole
        if (getRegex()->matches(content, manager) == false)
        {
            ThrowXMLwithMemMgr2(InvalidDatatypeValueException
                    , XMLExcepts::VALUE_NotMatch_Pattern
                    , content
                    , getPattern()
                    , manager);
        }

    }

    // if this is a base validator, we only need to check pattern facet
    // all other facet were inherited by the derived type
    if (asBase)
        return;

    unsigned int tokenNumber = tokenVector->size();

    if (((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) != 0) &&
        (tokenNumber > getMaxLength()))
    {
        XMLCh value1[BUF_LEN+1];
        XMLCh value2[BUF_LEN+1];
        XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager);
        XMLString::binToText(getMaxLength(), value2, BUF_LEN, 10, manager);

        ThrowXMLwithMemMgr3(InvalidDatatypeValueException
                , XMLExcepts::VALUE_GT_maxLen
                , getContent()
                , value1
                , value2
                , manager);
    }

    if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0) &&
        (tokenNumber < getMinLength()))
    {
        XMLCh value1[BUF_LEN+1];
        XMLCh value2[BUF_LEN+1];
        XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager);
        XMLString::binToText(getMinLength(), value2, BUF_LEN, 10, manager);

        ThrowXMLwithMemMgr3(InvalidDatatypeValueException
                , XMLExcepts::VALUE_LT_minLen
                , getContent()
                , value1
                , value2
                , manager);
    }

    if (((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) != 0) &&
        (tokenNumber != AbstractStringValidator::getLength()))
    {
        XMLCh value1[BUF_LEN+1];
        XMLCh value2[BUF_LEN+1];
        XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager);
        XMLString::binToText(AbstractStringValidator::getLength(), value2, BUF_LEN, 10, manager);

        ThrowXMLwithMemMgr3(InvalidDatatypeValueException
                , XMLExcepts::VALUE_NE_Len
                , getContent()
                , value1
                , value2
//.........这里部分代码省略.........
开发者ID:mydw,项目名称:mydw,代码行数:101,代码来源:ListDatatypeValidator.cpp

示例4: validate

void GeneralAttributeCheck::validate(const DOMElement* const elem,
                                     const XMLCh* const attName,
                                     const XMLCh* const attValue,
                                     const short dvIndex,
                                     TraverseSchema* const schema)
{
    bool isInvalid = false;
    DatatypeValidator* dv = 0;

    fValidationContext = schema->fSchemaInfo->getValidationContext();
    switch (dvIndex) {
    case DV_Form:
        if (!XMLString::equals(attValue, SchemaSymbols::fgATTVAL_QUALIFIED)
            && !XMLString::equals(attValue, SchemaSymbols::fgATTVAL_UNQUALIFIED)) {
            isInvalid = true;
        }
        break;
    case DV_MaxOccurs:
            // maxOccurs = (nonNegativeInteger | unbounded)
        if (!XMLString::equals(attValue, fgUnbounded)) {
            dv = fNonNegIntDV;
        }
        break;
    case DV_MaxOccurs1:
        if (!XMLString::equals(attValue, fgValueOne)) {
            isInvalid = true;
        }
        break;
    case DV_MinOccurs1:
        if (!XMLString::equals(attValue, fgValueZero)
            && !XMLString::equals(attValue, fgValueOne)) {
            isInvalid = true;
        }
        break;
    case DV_ProcessContents:
        if (!XMLString::equals(attValue, SchemaSymbols::fgATTVAL_SKIP)
            && !XMLString::equals(attValue, SchemaSymbols::fgATTVAL_LAX)
            && !XMLString::equals(attValue, SchemaSymbols::fgATTVAL_STRICT)) {
            isInvalid = true;
        }
        break;
    case DV_Use:
        if (!XMLString::equals(attValue, SchemaSymbols::fgATTVAL_OPTIONAL)
            && !XMLString::equals(attValue, SchemaSymbols::fgATTVAL_PROHIBITED)
            && !XMLString::equals(attValue, SchemaSymbols::fgATTVAL_REQUIRED)) {
            isInvalid = true;
        }
        break;
    case DV_WhiteSpace:
        if (!XMLString::equals(attValue, SchemaSymbols::fgWS_PRESERVE)
            && !XMLString::equals(attValue, SchemaSymbols::fgWS_REPLACE)
            && !XMLString::equals(attValue, SchemaSymbols::fgWS_COLLAPSE)) {
            isInvalid = true;
        }
        break;
    case DV_Boolean:
        dv = fBooleanDV;
        break;
    case DV_NonNegInt:
        dv = fNonNegIntDV;
        break;
    case DV_AnyURI:
        dv = fAnyURIDV;
        break;
    case DV_ID:
        if (fValidationContext)
        {
            dv = &fIDValidator;
        }
        break;
    }

    if (dv) {
        try {
            dv->validate(attValue, fValidationContext, fMemoryManager);
        }
        catch(const XMLException& excep) {
            schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage());
        }
        catch(const OutOfMemoryException&)
        {
            throw;
        }
        catch(...) {
            isInvalid = true;
        }
    }

    if (isInvalid) {
        schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::InvalidAttValue,
                                  attValue, attName);
    }
}
开发者ID:mydw,项目名称:mydw,代码行数:93,代码来源:GeneralAttributeCheck.cpp


注:本文中的DatatypeValidator::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。