code: @Override
      public AtomicValue evaluate() throws TTXPathException {
  
          // defines if current item is castable to the target type, or not
          boolean isCastable;
  
          // atomic type must not be xs:anyAtomicType or xs:NOTATION
          if (mTargetType == Type.ANY_ATOMIC_TYPE || mTargetType == Type.NOTATION) {
              throw new XPathError(ErrorType.XPST0080);
          }
  
          if (mSourceExpr.hasNext()) { // result sequence > 0
  
              final Type sourceType = Type.getType(getNode().getTypeKey());
              final String sourceValue = new String(((ITreeValData)getNode()).getRawValue());
  
              // determine castability
              isCastable = sourceType.isCastableTo(mTargetType, sourceValue);
  
              // if the result sequence of the input expression has more than one
              // item, a type error is raised.
              if (mSourceExpr.hasNext()) { // result sequence > 1
                  throw new XPathError(ErrorType.XPTY0004);
              }
  
          } else { // result sequence = 0 (empty sequence)
  
              // empty sequence is allowed.
              isCastable = mPermitEmptySeq;
  
          }
  
          // create result item and move transaction to it.
          AtomicValue val =
              new AtomicValue(TypedValue.getBytes(Boolean.toString(isCastable)), NamePageHash
                  .generateHashForString("xs:boolean"));
          final int mItemKey = getItemList().addItem(val);
          moveTo(mItemKey);
          return val;
  
      }
docs: {@inheritDoc}