public void testNormalizeSpaceRequiresAtMostOneArguments() throws JaxenException {
   BaseXPath xpath = new DOMXPath("normalize-space('a', 'a')");
   try {
     xpath.selectNodes(doc);
     fail("Allowed normalize-space function with two arguments");
   } catch (FunctionCallException ex) {
     assertNotNull(ex.getMessage());
   }
 }
 public void testSubstringBeforeFunctionRequiresAtMostTwoArguments() throws JaxenException {
   BaseXPath xpath = new DOMXPath("substring-before('a', 'a', 'a')");
   try {
     xpath.selectNodes(doc);
     fail("Allowed substring-before function with three arguments");
   } catch (FunctionCallException ex) {
     assertNotNull(ex.getMessage());
   }
 }
Esempio n. 3
0
  public void testContainsFunctionRequiresAtLeastTwoArguments() throws JaxenException {

    BaseXPath xpath = new DOMXPath("contains('a')");

    try {
      xpath.selectNodes(doc);
      fail("Allowed contains function with one argument");
    } catch (FunctionCallException ex) {
      assertNotNull(ex.getMessage());
    }
  }
Esempio n. 4
0
 @SuppressWarnings("unchecked")
 public static Iterator<Node> findNodes(
     Node node, String xpathquery, Map<String, String> namespaces) {
   Iterator<Node> it = null;
   try {
     BaseXPath expression = getXpath(xpathquery, namespaces);
     it = expression.selectNodes(node).iterator();
   } catch (Exception exe) {
   }
   if (it == null) {
     it = new Vector().iterator();
   }
   return it;
 }