Package javax.xml.xpath

Examples of javax.xml.xpath.XPathFunctionException


            // throw XPathFunctionException
            if ( extensionInvocationDisabled ) {
                String fmsg = XSLMessages.createXPATHMessage(
                    XPATHErrorResources.ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED,
                    new Object[] { myQName.toString() } );
                throw new XPathFunctionException ( fmsg );
            }

            // Assuming user is passing all the needed parameters ( including
            // default values )
            int arity = argVec.size();
View Full Code Here


            // feature is set then invocation of extension functions need to
            // throw XPathFunctionException
            if ( extensionInvocationDisabled ) {
                String fmsg = XSLMessages.createXPATHMessage(
                    XPATHErrorResources.ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED,                    new Object[] { myQName.toString() } );
                throw new XPathFunctionException ( fmsg );
            }

            XPathFunction xpathFunction =
                resolver.resolveFunction( myQName, arity );
View Full Code Here

            OLink olink = _oxpath.links.get(args.get(0));
            try {
                return _ectx.isLinkActive(olink) ? Boolean.TRUE : Boolean.FALSE;
            } catch (FaultException e) {
                throw new XPathFunctionException(e);
            }
        }
View Full Code Here

            OXPath10Expression.OSigGetVariableData sig = _oxpath.resolveGetVariableDataSig(varname,partname,xpathStr);
            if (sig == null) {
                String msg = "InternalError: Attempt to use an unknown getVariableData signature: " + args;
                if (__log.isFatalEnabled())
                    __log.fatal(msg);
                throw new XPathFunctionException(msg);
            }

            try {
                Node ret = _ectx.readVariable(sig.variable, sig.part);
                if (sig.location != null)
                    ret = _ectx.evaluateQuery(ret, sig.location);

                if (__log.isDebugEnabled()) {
                    __log.debug("bpws:getVariableData(" + args +  ")' = " + ret);
                }

                return ret;
            } catch (FaultException e) {
                __log.error("bpws:getVariableData(" + args + ") threw FaultException");

                throw new XPathFunctionException(e);
            }
        }
View Full Code Here

    }

    public class GetVariableProperty implements XPathFunction {
        public Object evaluate(List args) throws XPathFunctionException {
            if (args.size() != 2) {
                throw new XPathFunctionException("missing required arguments");
            }

            OScope.Variable var = _oxpath.vars.get(args.get(0));
            OProcess.OProperty property = _oxpath.properties.get(args.get(1));

            if (__log.isDebugEnabled()) {
                __log.debug("function call:'bpws:getVariableProperty(" + var + ","
                        + property + ")'");
            }

            try {
                return _ectx.readMessageProperty(var, property);
            } catch (FaultException e) {
                throw new XPathFunctionException(e);
            }
        }
View Full Code Here

                            try {
                                // use the property placeholder resolver to lookup the property for us
                                Object answer = exchange.get().getContext().resolvePropertyPlaceholders("{{" + text + "}}");
                                return answer;
                            } catch (Exception e) {
                                throw new XPathFunctionException(e);
                            }
                        }
                    }
                    return null;
                }
View Full Code Here

                            try {
                                // use the property placeholder resolver to lookup the property for us
                                Object answer = exchange.get().getContext().resolvePropertyPlaceholders("{{" + text + "}}");
                                return answer;
                            } catch (Exception e) {
                                throw new XPathFunctionException(e);
                            }
                        }
                    }
                    return null;
                }
View Full Code Here

                            try {
                                // use the property placeholder resolver to lookup the property for us
                                Object answer = exchange.get().getContext().resolvePropertyPlaceholders("{{" + text + "}}");
                                return answer;
                            } catch (Exception e) {
                                throw new XPathFunctionException(e);
                            }
                        }
                    }
                    return null;
                }
