@Override
    protected final Object invokeProjection(
        final String resolvedXpath, final Object proxy, final Object[] args) throws Throwable {
      final XPath xPath = projector.config().createXPath(DOMHelper.getOwnerDocumentFor(node));

      if (!lastInvocationContext.isStillValid(resolvedXpath)) {
        final DuplexExpression duplexExpression =
            new DuplexXPathParser(projector.config().getUserDefinedNamespaceMapping())
                .compile(resolvedXpath);
        String strippedXPath = duplexExpression.getExpressionAsStringWithoutFormatPatterns();
        MethodParamVariableResolver resolver = null;
        if (duplexExpression.isUsingVariables()) {
          XPathVariableResolver peviousResolver = xPath.getXPathVariableResolver();
          resolver =
              new MethodParamVariableResolver(
                  method,
                  args,
                  duplexExpression,
                  projector.config().getStringRenderer(),
                  peviousResolver);
          xPath.setXPathVariableResolver(resolver);
        }
        final XPathExpression xPathExpression = xPath.compile(strippedXPath);
        final Class<?> targetComponentType = findTargetComponentType(method);
        lastInvocationContext =
            new InvocationContext(
                resolvedXpath,
                xPath,
                xPathExpression,
                duplexExpression,
                resolver,
                targetComponentType,
                projector);
      }
      lastInvocationContext.updateMethodArgs(args);
      return invokeXpathProjection(lastInvocationContext, proxy, args);
    }
Exemple #2
0
 /**
  * Test for XPath.setXPathVariableResolver(XPathVariableResolver resolver). Set a valid resolver
  * and retrieve it using getXPathVariableResolver(), should return the same.
  */
 @Test
 public void testCheckXPath63() {
   xpath.setXPathVariableResolver(qname -> null);
   assertNotNull(xpath.getXPathVariableResolver());
 }
Exemple #3
0
 /**
  * Test for XPath.getXPathVariableResolver() Return the current variable resolver. null is
  * returned if no variable resolver is in effect.
  */
 @Test
 public void testCheckXPath62() {
   assertNull(xpath.getXPathVariableResolver());
 }