Esempio n. 1
0
inline bool SchemaInfo::circularImportExist(const unsigned int namespaceURI) {

    unsigned int importSize = fImportingInfoList->size();

    for (unsigned int i=0; i < importSize; i++) {
        if (fImportingInfoList->elementAt(i)->getTargetNSURI() == (int) namespaceURI) {
            return true;
        }
    }

    return false;
}
Esempio n. 2
0
inline SchemaInfo* SchemaInfo::getImportInfo(const unsigned int namespaceURI) const {

    unsigned int importSize = (fImportedInfoList) ? fImportedInfoList->size() : 0;
    SchemaInfo* currInfo = 0;

    for (unsigned int i=0; i < importSize; i++) {

        currInfo = fImportedInfoList->elementAt(i);

        if (currInfo->getTargetNSURI() == (int) namespaceURI)
            break;
    }

    return currInfo;
}
Esempio n. 3
0
XMLCh* RegularExpression::replace(const XMLCh* const matchString,  
                                  const XMLCh* const replaceString,
                                  const int start, const int end)
{

  //check if matches zero length string - throw error if so
  if (matches(XMLUni::fgZeroLenString, fMemoryManager)){
		ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_RepPatMatchesZeroString, fMemoryManager);
  }
      
  RefVectorOf<Match> *subEx = new (fMemoryManager) RefVectorOf<Match>(10, true, fMemoryManager);
	  Janitor<RefVectorOf<Match> > janSubEx(subEx);

  //Call to tokenize with Match vector so that we keep track of the locations
  //of the subExpression within each of the matches
  RefArrayVectorOf<XMLCh>* tokenStack = tokenize(matchString, start, end, subEx);
	  Janitor<RefArrayVectorOf<XMLCh> > janTokStack(tokenStack);
    
  XMLBuffer result(1023, fMemoryManager);
  
  int numSubEx = 0;
  
  if (subEx && subEx->size() > 0)
    numSubEx = subEx->elementAt(0)->getNoGroups() - 1;
  
  int tokStackSize = tokenStack->size();
  const XMLCh* curRepString = XMLString::replicate(replaceString, fMemoryManager);
    
  for (int i = 0; i < tokStackSize; i++){
      
    result.append(tokenStack->elementAt(i));
  
    if (i != tokStackSize - 1) {
       
      //if there are subExpressions, then determine the string we want to 
      //substitute in.
        if (numSubEx != 0) {
            fMemoryManager->deallocate((XMLCh*)curRepString);
            curRepString = subInExp(replaceString, matchString, subEx->elementAt(i));     
        }
      result.append(curRepString);
    }
  }  
    
  fMemoryManager->deallocate((XMLCh*)curRepString);
  return XMLString::replicate(result.getRawBuffer(), fMemoryManager); 
    
}
int UnionDatatypeValidator::compare(const XMLCh* const lValue
                                  , const XMLCh* const rValue
                                  , MemoryManager* const manager)
{
    RefVectorOf<DatatypeValidator>* memberDTV = getMemberTypeValidators();
    unsigned int memberTypeNumber = memberDTV->size();

    for ( unsigned int memberIndex = 0; memberIndex < memberTypeNumber; ++memberIndex)
    {
        if (memberDTV->elementAt(memberIndex)->compare(lValue, rValue, manager) ==0)
            return  0;
    }

    //REVISIT: what does it mean for UNION1 to be <less than> or <greater than> UNION2 ?
    // As long as -1 or +1 indicates an unequality, return either of them is ok.
    return -1;
}
Esempio n. 5
0
void processDatatypeValidator( const DatatypeValidator* dtValidator, bool margin )
{
    if( !dtValidator )
    {
        return;
    }

    if( margin )
    {
        XERCES_STD_QUALIFIER cout << "\t";
    }

    XERCES_STD_QUALIFIER cout << "Base Datatype:\t\t";
    switch( dtValidator->getType() )
    {
    case DatatypeValidator::String:         XERCES_STD_QUALIFIER cout << "string";      break;
    case DatatypeValidator::AnyURI:         XERCES_STD_QUALIFIER cout << "AnyURI";      break;
    case DatatypeValidator::QName:          XERCES_STD_QUALIFIER cout << "QName";       break;
    case DatatypeValidator::Name:           XERCES_STD_QUALIFIER cout << "Name";        break;
    case DatatypeValidator::NCName:         XERCES_STD_QUALIFIER cout << "NCName";      break;
    case DatatypeValidator::Boolean:        XERCES_STD_QUALIFIER cout << "Boolean";     break;
    case DatatypeValidator::Float:          XERCES_STD_QUALIFIER cout << "Float";       break;
    case DatatypeValidator::Double:         XERCES_STD_QUALIFIER cout << "Double";      break;
    case DatatypeValidator::Decimal:        XERCES_STD_QUALIFIER cout << "Decimal";     break;
    case DatatypeValidator::HexBinary:      XERCES_STD_QUALIFIER cout << "HexBinary";   break;
    case DatatypeValidator::Base64Binary:   XERCES_STD_QUALIFIER cout << "Base64Binary";break;
    case DatatypeValidator::Duration:       XERCES_STD_QUALIFIER cout << "Duration";    break;
    case DatatypeValidator::DateTime:       XERCES_STD_QUALIFIER cout << "DateTime";    break;
    case DatatypeValidator::Date:           XERCES_STD_QUALIFIER cout << "Date";        break;
    case DatatypeValidator::Time:           XERCES_STD_QUALIFIER cout << "Time";        break;
    case DatatypeValidator::MonthDay:       XERCES_STD_QUALIFIER cout << "MonthDay";    break;
    case DatatypeValidator::YearMonth:      XERCES_STD_QUALIFIER cout << "YearMonth";   break;
    case DatatypeValidator::Year:           XERCES_STD_QUALIFIER cout << "Year";        break;
    case DatatypeValidator::Month:          XERCES_STD_QUALIFIER cout << "Month";       break;
    case DatatypeValidator::Day:            XERCES_STD_QUALIFIER cout << "Day";         break;
    case DatatypeValidator::ID:             XERCES_STD_QUALIFIER cout << "ID";          break;
    case DatatypeValidator::IDREF:          XERCES_STD_QUALIFIER cout << "IDREF";       break;
    case DatatypeValidator::ENTITY:         XERCES_STD_QUALIFIER cout << "ENTITY";      break;
    case DatatypeValidator::NOTATION:       XERCES_STD_QUALIFIER cout << "NOTATION";    break;
    case DatatypeValidator::List:           XERCES_STD_QUALIFIER cout << "List";        break;
    case DatatypeValidator::Union:          XERCES_STD_QUALIFIER cout << "Union";       break;
    case DatatypeValidator::AnySimpleType:  XERCES_STD_QUALIFIER cout << "AnySimpleType"; break;
    case DatatypeValidator::UnKnown:        XERCES_STD_QUALIFIER cout << "UNKNOWN";     break;
    }

    XERCES_STD_QUALIFIER cout << "\n";

    // Facets
	RefHashTableOf<KVStringPair>* facets = dtValidator->getFacets();
    if( facets && facets->getCount()>0)
    {
        XMLSize_t i;
        // Element's properties
        XERCES_STD_QUALIFIER cout << "Facets:\t\t\n";
        // use a list to print them sorted, or the list could be different on 64-bit machines
        RefVectorOf<XMLCh> sortedList(facets->getCount(), false);
        RefHashTableOfEnumerator<KVStringPair> enumFacets(facets);
        while( enumFacets.hasMoreElements() )
        {
            const KVStringPair& curPair = enumFacets.nextElement();
            const XMLCh* key=curPair.getKey();
            XMLSize_t len=sortedList.size();
            for(i=0;i<len;i++)
                if(XMLString::compareString(key, sortedList.elementAt(i))<0)
                {
                    sortedList.insertElementAt((XMLCh*)key,i);
                    break;
                }
            if(i==len)
                sortedList.addElement((XMLCh*)key);
        }

        XMLSize_t len=sortedList.size();
        for(i=0;i<len;i++)
        {
            const XMLCh* key = sortedList.elementAt(i);
            XERCES_STD_QUALIFIER cout << "\t" << StrX( key )    << "="
                         << StrX( facets->get(key)->getValue() )  << "\n";
        }
    }

	// Enumerations
	RefVectorOf<XMLCh>* enums = (RefVectorOf<XMLCh>*) dtValidator->getEnumString();
	if (enums)
	{
		XERCES_STD_QUALIFIER cout << "Enumeration:\t\t\n";

		XMLSize_t enumLength = enums->size();
		for ( XMLSize_t i = 0; i < enumLength; i++)
        {
            XERCES_STD_QUALIFIER cout << "\t" << StrX( enums->elementAt(i)) << "\n";
        }

	}
}
//
// 1) the bottom level UnionDTV would check against
//        pattern and enumeration as well
// 2) each UnionDTV(s) above the bottom level UnionDTV and
//        below the native UnionDTV (the top level DTV)
//        would check against pattern only.
// 3) the natvie Union DTV (the top level DTV) would invoke
//        memberTypeValidator to validate
//
void UnionDatatypeValidator::checkContent(const XMLCh*             const content
                                        ,       ValidationContext* const context
                                        ,       bool                     asBase
                                        ,       MemoryManager*     const manager)
{

    DatatypeValidator* bv = getBaseValidator();
    if (bv)
        ((UnionDatatypeValidator*)bv)->checkContent(content, context, true, manager);
    else
    {   // 3) native union type
        // check content against each member type validator in Union
        // report an error only in case content is not valid against all member datatypes.
        //
        bool memTypeValid = false;
        for ( unsigned int i = 0; i < fMemberTypeValidators->size(); ++i )
        {
            if ( memTypeValid )
                break;

            try
            {
                fMemberTypeValidators->elementAt(i)->validate(content, context, manager);
                memTypeValid = true;
                
                //set the validator of the type actually used to validate the content
                DatatypeValidator *dtv = fMemberTypeValidators->elementAt(i);
                fValidatedDatatype = dtv;
                // context will be null during schema construction
                if(context)
                    context->setValidatingMemberType(dtv);
            }
            catch (XMLException&)
            {
                //absorbed
            }
        } // for

        if ( !memTypeValid )
        {
            ThrowXMLwithMemMgr1(InvalidDatatypeValueException
                    , XMLExcepts::VALUE_no_match_memberType
                    , content
                    , manager);
            //( "Content '"+content+"' does not match any union types" );
        }
    }

    // 1) and 2). we check pattern first
    if ( (getFacetsDefined() & DatatypeValidator::FACET_PATTERN ) != 0 )
    {
        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;

    if ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) != 0 &&
        (getEnumeration() != 0))
    {

        // If the content match (compare equal) any enumeration with
        // any of the member types, it is considerd valid.
        //
        RefVectorOf<DatatypeValidator>* memberDTV = getMemberTypeValidators();
        RefArrayVectorOf<XMLCh>* tmpEnum = getEnumeration();
        unsigned int memberTypeNumber = memberDTV->size();
        unsigned int enumLength = tmpEnum->size();

        for ( unsigned int memberIndex = 0; memberIndex < memberTypeNumber; ++memberIndex)
        {
            for ( unsigned int enumIndex = 0; enumIndex < enumLength; ++enumIndex)
            {
                try
                {
                    if (memberDTV->elementAt(memberIndex)->compare(content, tmpEnum->elementAt(enumIndex), manager) == 0)
                        return;
                }
                catch (XMLException&)
                {
                    //absorbed
                }
            } // for enumIndex
        } // for memberIndex

        ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager);

    } // enumeration

}
Esempio n. 7
0
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);

        // process facets
        processFacets(validator, xsModel, xsObj);
    }

    return xsObj;
}
Esempio n. 8
0
void XercesXPath::parseExpression(XMLStringPool* const stringPool,
                                  NamespaceScope* const scopeContext) {

    unsigned int length = XMLString::stringLen(fExpression);

    if (!length) {
        return;
    }

    ValueVectorOf<int>                tokens(16, fMemoryManager);
    XPathScannerForSchema             scanner(stringPool);
    bool                              success = scanner.scanExpression(fExpression, 0, length, &tokens);
    bool                              firstTokenOfLocationPath=true;
    unsigned int                      tokenCount = tokens.size();
    RefVectorOf<XercesStep>*          stepsVector = new (fMemoryManager) RefVectorOf<XercesStep>(16, true, fMemoryManager);
    Janitor<RefVectorOf<XercesStep> > janSteps(stepsVector);

    if (tokenCount) {
        fLocationPaths = new (fMemoryManager) RefVectorOf<XercesLocationPath>(8, true, fMemoryManager);
    }

    for (unsigned int i = 0; i < tokenCount; i++) {

        int  aToken = tokens.elementAt(i);
        bool isNamespace=false;

        switch (aToken) {
        case  XercesXPath::EXPRTOKEN_OPERATOR_UNION:
            {
                if (i == 0) {
                    ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoUnionAtStart, fMemoryManager);
                }

                int stepsSize = stepsVector->size();

                if (stepsSize == 0) {
                    ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoMultipleUnion, fMemoryManager);
                }

                fLocationPaths->addElement(new (fMemoryManager) XercesLocationPath(stepsVector));
                janSteps.orphan();
                stepsVector = new (fMemoryManager) RefVectorOf<XercesStep>(16, true, fMemoryManager);
                janSteps.reset(stepsVector);
                firstTokenOfLocationPath = true;
            }
            break;
        case XercesXPath::EXPRTOKEN_AXISNAME_ATTRIBUTE:
            {
                // consume "::" token and drop through
                i++;
            }
        case XercesXPath::EXPRTOKEN_ATSIGN:
            {
                // consume QName token
                if (i == tokenCount - 1) {
                    ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_MissingAttr, fMemoryManager);
                }

                aToken = tokens.elementAt(++i);

                if (aToken != XercesXPath::EXPRTOKEN_NAMETEST_QNAME
                    && aToken!= XercesXPath::EXPRTOKEN_NAMETEST_ANY
                    && aToken!= XercesXPath::EXPRTOKEN_NAMETEST_NAMESPACE) {
                        ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_ExpectedToken1, fMemoryManager);
                }

                bool isNamespaceAtt=false;

                switch (aToken) {

                case XercesXPath::EXPRTOKEN_NAMETEST_ANY:
                    {
                        XercesNodeTest* nodeTest = new (fMemoryManager) XercesNodeTest(XercesNodeTest::WILDCARD, fMemoryManager);
                        XercesStep* step = new (fMemoryManager) XercesStep(XercesStep::ATTRIBUTE, nodeTest);
                        stepsVector->addElement(step);
                        break;
                    }
                case XercesXPath::EXPRTOKEN_NAMETEST_NAMESPACE:
                    {
                        isNamespaceAtt = true;
                    }
                case XercesXPath::EXPRTOKEN_NAMETEST_QNAME:
                    {
                        aToken = tokens.elementAt(++i);

                        const XMLCh* prefix = XMLUni::fgZeroLenString;
                        unsigned int uri = fEmptyNamespaceId;

                        if (scopeContext && aToken != -1) {

                            prefix = stringPool->getValueForId(aToken);
                            uri = scopeContext->getNamespaceForPrefix(prefix);
                        }

                        if (aToken != -1 && scopeContext && uri == fEmptyNamespaceId) {
                            ThrowXMLwithMemMgr1(XPathException, XMLExcepts::XPath_PrefixNoURI, prefix, fMemoryManager);
                        }

                        if (isNamespaceAtt) {

                            // build step
                            XercesNodeTest* nodeTest = new (fMemoryManager) XercesNodeTest(prefix, uri, fMemoryManager);
                            XercesStep* step = new (fMemoryManager) XercesStep(XercesStep::ATTRIBUTE, nodeTest);
                            stepsVector->addElement(step);
                            break;
                        }

                        aToken = tokens.elementAt(++i);

                        const XMLCh* localPart = stringPool->getValueForId(aToken);
                        QName aQName(prefix, localPart, uri, fMemoryManager);

                        // build step
                        XercesNodeTest* nodeTest = new (fMemoryManager) XercesNodeTest(&aQName);
                        XercesStep* step = new (fMemoryManager) XercesStep(XercesStep::ATTRIBUTE, nodeTest);
                        stepsVector->addElement(step);
                        break;
                    }
				}

                firstTokenOfLocationPath=false;
                break;
            }
        case XercesXPath::EXPRTOKEN_DOUBLE_COLON:
            {
                // should never have a bare double colon
                ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoDoubleColon, fMemoryManager);
            }
        case XercesXPath::EXPRTOKEN_AXISNAME_CHILD:
            {
                // consume "::" token and drop through
                i++;

                if (i == tokenCount - 1) {
                    ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_ExpectedStep1, fMemoryManager);
                }

                firstTokenOfLocationPath=false;
                break;
            }
        case XercesXPath::EXPRTOKEN_NAMETEST_ANY:
            {
                XercesNodeTest* nodeTest = new (fMemoryManager) XercesNodeTest(XercesNodeTest::WILDCARD, fMemoryManager);
                XercesStep* step = new (fMemoryManager) XercesStep(XercesStep::CHILD, nodeTest);
                stepsVector->addElement(step);
                firstTokenOfLocationPath = false;
                break;
            }
        case XercesXPath::EXPRTOKEN_NAMETEST_NAMESPACE:
            {
                isNamespace=true;
            }
        case XercesXPath::EXPRTOKEN_NAMETEST_QNAME:
            {
                // consume QName token
                aToken = tokens.elementAt(++i);

                const XMLCh* prefix = XMLUni::fgZeroLenString;
                unsigned int uri = fEmptyNamespaceId;

                if (scopeContext && aToken != -1) {

                    prefix = stringPool->getValueForId(aToken);
                    uri = scopeContext->getNamespaceForPrefix(prefix);
                }

                if (aToken != -1 && scopeContext && uri == fEmptyNamespaceId) {
                    ThrowXMLwithMemMgr1(XPathException, XMLExcepts::XPath_PrefixNoURI, prefix, fMemoryManager);
                }

                if (isNamespace) {

                    // build step
                    XercesNodeTest* nodeTest = new (fMemoryManager) XercesNodeTest(prefix, uri, fMemoryManager);
                    XercesStep* step = new (fMemoryManager) XercesStep(XercesStep::CHILD, nodeTest);
                    stepsVector->addElement(step);
                    break;
                }

                aToken = tokens.elementAt(++i);
                const XMLCh* localPart = stringPool->getValueForId(aToken);
                QName aQName(prefix, localPart, uri, fMemoryManager);

                // build step
                XercesNodeTest* nodeTest = new (fMemoryManager) XercesNodeTest(&aQName);
                XercesStep* step = new (fMemoryManager) XercesStep(XercesStep::CHILD, nodeTest);
                stepsVector->addElement(step);
                firstTokenOfLocationPath = false;
                break;
            }
        case XercesXPath::EXPRTOKEN_PERIOD:
            {
                // build step
                XercesNodeTest* nodeTest = new (fMemoryManager) XercesNodeTest(XercesNodeTest::NODE, fMemoryManager);
                XercesStep* step = new (fMemoryManager) XercesStep(XercesStep::SELF, nodeTest);
                stepsVector->addElement(step);

                if (firstTokenOfLocationPath && i+1 < tokenCount) {

                    aToken = tokens.elementAt(i+1);

                    if (aToken == XercesXPath::EXPRTOKEN_OPERATOR_DOUBLE_SLASH){

                        if (++i == tokenCount - 1) {
                            ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_ExpectedStep2, fMemoryManager);
                        }

                        if (i+1 < tokenCount)	{

                            aToken = tokens.elementAt(i+1);

                            if (aToken == XercesXPath::EXPRTOKEN_OPERATOR_SLASH) {
                                ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoForwardSlash, fMemoryManager);
                            }
                        }
                        // build step
                        nodeTest = new (fMemoryManager) XercesNodeTest(XercesNodeTest::NODE, fMemoryManager);
                        step = new (fMemoryManager) XercesStep(XercesStep::DESCENDANT, nodeTest);
                        stepsVector->addElement(step);
                    }
                }
                firstTokenOfLocationPath=false;
                break;
            }
        case XercesXPath::EXPRTOKEN_OPERATOR_DOUBLE_SLASH:
            {
                ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoDoubleForwardSlash, fMemoryManager);
            }
        case XercesXPath::EXPRTOKEN_OPERATOR_SLASH:
            {
                if (i == 0) {
                    ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoForwardSlashAtStart, fMemoryManager);
                }

                // keep on truckin'
                if (firstTokenOfLocationPath) {
                    ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoSelectionOfRoot, fMemoryManager);
                }

                if (i == tokenCount - 1) {
                    ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_ExpectedStep3, fMemoryManager);
                }

                firstTokenOfLocationPath=false;
                break;
            }
        default:
            firstTokenOfLocationPath=false;
        }
    }

    int stepsSize = stepsVector->size();

    if (stepsSize == 0) {
        if (!fLocationPaths || fLocationPaths->size() == 0) {
            ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_EmptyExpr, fMemoryManager);
        }
        else {
            ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoUnionAtEnd, fMemoryManager);
        }
    }

    fLocationPaths->addElement(new (fMemoryManager) XercesLocationPath(stepsVector));
    janSteps.orphan();
}
Esempio n. 9
0
void processDatatypeValidator( const DatatypeValidator* dtValidator, bool margin )
{
    if( !dtValidator )
    {
        return;
    }

    if( margin )
    {
        XERCES_STD_QUALIFIER cout << "\t";
    }

    XERCES_STD_QUALIFIER cout << "Base Datatype:\t\t";
    switch( dtValidator->getType() )
    {
    case DatatypeValidator::String:         XERCES_STD_QUALIFIER cout << "string";      break;
    case DatatypeValidator::AnyURI:         XERCES_STD_QUALIFIER cout << "AnyURI";      break;
    case DatatypeValidator::QName:          XERCES_STD_QUALIFIER cout << "QName";       break;
	case DatatypeValidator::Name:           XERCES_STD_QUALIFIER cout << "Name";        break;
	case DatatypeValidator::NCName:         XERCES_STD_QUALIFIER cout << "NCName";      break;
    case DatatypeValidator::Boolean:        XERCES_STD_QUALIFIER cout << "Boolean";     break;
    case DatatypeValidator::Float:          XERCES_STD_QUALIFIER cout << "Float";       break;
    case DatatypeValidator::Double:         XERCES_STD_QUALIFIER cout << "Double";      break;
    case DatatypeValidator::Decimal:        XERCES_STD_QUALIFIER cout << "Decimal";     break;
    case DatatypeValidator::HexBinary:      XERCES_STD_QUALIFIER cout << "HexBinary";   break;
    case DatatypeValidator::Base64Binary:   XERCES_STD_QUALIFIER cout << "Base64Binary";break;
    case DatatypeValidator::Duration:       XERCES_STD_QUALIFIER cout << "Duration";    break;
    case DatatypeValidator::DateTime:       XERCES_STD_QUALIFIER cout << "DateTime";    break;
    case DatatypeValidator::Date:           XERCES_STD_QUALIFIER cout << "Date";        break;
    case DatatypeValidator::Time:           XERCES_STD_QUALIFIER cout << "Time";        break;
    case DatatypeValidator::MonthDay:       XERCES_STD_QUALIFIER cout << "MonthDay";    break;
    case DatatypeValidator::YearMonth:      XERCES_STD_QUALIFIER cout << "YearMonth";   break;
    case DatatypeValidator::Year:           XERCES_STD_QUALIFIER cout << "Year";        break;
    case DatatypeValidator::Month:          XERCES_STD_QUALIFIER cout << "Month";       break;
    case DatatypeValidator::Day:            XERCES_STD_QUALIFIER cout << "Day";         break;
    case DatatypeValidator::ID:             XERCES_STD_QUALIFIER cout << "ID";          break;
    case DatatypeValidator::IDREF:          XERCES_STD_QUALIFIER cout << "IDREF";       break;
    case DatatypeValidator::ENTITY:         XERCES_STD_QUALIFIER cout << "ENTITY";      break;
    case DatatypeValidator::NOTATION:       XERCES_STD_QUALIFIER cout << "NOTATION";    break;
    case DatatypeValidator::List:           XERCES_STD_QUALIFIER cout << "List";        break;
    case DatatypeValidator::Union:          XERCES_STD_QUALIFIER cout << "Union";       break;
    case DatatypeValidator::AnySimpleType:  XERCES_STD_QUALIFIER cout << "AnySimpleType"; break;
    }

    XERCES_STD_QUALIFIER cout << "\n";

    // Facets
	RefHashTableOf<KVStringPair>* facets = dtValidator->getFacets();
    if( facets )
    {
        RefHashTableOfEnumerator<KVStringPair> enumFacets(facets);
        if( enumFacets.hasMoreElements() )
        {
            XERCES_STD_QUALIFIER cout << "Facets:\t\t\n";
        }

        while(enumFacets.hasMoreElements())
        {
            // Element's properties
            const KVStringPair& curPair = enumFacets.nextElement();
            XERCES_STD_QUALIFIER cout << "\t" << StrX( curPair.getKey() )    << "="
                         << StrX( curPair.getValue() )  << "\n";
        }
    }

	// Enumerations
	RefVectorOf<XMLCh>* enums = (RefVectorOf<XMLCh>*) dtValidator->getEnumString();
	if (enums)
	{
		XERCES_STD_QUALIFIER cout << "Enumeration:\t\t\n";

        int enumLength = enums->size();
        for ( int i = 0; i < enumLength; i++)
        {
            XERCES_STD_QUALIFIER cout << "\t" << StrX( enums->elementAt(i)) << "\n";
        }

	}
}