View Full Code Here

    }
   
    public class ProcessProperty implements XPathFunction {
      public Object evaluate(List args) throws XPathFunctionException {
            if (args.size() != 1)
                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "processPropertyInvalidSource"), "Invalid arguments"));

            if (__log.isDebugEnabled()) {
                __log.debug("process-property call(context=" + _ectx + " args=" + args + ")");
            }

            QName propertyName = null;
            Element targetElmt = null;
            try {
                if (args.get(0) instanceof List) {
                    List elmts = (List) args.get(0);
                    if (elmts.size() != 1) throw new XPathFunctionException(
                            new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
                                    "The bpws:process-property function MUST be passed a single " +
                                            "element node."));
                    if (elmts.get(0) instanceof Element) {
                        targetElmt = (Element) elmts.get(0);
                    } else if (elmts.get(0) instanceof String) {
                      propertyName = new QName((String) elmts.get(0));
                    }
                } else if (args.get(0) instanceof NodeWrapper) {
                    targetElmt = (Element) ((NodeWrapper) args.get(0)).getUnderlyingNode();
                } else if (args.get(0) instanceof Element) {
                    targetElmt = (Element) args.get(0);
                } else if (args.get(0) instanceof QNameValue) {
                  QNameValue qNameValue = (QNameValue) args.get(0);
                    propertyName = new QName(qNameValue.getNamespaceURI(), qNameValue.getLocalName(), qNameValue.getPrefix());
                } else if (args.get(0) instanceof String)  {
                  String stringValue = (String) args.get(0);
                  if (stringValue.indexOf(":") > 0) {
                    String prefix = stringValue.substring(0, stringValue.indexOf(":"));
                    String localPart = stringValue.substring(stringValue.indexOf(":") + 1);
                    String namespaceUri = _oxpath.namespaceCtx.getNamespaceURI(prefix);
                    propertyName = new QName(namespaceUri, localPart, prefix);
                  } else {
                      propertyName = new QName(stringValue);
                  }
                } else if (args.get(0) instanceof QName) {
                  propertyName = (QName) args.get(0);
                } else {
                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
                }
                if (propertyName == null) {
                  if (targetElmt != null) {
                    propertyName = new QName(targetElmt.getTextContent());
                  }
                }
            } catch (IllegalArgumentException e) {
                throw new XPathFunctionException(
                    new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
                        "Invalid argument: URI Template expected. " + args.get(0), e));
            } catch (ClassCastException e) {
                throw new XPathFunctionException(
                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
                                "The bpws:process-property function MUST be passed a single " +
                                        "element node."));
            }
            return _ectx.getPropertyValue(propertyName);
View Full Code Here

    }
   
    public class InsertAfter implements XPathFunction {
      public Object evaluate(List args) throws XPathFunctionException {
            if (args.size() < 2 || args.size() > 3)
                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "insertAfterInvalidSource"), "Invalid arguments"));

            if (__log.isDebugEnabled()) {
                __log.debug("insertAfter call(context=" + _ectx + " args=" + args + ")");
            }
           
            Element targetElmt;
            List<Node> siblingNodes;
          Object childArg = null, siblingsArg = null;
            try {
              if (args.size() == 2) {
                childArg = args.get(0);
                siblingsArg = args.get(1);
              } else {
                childArg = args.get(1);
                siblingsArg = args.get(2);
              }
                if (childArg instanceof List) {
                    List elmts = (List) childArg;
                    // allow insertions after a sequence of node items
                    // if (elmts.size() != 1) throw new XPathFunctionException(
                    //        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
                    //                "The bpws:insertAfter function MUST be passed a single " +
                    //                        "element node."));
                    targetElmt = (Element) elmts.get(elmts.size() - 1);
                } else if (childArg instanceof NodeWrapper) {
                    targetElmt = (Element) ((NodeWrapper) childArg).getUnderlyingNode();
                } else if (childArg instanceof Element) {
                    targetElmt = (Element) childArg;
                } else {
                    throw new XPathFunctionException("Unexpected argument type: " + childArg.getClass());
                }
                if (siblingsArg instanceof List) {
                    siblingNodes = (List<Node>) siblingsArg;
                } else if (siblingsArg instanceof NodeWrapper) {
                    Node childElmt = (Node) ((NodeWrapper) siblingsArg).getUnderlyingNode();
                    siblingNodes = new ArrayList<Node>();
                    siblingNodes.add(childElmt);
                } else if (siblingsArg instanceof Element) {
                    Node childElmt = (Node) siblingsArg;
                    siblingNodes = new ArrayList<Node>();
                    siblingNodes.add(childElmt);
                } else {
                    throw new XPathFunctionException("Unexpected argument type: " + siblingsArg.getClass());
                }
            } catch (IllegalArgumentException e) {
                throw new XPathFunctionException(
                    new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
                        "Invalid argument: URI Template expected. " + siblingsArg, e));
            } catch (ClassCastException e) {
                throw new XPathFunctionException(
                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
                                "The bpws:insertAfter function MUST be passed a single " +
                                        "element node."));
            }
            Element parentElmt = (Element) targetElmt.getParentNode();
View Full Code Here

TOP

Related Classes of javax.xml.xpath.XPathFunctionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.