int DateUtils::asInt(MAPM num) { if(num < INT_MIN || num > INT_MAX) { XQThrow2(XPath2TypeCastException, X("DateUtils::asInt"), X("Invalid representation of an int [err:FORG0001]")); } else { return (int)num.toDouble(); } }
/* returns true if the two objects have the same boolean value * false otherwise */ bool ATBooleanOrDerivedImpl::equals(const AnyAtomicType::Ptr &target, const DynamicContext* context) const { if(this->getPrimitiveTypeIndex() != target->getPrimitiveTypeIndex()) { XQThrow2(IllegalArgumentException,X("ATBooleanOrDerivedImpl::equals"), X("Equality operator for given types not supported [err:XPTY0004]")); } return compare((const ATBooleanOrDerived*)target.get(), context) == 0; }
AnyAtomicType::Ptr AnyAtomicType::castAsNoCheck(AtomicObjectType targetIndex, const XMLCh* targetURI, const XMLCh* targetType, const DynamicContext* context) const { try { return castAsInternal(targetIndex, targetURI, targetType, context); } catch (TypeNotFoundException &e) { XQThrow2(XPath2TypeCastException, X("AnyAtomicType::castAs"), e.getError()); } catch (InvalidLexicalSpaceException &e) { if(getPrimitiveTypeIndex() == UNTYPED_ATOMIC || getPrimitiveTypeIndex() == ANY_SIMPLE_TYPE || getPrimitiveTypeIndex() == STRING) { XQThrow2(XPath2TypeCastException, X("AnyAtomicType::castAs"), X("Invalid lexical value [err:FORG0001]")); } else if(getPrimitiveTypeIndex() == targetIndex) { XQThrow2(XPath2TypeCastException, X("AnyAtomicType::castAs"), X("Value does not conform to facets [err:FORG0001]")); } else { XQThrow2(XPath2TypeCastException, X("AnyAtomicType::castAs"), e.getError()); // should never be here, in theory } } catch (NamespaceLookupException &e) { XQThrow2(XPath2TypeCastException, X("AnyAtomicType::castAs"), e.getError()); } }
/** Returns the arithmetic product of its operands as a Numeric */ Numeric::Ptr ATDecimalOrDerivedImpl::mod(const Numeric::Ptr &other, const DynamicContext* context) const { if(this->isOfType(other->getTypeURI(), other->getTypeName(), context)) { // if both are of the same type exactly, we can perform the modulo const ATDecimalOrDerivedImpl* otherImpl = (ATDecimalOrDerivedImpl*)(const Numeric*)other; if(otherImpl->isZero()) { XQThrow2(::IllegalArgumentException, X("ATDecimalOrDerivedImpl::mod"), X("Division by zero [err:FOAR0001]")); } MAPM result = _decimal; MAPM r; r = result.integer_divide(otherImpl->_decimal); result -= r * otherImpl->_decimal; // if integer, return xs:integer, otherwise xs:decimal if(_isInteger) { return context->getItemFactory()->createInteger(result, context); } return context->getItemFactory()->createDecimal(result, context); } else if(this->getPrimitiveTypeIndex() != other->getPrimitiveTypeIndex()) { // if other is not a decimal, then we need to promote this to a float or double return ((const Numeric::Ptr )this->castAs(other->getPrimitiveTypeIndex(), context))->mod(other, context); } else if (this->isInstanceOfType(other->getTypeURI(), other->getTypeName(), context)) { // here we know we have two decimals, and this is 'lower' in the hierarchy than other // so cast this to other's type return ((const Numeric::Ptr )this->castAs(AnyAtomicType::DECIMAL, other->getTypeURI(), other->getTypeName(), context))->mod(other, context); } else if (other->isInstanceOfType(this->getTypeURI(), this->getTypeName(), context)) { // here we have two decimals, and this is 'higher' in the hierarchy than other // so cast other to this' type return this->mod((const Numeric::Ptr )other->castAs(AnyAtomicType::DECIMAL, this->getTypeURI(), this->getTypeName(), context), context); } else { // we have two separate branches. if either is instance of integer, cast it to integer, otherwise, cast to decimal // revisit: this is not the prettiest way to do it. You would want to go up the tree one by one instead of // jumping to integer and decimal ATDecimalOrDerived::Ptr first; ATDecimalOrDerived::Ptr second; if(this->_isInteger) { first = (const ATDecimalOrDerived::Ptr )this->castAs(AnyAtomicType::DECIMAL, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, SchemaSymbols::fgDT_INTEGER, context); } else { first = (const ATDecimalOrDerived::Ptr )this->castAs(AnyAtomicType::DECIMAL, context); } if(((ATDecimalOrDerivedImpl*)(const Numeric*)other)->_isInteger) { second = (const ATDecimalOrDerived::Ptr )other->castAs(AnyAtomicType::DECIMAL, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, SchemaSymbols::fgDT_INTEGER, context); } else { second = (const ATDecimalOrDerived::Ptr )other->castAs(AnyAtomicType::DECIMAL, context); } return first->mod(second, context); } }
const DatatypeFactory* DatatypeLookup::lookupDatatype(const XMLCh* typeURI, const XMLCh* typeName, bool &isPrimitive) const { const DatatypeFactory* pFactory=fDatatypeTable.get((void*)typeName); // in case we're lucky and we were given a primitive type if (pFactory) { if(XPath2Utils::equals(typeURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA)) { isPrimitive = true; return pFactory; } } isPrimitive = false; const DatatypeValidator* validator = fDocumentCache->getDatatypeValidator(typeURI, typeName); const DatatypeValidator* previousValidator = 0; while(validator) { const DatatypeValidator* tempVal = validator->getBaseValidator(); if(!tempVal) break; previousValidator = validator; validator = tempVal; } if(validator) { pFactory = fDatatypeTable.get((void*)validator->getTypeLocalName()); if(pFactory) { if(pFactory->getPrimitiveTypeIndex() == AnyAtomicType::DURATION && previousValidator != 0) { // Find a more specific type for duration, if possible const DatatypeFactory *tmp = fDatatypeTable.get((void*)previousValidator->getTypeLocalName()); if(tmp) pFactory = tmp; } return pFactory; } } XMLBuffer buf(1023, fMemMgr); buf.append(X("Type ")); buf.append(typeURI); buf.append(chColon); buf.append(typeName); buf.append(X(" not found [err:XPST0051]")); XQThrow2(TypeNotFoundException, X("DatatypeLookup::lookupDatatype"), buf.getRawBuffer()); }
ATBooleanOrDerivedImpl:: ATBooleanOrDerivedImpl(const XMLCh* typeURI, const XMLCh* typeName, const XMLCh* value, const StaticContext* context): _typeName(typeName), _typeURI(typeURI) { // canonical values static const XMLCh zero[] = {XERCES_CPP_NAMESPACE_QUALIFIER chDigit_0, XERCES_CPP_NAMESPACE_QUALIFIER chNull }; static const XMLCh one[] = {XERCES_CPP_NAMESPACE_QUALIFIER chDigit_1, XERCES_CPP_NAMESPACE_QUALIFIER chNull }; if( XPath2Utils::equals(value, zero) || XPath2Utils::equals(value, XERCES_CPP_NAMESPACE_QUALIFIER SchemaSymbols::fgATTVAL_FALSE)) { _value = false; } else if(XPath2Utils::equals(value, one) || XPath2Utils::equals(value, XERCES_CPP_NAMESPACE_QUALIFIER SchemaSymbols::fgATTVAL_TRUE)) { _value = true; } else { XQThrow2(XPath2TypeCastException,X("ATBooleanOrDerivedImpl::ATBooleanOrDerivedImpl"), X("Invalid representation of boolean [err:FORG0001]")); } }
ASTNode *XQLiteral::create(const Item::Ptr &item, DynamicContext *context, XPath2MemoryManager* memMgr, const LocationInfo *location) { if(item->isAtomicValue()) { ASTNode *result = 0; const AnyAtomicType *atom = (const AnyAtomicType*)item.get(); switch(atom->getPrimitiveTypeIndex()) { case AnyAtomicType::QNAME: { const ATQNameOrDerived *qname = (const ATQNameOrDerived*)atom; result = new (memMgr) XQQNameLiteral(atom->getTypeURI(), atom->getTypeName(), qname->getURI(), qname->getPrefix(), qname->getName(), memMgr); break; } case AnyAtomicType::DECIMAL: case AnyAtomicType::DOUBLE: case AnyAtomicType::FLOAT: { const Numeric *number = (const Numeric*)atom; if(number->getState() == Numeric::NUM || (number->getState() == Numeric::NEG_NUM && !number->isZero())) { result = new (memMgr) XQNumericLiteral(number->getTypeURI(), number->getTypeName(), number->asMAPM(), number->getPrimitiveTypeIndex(), memMgr); break; } // Fall through } default: result = new (memMgr) XQLiteral(atom->getTypeURI(), atom->getTypeName(), atom->asString(context), atom->getPrimitiveTypeIndex(), memMgr); break; } result->setLocationInfo(location); return result; } else { XQThrow2(::IllegalArgumentException, X("XQLiteral::create"), X("Cannot create an ASTNode literal for a non atomic item")); } }
AnyAtomicType::Ptr AnyAtomicType::castAs(AtomicObjectType targetIndex, const XMLCh* targetTypeURI, const XMLCh* targetTypeName, const DynamicContext* context) const { if(!castIsSupported(targetIndex, context)) { if(targetTypeName == 0) { context->getItemFactory()->getPrimitiveTypeName(targetIndex, targetTypeURI, targetTypeName); } XMLBuffer buffer(1023, context->getMemoryManager()); buffer.set(X("Casting from {")); buffer.append(getTypeURI()); buffer.append(X("}")); buffer.append(getTypeName()); buffer.append(X(" to {")); buffer.append(targetTypeURI); buffer.append(X("}")); buffer.append(targetTypeName); buffer.append(X(" is not supported [err:XPTY0004]")); XQThrow2(XPath2TypeCastException, X("AnyAtomicType::castAs"), buffer.getRawBuffer()); } return castAsNoCheck(targetIndex, targetTypeURI, targetTypeName, context); }
MAPM ATDecimalOrDerivedImpl::parseDecimal(const XMLCh* const value) { if(value == NULL) { XQThrow2(XPath2TypeCastException,X("ATDecimalOrDerivedImpl::setDecimal"), X("Invalid representation of decimal [err:FORG0001]")); } unsigned int length = XPath2Utils::uintStrlen(value) + 1; AutoDeleteArray<char> buffer(new char[length]); bool gotPoint = false; bool gotSign = false; bool gotDigit = false; bool stop = false; bool munchWS = true; const XMLCh *src = value; char *dest = buffer; XMLCh tmpChar; while(!stop && *src != 0) { tmpChar = *src++; switch(tmpChar) {/*{{{*/ case L'+': { *dest++ = '+'; if(gotSign) { stop = true; } else { gotSign = true; } break; } case L'-': { *dest++ = '-'; if(gotSign) { stop = true; } else { gotSign = true; } break; } //This is '.' case 0x002e: { *dest++ = '.'; if(gotPoint) { stop = true; } else { gotPoint = true; } break; } /* All the numerals defined by XML standard */ case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034: case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: { gotDigit = true; *dest++ = (char)(tmpChar - 0x0030) + '0'; break; } // whitespace at start or end of string... case 0x0020: case 0x0009: case 0x000d: case 0x000a: { bool endOfWS = false; while(!endOfWS && *src != 0) { tmpChar = *src++; switch(tmpChar) { case 0x0020: case 0x0009: case 0x000d: case 0x000a: { break; } default: { endOfWS = true; --src; if(munchWS) { //end of leading whitespace munchWS = false; } else { //trailing whitespace is followed by other characters - so return NaN. stop = true; } } }//switch }//while break; } default: stop = true; break; }//switch /*}}}*/ }//while if(!gotDigit || stop) { XQThrow2(XPath2TypeCastException,X("ATDecimalOrDerivedImpl::setDecimal"), X("Invalid representation of decimal [err:FORG0001]")); } *dest++ = 0; // Null terminate return (char*)buffer; }
/* parse the gMonth */ void ATGMonthOrDerivedImpl::setGMonth(const XMLCh* const value) { unsigned int length = XPath2Utils::uintStrlen(value); if(value == NULL) { XQThrow2(XPath2TypeCastException,X("XSGMonthImpl::setGMonth"), X("Invalid representation of gMonth [err:FORG0001]")); } // State variables etc. bool gotDigit = false; unsigned int pos = 0; long int tmpnum = 0; unsigned int numDigit = 0; // defaulting values MAPM MM = 0; _hasTimezone = false; bool zonepos = false; int zonehh = 0; int zonemm = 0; int state = 0 ; // 0 = year / 1 = month / 2 = day / 3 = hour // 4 = minutes / 5 = sec / 6 = timezonehour / 7 = timezonemin XMLCh tmpChar; bool wrongformat = false; if ( length < 4 || value[0] != L'-' || value[1] != L'-' ) { wrongformat = true; }else{ pos = 2; state = 1; } while ( ! wrongformat && pos < length) { tmpChar = value[pos]; pos++; switch(tmpChar) { case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034: case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: { tmpnum *= 10; tmpnum += static_cast<int>(tmpChar - 0x0030); gotDigit = true; numDigit ++; break; } case L'-' : { if ( gotDigit && state == 1 && numDigit == 2) { MM = tmpnum; tmpnum = 0; gotDigit = false; state = 6; numDigit = 0; _hasTimezone = true; zonepos = false; } else { wrongformat = true; } break; } case L'+' : { if ( gotDigit && state == 1 && numDigit == 2) { MM = tmpnum; tmpnum = 0; gotDigit = false; state = 6; numDigit = 0; _hasTimezone = true; zonepos = true; } else { wrongformat = true; } break; } case L':' : { if (gotDigit && state == 6 && numDigit == 2) { zonehh = tmpnum; tmpnum = 0; gotDigit = false; state ++; numDigit = 0; state = 7; }else { wrongformat = true; } break; } case L'Z' : { if ( gotDigit && state == 1 && numDigit == 2) { state = 8; // final state MM = tmpnum; _hasTimezone = true; gotDigit = false; tmpnum = 0; numDigit = 0; } else { wrongformat = true; } break; } default: wrongformat = true; } } if (gotDigit) { if ( state == 1 && numDigit == 2) MM = tmpnum; else if( state == 7 && numDigit == 2) zonemm = tmpnum; else wrongformat = true; } // check time format if ( MM > 12 || zonehh > 24 || zonemm > 60 ) { wrongformat = true; } if ( wrongformat) { XQThrow2(XPath2TypeCastException,X("ATGMonthOrDerivedImpl::setGMonth"), X("Invalid representation of gMonth [err:FORG0001]")); } _gMonth = MM; timezone_ = new Timezone(Timezone::convert(zonepos, zonehh, zonemm)); }
/* parse the gYear */ void ATGYearOrDerivedImpl::setGYear(const XMLCh* const value) { unsigned int length = XPath2Utils::uintStrlen(value); if(value == NULL) { XQThrow2(XPath2TypeCastException,X("ATGYearOrDerivedImpl::setGYear"), X("Invalid representation of gYear [err:FORG0001]")); } // State variables etc. bool gotDigit = false; unsigned int pos = 0; long int tmpnum = 0; unsigned int numDigit = 0; bool negative = false; // defaulting values MAPM YY = 0; _hasTimezone = false; bool zonepos = false; int zonehh = 0; int zonemm = 0; int state = 0 ; // 0 = year / 1 = month / 2 = day / 3 = hour // 4 = minutes / 5 = sec / 6 = timezonehour / 7 = timezonemin XMLCh tmpChar; bool wrongformat = false; if ( length > 0 && value[0] == L'-' ) { negative = true; pos = 1; }else{ pos = 0; } while ( ! wrongformat && pos < length) { tmpChar = value[pos]; pos++; switch(tmpChar) { case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034: case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: { numDigit ++; tmpnum *= 10; tmpnum += static_cast<int>(tmpChar - 0x0030); gotDigit = true; break; } case L'-' : { if ( gotDigit && state == 0 && numDigit >= 4) { YY = tmpnum; tmpnum = 0; gotDigit = false; _hasTimezone = true; zonepos = false; state = 6; numDigit = 0; } else { wrongformat = true; } break; } case L'+' : { if ( gotDigit && state == 0 && numDigit >= 4) { YY = tmpnum; state = 6; gotDigit = false; _hasTimezone = true; zonepos = true; tmpnum = 0; numDigit = 0; } else { wrongformat = true; } break; } case L':' : { if (gotDigit && state == 6 && numDigit == 2 ) { zonehh = tmpnum; tmpnum = 0; gotDigit = false; numDigit = 0; state = 7; }else { wrongformat = true; } break; } case L'Z' : { if (gotDigit && state == 0 && numDigit >= 4) { YY = tmpnum; state = 8; // final state _hasTimezone = true; gotDigit = false; tmpnum = 0; numDigit = 0; } else { wrongformat = true; } break; } default: wrongformat = true; } } if (gotDigit) { if ( gotDigit && state == 7 && numDigit == 2) { zonemm = tmpnum; }else if ( gotDigit && state == 0 && numDigit >= 4 ) { YY += tmpnum; }else { wrongformat = true; } } if (negative) { YY = YY * -1; } if (YY == 0) { wrongformat = true; } // check time format if (wrongformat) { XQThrow2(XPath2TypeCastException,X("ATGYearOrDerivedImpl::setGYear"), X("Invalid representation of gYear [err:FORG0001]")); } timezone_ = new Timezone(Timezone::convert(zonepos, zonehh, zonemm)); _YY = YY; }
/* returns true if the two objects' URI are equal (string comparison) * false otherwise */ bool ATUntypedAtomicImpl::equals(const AnyAtomicType::Ptr &target, const DynamicContext* context) const { if(this->getPrimitiveTypeIndex() != target->getPrimitiveTypeIndex()) { XQThrow2(IllegalArgumentException,X("ATUntypedAtomicImpl::equals"), X("Equality operator for given types not supported [err:XPTY0004]")); } return XPath2Utils::equals(target->asString(context), _value); }
/* parse the gDay */ void ATGDayOrDerivedImpl::setGDay(const XMLCh* const value) { if(value == NULL) { XQThrow2(XPath2TypeCastException,X("ATGDayOrDerivedImpl::setGDay"), X("Invalid representation of gDay [err:FORG0001]")); } unsigned int length = XPath2Utils::uintStrlen(value); // State variables etc. bool gotDigit = false; unsigned int pos = 0; long int tmpnum = 0; // defaulting values MAPM DD = 0; _hasTimezone = false; bool zonepos = false; int zonehh = 0; int zonemm = 0; int state = 0 ; // 0 = year / 1 = month / 2 = day / 3 = hour // 4 = minutes / 5 = sec / 6 = timezonehour / 7 = timezonemin XMLCh tmpChar; bool wrongformat = false; if ( length < 5 || value[0] != L'-' || value[1] != L'-' || value[2] != L'-') { wrongformat = true; }else{ pos = 3; state = 1; } while ( ! wrongformat && pos < length) { tmpChar = value[pos]; pos++; switch(tmpChar) { case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034: case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: { tmpnum *= 10; tmpnum += static_cast<int>(tmpChar - 0x0030); gotDigit = true; break; } case L':' : { if (gotDigit && state == 6 ) { zonehh = tmpnum; tmpnum = 0; gotDigit = false; state ++; }else { wrongformat = true; } break; } case L'-' : { if ( gotDigit && state == 1 ) { DD = tmpnum; state = 6; gotDigit = false; _hasTimezone = true; zonepos = false; tmpnum = 0; } else { wrongformat = true; } break; } case L'+' : { if ( gotDigit && state == 1 ) { DD = tmpnum; state = 6; gotDigit = false; _hasTimezone = true; zonepos = true; tmpnum = 0; } else { wrongformat = true; } break; } case L'Z' : { if (gotDigit && state == 1 ) { DD = tmpnum; state = 8; // final state _hasTimezone = true; gotDigit = false; tmpnum = 0; } else { wrongformat = true; } break; } default: wrongformat = true; } } if (gotDigit) { if ( gotDigit && state == 7 ) { zonemm = tmpnum; }else if ( gotDigit && state == 1 ) { DD = tmpnum; }else { wrongformat = true; } } // check time format if ( DD > 31 || zonehh > 24 || zonemm > 60 ) { wrongformat = true; } if ( wrongformat) { XQThrow2(XPath2TypeCastException,X("ATGDayOrDerivedImpl::setGDay"), X("Invalid representation of gDay [err:FORG0001]")); } timezone_ = new Timezone(Timezone::convert(zonepos, zonehh, zonemm)); _gDay = DD; }
/*static*/ bool GreaterThan::greater_than(const AnyAtomicType::Ptr &atom1, const AnyAtomicType::Ptr &atom2, Collation* collation, DynamicContext* context, const LocationInfo *info) { try { // take care of Numeric types first if(atom1->isNumericValue()) { if(atom2->isNumericValue()) { return ((Numeric*)(const AnyAtomicType*)atom1)->greaterThan((const Numeric::Ptr )atom2, context); } else { XQThrow2(XPath2ErrorException,X("GreaterThan::greater_than"), X("An attempt to compare a numeric type to a non numeric type has occurred [err:XPTY0004]")); } } switch(atom1->getPrimitiveTypeIndex()) { case AnyAtomicType::BOOLEAN: { // op:boolean-greater-than(A, B) if(atom2->getPrimitiveTypeIndex() != AnyAtomicType::BOOLEAN) XQThrow2(XPath2ErrorException,X("GreaterThan::greater_than"), X("An attempt to compare a boolean type to a non boolean type has occurred [err:XPTY0004]")); return ((const ATBooleanOrDerived*)atom1.get())->compare((const ATBooleanOrDerived*)atom2.get(), context) > 0; } case AnyAtomicType::STRING: case AnyAtomicType::ANY_URI: { // use function compare if(atom2->getPrimitiveTypeIndex() != AnyAtomicType::STRING && atom2->getPrimitiveTypeIndex() != AnyAtomicType::ANY_URI) XQThrow2(XPath2ErrorException,X("GreaterThan::greater_than"), X("An attempt to compare a string type to a non string type has occurred [err:XPTY0004]")); // if the function returns 1, then atom1 is greater return collation->compare(atom1->asString(context),atom2->asString(context))>0; } case AnyAtomicType::DATE: { // op:date-greater-than(A, B) if(atom2->getPrimitiveTypeIndex() != AnyAtomicType::DATE) XQThrow2(XPath2ErrorException,X("GreaterThan::greater_than"), X("An attempt to compare a date type to a non date type has occurred [err:XPTY0004]")); return ((ATDateOrDerived*)atom1.get())->compare((const ATDateOrDerived::Ptr )atom2, context) > 0; } case AnyAtomicType::TIME: { // op:time-greater-than(A, B) if(atom2->getPrimitiveTypeIndex() != AnyAtomicType::TIME) XQThrow2(XPath2ErrorException,X("GreaterThan::greater_than"), X("An attempt to compare a time type to a non time type has occurred [err:XPTY0004]")); return ((ATTimeOrDerived*)atom1.get())->compare((const ATTimeOrDerived::Ptr )atom2, context) > 0; } case AnyAtomicType::DATE_TIME: { // op:datetime-greater-than(A, B) if(atom2->getPrimitiveTypeIndex() != AnyAtomicType::DATE_TIME) XQThrow2(XPath2ErrorException,X("GreaterThan::greater_than"), X("An attempt to compare a dateTime type to a non dateTime type has occurred [err:XPTY0004]")); return ((ATDateTimeOrDerived*)atom1.get())->compare((const ATDateTimeOrDerived::Ptr)atom2, context) > 0; } case AnyAtomicType::DAY_TIME_DURATION: { if(atom2->getPrimitiveTypeIndex() != AnyAtomicType::DAY_TIME_DURATION) XQThrow2(XPath2ErrorException,X("GreaterThan::greater_than"), X("An attempt to compare a duration type to a non duration type has occurred [err:XPTY0004]")); return ((const ATDurationOrDerived*)atom1.get())->compare((const ATDurationOrDerived*)atom2.get(), context) > 0; } case AnyAtomicType::YEAR_MONTH_DURATION: { if(atom2->getPrimitiveTypeIndex() != AnyAtomicType::YEAR_MONTH_DURATION) XQThrow2(XPath2ErrorException,X("GreaterThan::greater_than"), X("An attempt to compare a duration type to a non duration type has occurred [err:XPTY0004]")); return ((const ATDurationOrDerived*)atom1.get())->compare((const ATDurationOrDerived*)atom2.get(), context) > 0; } default: XQThrow2(XPath2ErrorException,X("GreaterThan::greater_than"), X("Unexpected data type in operator 'gt' [err:XPTY0004]")); } XQThrow2(FunctionException,X("GreaterThan::greater_than"), X("An equality operator is not defined for the provided arguments [err:XPTY0004]")); } catch(XQException &e) { if(e.getXQueryLine() == 0) e.setXQueryPosition(info); throw; } }