本文整理汇总了C++中DatatypeValidator类的典型用法代码示例。如果您正苦于以下问题:C++ DatatypeValidator类的具体用法?C++ DatatypeValidator怎么用?C++ DatatypeValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DatatypeValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ATFloatOrDerivedImpl
/** 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;
}
示例2: while
DatatypeValidator* ListDatatypeValidator::getItemTypeDTV() const
{
DatatypeValidator* bdv = this->getBaseValidator();
while (bdv->getType() == DatatypeValidator::List)
bdv = bdv->getBaseValidator();
return bdv;
}
示例3: getBuiltInBaseValidator
DatatypeValidator* DatatypeValidatorFactory::getBuiltInBaseValidator(const DatatypeValidator* const dv)
{
DatatypeValidator *curdv = (DatatypeValidator*)dv;
while (curdv)
{
if (curdv == getBuiltInRegistry()->get(curdv->getTypeLocalName()))
return curdv;
else
curdv = curdv->getBaseValidator();
}
return 0;
}
示例4: while
bool XSObjectFactory::isMultiValueFacetDefined(DatatypeValidator* const dv)
{
DatatypeValidator* tmpDV = dv;
while (tmpDV)
{
if ((tmpDV->getFacetsDefined() & DatatypeValidator::FACET_PATTERN)
|| (tmpDV->getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION))
return true;
tmpDV = tmpDV->getBaseValidator();
}
return false;
}
示例5: return
bool ValueStore::isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const val1,
DatatypeValidator* const dv2, const XMLCh* const val2) {
// if either validator's null, fall back on string comparison
if(!dv1 || !dv2) {
return (XMLString::equals(val1, val2));
}
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) {
return ((dv1->compare(val1, val2, fMemoryManager)) == 0);
}
// see if this.fValidator is derived from value.fValidator:
DatatypeValidator* tempVal = dv1;
for(; !tempVal || tempVal == dv2; tempVal = tempVal->getBaseValidator()) ;
if (tempVal) { // was derived!
return ((dv2->compare(val1, val2, fMemoryManager)) == 0);
}
// see if value.fValidator is derived from this.fValidator:
for(tempVal = dv2; !tempVal || tempVal == dv1; tempVal = tempVal->getBaseValidator()) ;
if(tempVal) { // was derived!
return ((dv1->compare(val1, val2, fMemoryManager)) == 0);
}
// if we're here it means the types weren't related. Must fall back to strings:
return (XMLString::equals(val1, val2));
}
示例6: getCanRepGroup
/***
*
* For any dv other than Decimaldv, return String only.
* Later on if support to dv other than Decimaldv arise, we may
* add them fCanRepRegistry during DatatypeValidatorFactory::initCanRepRegistory()
*
***/
XMLCanRepGroup::CanRepGroup DatatypeValidatorFactory::getCanRepGroup(const DatatypeValidator* const dv)
{
if (!dv)
return XMLCanRepGroup::String;
DatatypeValidator *curdv = (DatatypeValidator*) dv;
while (curdv)
{
if (fCanRepRegistry->containsKey(curdv))
return fCanRepRegistry->get(curdv)->getGroup();
else
curdv = curdv->getBaseValidator();
}
return XMLCanRepGroup::String;
}
示例7: getItemTypeDTV
bool ListDatatypeValidator::valueSpaceCheck(BaseRefVectorOf<XMLCh>* tokenVector
, const XMLCh* const enumStr
, MemoryManager* const manager) const
{
DatatypeValidator* theItemTypeDTV = getItemTypeDTV();
BaseRefVectorOf<XMLCh>* enumVector = XMLString::tokenizeString(enumStr, manager);
Janitor<BaseRefVectorOf<XMLCh> > janName(enumVector);
if (tokenVector->size() != enumVector->size())
return false;
for ( unsigned int j = 0; j < tokenVector->size(); j++ )
{
if (theItemTypeDTV->compare(tokenVector->elementAt(j), enumVector->elementAt(j), manager) != 0)
return false;
}
return true;
}
示例8: 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);
}
示例9: getMemoryManager
/***
* 2.5.1.2 List datatypes
*
* The canonical-lexical-representation for the ·list· datatype is defined as
* the lexical form in which each item in the ·list· has the canonical
* lexical representation of its ·itemType·.
***/
const XMLCh* ListDatatypeValidator::getCanonicalRepresentation(const XMLCh* const rawData
, MemoryManager* const memMgr
, bool toValidate) const
{
MemoryManager* toUse = memMgr? memMgr : getMemoryManager();
ListDatatypeValidator* temp = (ListDatatypeValidator*) this;
temp->setContent(rawData);
BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(rawData, toUse);
Janitor<BaseRefVectorOf<XMLCh> > janName(tokenVector);
if (toValidate)
{
try
{
temp->checkContent(tokenVector, rawData, 0, false, toUse);
}
catch (...)
{
return 0;
}
}
unsigned int retBufSize = 2 * XMLString::stringLen(rawData);
XMLCh* retBuf = (XMLCh*) toUse->allocate(retBufSize * sizeof(XMLCh));
retBuf[0] = 0;
XMLCh* retBufPtr = retBuf;
DatatypeValidator* itemDv = this->getItemTypeDTV();
try
{
for (unsigned int i = 0; i < tokenVector->size(); i++)
{
XMLCh* itemCanRep = (XMLCh*) itemDv->getCanonicalRepresentation(tokenVector->elementAt(i), toUse, false);
unsigned int itemLen = XMLString::stringLen(itemCanRep);
if(retBufPtr+itemLen+2 >= retBuf+retBufSize)
{
// need to resize
XMLCh * oldBuf = retBuf;
retBuf = (XMLCh*) toUse->allocate(retBufSize * sizeof(XMLCh) * 4);
memcpy(retBuf, oldBuf, retBufSize * sizeof(XMLCh ));
retBufPtr = (retBufPtr - oldBuf) + retBuf;
toUse->deallocate(oldBuf);
retBufSize <<= 2;
}
XMLString::catString(retBufPtr, itemCanRep);
retBufPtr = retBufPtr + itemLen + 1;
*(retBufPtr++) = chSpace;
*(retBufPtr) = chNull;
toUse->deallocate(itemCanRep);
}
return retBuf;
}
catch (...)
{
return 0;
}
}
示例10: getBaseValidator
//
// 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
//.........这里部分代码省略.........
示例11: 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);
}
}
示例12: new
DatatypeValidator* DatatypeValidatorFactory::createDatatypeValidator
(
const XMLCh* const typeName
, RefVectorOf<DatatypeValidator>* const validators
, const int finalSet
, const bool userDefined
, MemoryManager* const userManager
)
{
if (validators == 0)
return 0;
DatatypeValidator* datatypeValidator = 0;
MemoryManager* const manager = (userDefined)
? userManager : XMLPlatformUtils::fgMemoryManager;
datatypeValidator = new (manager) UnionDatatypeValidator(validators, finalSet, manager);
if (datatypeValidator != 0) {
if (userDefined) {
if (!fUserDefinedRegistry) {
fUserDefinedRegistry = new (userManager) RefHashTableOf<DatatypeValidator>(29, userManager);
}
fUserDefinedRegistry->put((void *)typeName, datatypeValidator);
}
else {
fBuiltInRegistry->put((void *)typeName, datatypeValidator);
}
datatypeValidator->setTypeName(typeName);
// Set PSVI information for Ordered, Numeric, Bounded & Finite
unsigned int valSize = validators->size();
if (valSize)
{
DatatypeValidator::ValidatorType ancestorId = getPrimitiveDV(validators->elementAt(0)->getType());
// For a union the ORDERED {value} is partial unless one of the following:
// 1. If every member of {member type definitions} is derived from a common ancestor other than the simple ur-type, then {value} is the same as that ancestor's ordered facet.
// 2. If every member of {member type definitions} has a {value} of false for the ordered facet, then {value} is false.
bool allOrderedFalse = true;
bool commonAnc = ancestorId != DatatypeValidator::AnySimpleType;
bool allNumeric = true;
bool allBounded = true;
bool allFinite = true;
for(unsigned int i = 0 ; (i < valSize) && (commonAnc || allOrderedFalse || allNumeric || allBounded || allFinite); i++)
{
// for the other member types, check whether the value is false
// and whether they have the same ancestor as the first one
if (commonAnc)
commonAnc = ancestorId == getPrimitiveDV(validators->elementAt(i)->getType());
if (allOrderedFalse)
allOrderedFalse = validators->elementAt(i)->getOrdered() == XSSimpleTypeDefinition::ORDERED_FALSE;
if (allNumeric && !validators->elementAt(i)->getNumeric())
{
allNumeric = false;
}
if (allBounded && (!validators->elementAt(i)->getBounded() ||
ancestorId != getPrimitiveDV(validators->elementAt(i)->getType())))
{
allBounded = false;
}
if (allFinite && !validators->elementAt(i)->getFinite())
{
allFinite = false;
}
}
if (commonAnc)
{
datatypeValidator->setOrdered(validators->elementAt(0)->getOrdered());
}
else if (allOrderedFalse)
{
datatypeValidator->setOrdered(XSSimpleTypeDefinition::ORDERED_FALSE);
}
else
{
datatypeValidator->setOrdered(XSSimpleTypeDefinition::ORDERED_PARTIAL);
}
datatypeValidator->setNumeric(allNumeric);
datatypeValidator->setBounded(allBounded);
datatypeValidator->setFinite(allFinite);
}
else // size = 0
{
datatypeValidator->setOrdered(XSSimpleTypeDefinition::ORDERED_PARTIAL);
datatypeValidator->setNumeric(true);
datatypeValidator->setBounded(true);
datatypeValidator->setFinite(true);
}
}
return datatypeValidator;
}
示例13: janFacets
// ---------------------------------------------------------------------------
// DatatypeValidatorFactory: factory methods
// ---------------------------------------------------------------------------
DatatypeValidator* DatatypeValidatorFactory::createDatatypeValidator
(
const XMLCh* const typeName
, DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const bool isDerivedByList
, const int finalSet
, const bool isUserDefined
, MemoryManager* const userManager
)
{
if (baseValidator == 0) {
if (facets) {
Janitor<KVStringPairHashTable> janFacets(facets);
}
if (enums) {
Janitor<XMLChRefVector> janEnums(enums);
}
return 0;
}
DatatypeValidator* datatypeValidator = 0;
MemoryManager* const manager = (isUserDefined)
? userManager : XMLPlatformUtils::fgMemoryManager;
if (isDerivedByList) {
datatypeValidator = new (manager) ListDatatypeValidator(baseValidator, facets, enums, finalSet, manager);
// Set PSVI information for Ordered, Numeric, Bounded & Finite
datatypeValidator->setOrdered(XSSimpleTypeDefinition::ORDERED_FALSE);
datatypeValidator->setNumeric(false);
if (facets &&
((facets->get(SchemaSymbols::fgELT_LENGTH) ||
(facets->get(SchemaSymbols::fgELT_MINLENGTH) && facets->get(SchemaSymbols::fgELT_MAXLENGTH)))))
{
datatypeValidator->setBounded(true);
datatypeValidator->setFinite(true);
}
else
{
datatypeValidator->setBounded(false);
datatypeValidator->setFinite(false);
}
}
else {
if ((baseValidator->getType() != DatatypeValidator::String) && facets) {
KVStringPair* value = facets->get(SchemaSymbols::fgELT_WHITESPACE);
if (value != 0) {
facets->removeKey(SchemaSymbols::fgELT_WHITESPACE);
}
}
datatypeValidator = baseValidator->newInstance
(
facets
, enums
, finalSet
, manager
);
// Set PSVI information for Ordered, Numeric, Bounded & Finite
datatypeValidator->setOrdered(baseValidator->getOrdered());
datatypeValidator->setNumeric(baseValidator->getNumeric());
RefHashTableOf<KVStringPair>* baseFacets = baseValidator->getFacets();
if (facets &&
((facets->get(SchemaSymbols::fgELT_MININCLUSIVE) ||
facets->get(SchemaSymbols::fgELT_MINEXCLUSIVE) ||
(baseFacets && (baseFacets->get(SchemaSymbols::fgELT_MININCLUSIVE) ||
baseFacets->get(SchemaSymbols::fgELT_MINEXCLUSIVE))))) &&
(facets->get(SchemaSymbols::fgELT_MAXINCLUSIVE) ||
facets->get(SchemaSymbols::fgELT_MAXEXCLUSIVE) ||
(baseFacets && ((baseFacets->get(SchemaSymbols::fgELT_MAXINCLUSIVE) ||
baseFacets->get(SchemaSymbols::fgELT_MAXEXCLUSIVE))))))
{
datatypeValidator->setBounded(true);
}
else
{
datatypeValidator->setBounded(false);
}
if (baseValidator->getFinite())
{
datatypeValidator->setFinite(true);
}
else if (!facets)
{
datatypeValidator->setFinite(false);
}
else if (facets->get(SchemaSymbols::fgELT_LENGTH) || facets->get(SchemaSymbols::fgELT_MAXLENGTH) ||
facets->get(SchemaSymbols::fgELT_TOTALDIGITS))
//.........这里部分代码省略.........
示例14: lock
// ---------------------------------------------------------------------------
// DatatypeValidatorFactory: Registry initialization methods
// ---------------------------------------------------------------------------
void DatatypeValidatorFactory::expandRegistryToFullSchemaSet()
{
if (!sBuiltInRegistryMutexRegistered)
{
if (!sBuiltInRegistryMutex)
{
XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex);
if (!sBuiltInRegistryMutex)
sBuiltInRegistryMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager);
}
// Use a faux scope to synchronize while we do this
{
XMLMutexLock lock(sBuiltInRegistryMutex);
// If we got here first, then register it and set the registered flag
if (!sBuiltInRegistryMutexRegistered)
{
//Initialize common Schema/DTD Datatype validator set
fBuiltInRegistry = new RefHashTableOf<DatatypeValidator>(29);
DatatypeValidator *dv = new StringDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_STRING, dv);
dv = new NOTATIONDatatypeValidator();
dv->setTypeName(XMLUni::fgNotationString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) XMLUni::fgNotationString, dv);
dv = new AnySimpleTypeDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_ANYSIMPLETYPE, dv);
dv = new BooleanDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_BOOLEAN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_BOOLEAN, dv);
dv = new DecimalDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_DECIMAL, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DECIMAL, dv);
dv = new HexBinaryDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_HEXBINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_HEXBINARY, dv);
dv = new Base64BinaryDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_BASE64BINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_BASE64BINARY, dv);
dv = new DoubleDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_DOUBLE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DOUBLE, dv);
dv = new FloatDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_FLOAT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_FLOAT, dv);
dv = new AnyURIDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_ANYURI, dv);
dv = new QNameDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_QNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_QNAME, dv);
dv = new DateTimeDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_DATETIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DATETIME, dv);
dv = new DateDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_DATE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DATE, dv);
dv = new TimeDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_TIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_TIME, dv);
dv = new DayDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_DAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DAY, dv);
dv = new MonthDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_MONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_MONTH, dv);
dv = new MonthDayDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_MONTHDAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_MONTHDAY, dv);
dv = new YearDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_YEAR, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_YEAR, dv);
dv = new YearMonthDatatypeValidator();
dv->setTypeName(SchemaSymbols::fgDT_YEARMONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_YEARMONTH, dv);
//.........这里部分代码省略.........
示例15: new
XSSimpleTypeDefinition*
XSObjectFactory::addOrFind(DatatypeValidator* const validator,
XSModel* const xsModel,
bool isAnySimpleType)
{
XSSimpleTypeDefinition* xsObj = (XSSimpleTypeDefinition*) xsModel->getXSObject(validator);
if (!xsObj)
{
XSTypeDefinition* baseType = 0;
XSSimpleTypeDefinitionList* memberTypes = 0;
XSSimpleTypeDefinition* primitiveOrItemType = 0;
XSSimpleTypeDefinition::VARIETY typeVariety = XSSimpleTypeDefinition::VARIETY_ATOMIC;
bool primitiveTypeSelf = false;
//REVISIT: the getFixed method is protected so added friend XSObjectFactory
// to DatatypeValidator class...
DatatypeValidator::ValidatorType dvType = validator->getType();
DatatypeValidator* baseDV = validator->getBaseValidator();
if (dvType == DatatypeValidator::Union)
{
typeVariety = XSSimpleTypeDefinition::VARIETY_UNION;
RefVectorOf<DatatypeValidator>* membersDV = ((UnionDatatypeValidator*)validator)->getMemberTypeValidators();
XMLSize_t size = membersDV->size();
if (size)
{
memberTypes = new (fMemoryManager) RefVectorOf<XSSimpleTypeDefinition>(size, false, fMemoryManager);
for (XMLSize_t i=0; i<size; i++)
memberTypes->addElement(addOrFind(membersDV->elementAt(i), xsModel));
}
if (baseDV)
{
baseType = addOrFind(baseDV, xsModel);
}
else
{
baseType = (XSSimpleTypeDefinition*) xsModel->getTypeDefinition
(
SchemaSymbols::fgDT_ANYSIMPLETYPE
, SchemaSymbols::fgURI_SCHEMAFORSCHEMA
);
}
}
else if (dvType == DatatypeValidator::List)
{
typeVariety = XSSimpleTypeDefinition::VARIETY_LIST;
if (baseDV->getType() == DatatypeValidator::List)
{
baseType = addOrFind(baseDV, xsModel);
primitiveOrItemType = ((XSSimpleTypeDefinition*) baseType)->getItemType();
}
else
{
baseType = (XSSimpleTypeDefinition*) xsModel->getTypeDefinition
(
SchemaSymbols::fgDT_ANYSIMPLETYPE
, SchemaSymbols::fgURI_SCHEMAFORSCHEMA
);
primitiveOrItemType = addOrFind(baseDV, xsModel);
}
}
else if (!isAnySimpleType)
{
if (baseDV)
{
baseType = addOrFind(baseDV, xsModel);
primitiveOrItemType = ((XSSimpleTypeDefinition*) baseType)->getPrimitiveType();
}
else // built-in
{
baseType = (XSSimpleTypeDefinition*) xsModel->getTypeDefinition
(
SchemaSymbols::fgDT_ANYSIMPLETYPE
, SchemaSymbols::fgURI_SCHEMAFORSCHEMA
);
primitiveTypeSelf = true;
}
}
else
{
baseType = xsModel->getTypeDefinition(SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
}
xsObj = new (fMemoryManager) XSSimpleTypeDefinition
(
validator
, typeVariety
, baseType
, primitiveOrItemType
, memberTypes
, getAnnotationFromModel(xsModel, validator)
, xsModel
, fMemoryManager
);
putObjectInMap(validator, xsObj);
if (primitiveTypeSelf)
xsObj->setPrimitiveType(xsObj);
//.........这里部分代码省略.........