Пример #1
0
 /** Evaluate an XPath expression as a boolean value. */
 public static boolean evaluateAsBoolean(
     PropertyContext propertyContext,
     List<Item> contextItems,
     int contextPosition,
     String xpathString,
     Map<String, String> prefixToURIMap,
     Map<String, ValueRepresentation> variableToValueMap,
     FunctionLibrary functionLibrary,
     FunctionContext functionContext,
     String baseURI,
     LocationData locationData) {
   final PooledXPathExpression xpathExpression =
       XPathCache.getXPathExpression(
           propertyContext,
           contextItems,
           contextPosition,
           "string(subsequence(" + xpathString + ", 1, 1))",
           prefixToURIMap,
           variableToValueMap,
           functionLibrary,
           baseURI,
           false,
           false,
           locationData);
   try {
     return xpathExpression.evaluateAsBoolean(functionContext);
   } catch (XPathException e) {
     throw handleXPathException(e, xpathString, "evaluating XPath expression", locationData);
   } finally {
     if (xpathExpression != null) xpathExpression.returnToPool();
   }
 }
Пример #2
0
 /**
  * Evaluate an XPath expression on the document as an attribute value template, and return its
  * string value.
  */
 public static String evaluateAsAvt(
     PropertyContext propertyContext,
     List<Item> contextItems,
     int contextPosition,
     String xpathString,
     Map<String, String> prefixToURIMap,
     Map<String, ValueRepresentation> variableToValueMap,
     FunctionLibrary functionLibrary,
     FunctionContext functionContext,
     String baseURI,
     LocationData locationData) {
   final PooledXPathExpression xpathExpression =
       XPathCache.getXPathExpression(
           propertyContext,
           contextItems,
           contextPosition,
           xpathString,
           prefixToURIMap,
           variableToValueMap,
           functionLibrary,
           baseURI,
           true,
           false,
           locationData);
   try {
     final Object result = xpathExpression.evaluateSingleKeepNodeInfo(functionContext);
     return (result != null) ? result.toString() : null;
   } catch (XPathException e) {
     throw handleXPathException(e, xpathString, "evaluating XPath expression", locationData);
   } finally {
     if (xpathExpression != null) xpathExpression.returnToPool();
   }
 }