/**
  * Get the value converted to a double using the XPath casting rules
  *
  * @return the result of converting to a double
  * @throws SaxonApiException if the value cannot be cast to a double
  */
 public double getDoubleValue() throws SaxonApiException {
   AtomicValue av = (AtomicValue) getUnderlyingValue();
   if (av instanceof BooleanValue) {
     return ((BooleanValue) av).getBooleanValue() ? 0.0 : 1.0;
   } else if (av instanceof NumericValue) {
     return ((NumericValue) av).getDoubleValue();
   } else if (av instanceof StringValue) {
     return Value.stringToNumber(av.getStringValueCS());
   } else {
     throw new SaxonApiException("Cannot cast item to a double");
   }
 }
 /**
  * Get the value converted to an integer using the XPath casting rules
  *
  * @return the result of converting to an integer
  * @throws SaxonApiException if the value cannot be cast to an integer
  */
 public long getLongValue() throws SaxonApiException {
   AtomicValue av = (AtomicValue) getUnderlyingValue();
   if (av instanceof BooleanValue) {
     return ((BooleanValue) av).getBooleanValue() ? 0L : 1L;
   } else if (av instanceof NumericValue) {
     try {
       return ((NumericValue) av).longValue();
     } catch (XPathException e) {
       throw new SaxonApiException("Cannot cast item to an integer");
     }
   } else if (av instanceof StringValue) {
     return (long) Value.stringToNumber(av.getStringValueCS());
   } else {
     throw new SaxonApiException("Cannot cast item to an integer");
   }
 }