Package com.ibm.commons.xml.xpath

Examples of com.ibm.commons.xml.xpath.XPathException


            if (nodeList.getLength() == 1) {
                node = nodeList.get(0);
            }
        }
        if (node == null || !(node instanceof Node)) {
            throw new XPathException(null,"Error creating part:" + part.toString() // $NLS-XmlSimpleExpression.ErrorcreatePART-1$
                    + " Node must be of the type " + Node.class // $NLS-XmlSimpleExpression.Nodemustbeofthetype-1$
                    + " but it was :" // $NLS-XmlSimpleExpression.BUTitwas-1$
                    + ((node == null) ? null : node.getClass()));
        }
        Node nodeObj = (Node) node;
View Full Code Here


     *
     * @see AbstractSimpleExpression#setPart(Object, Part, Object)
     */
    protected void setNodeValue(Object node, Object value) throws XPathException {
        if (node == null) {
            throw new XPathException(null, "Cannot set a value on an null XPath result" ); // $NLS-XmlSimpleExpression.CannotsetavalueonannullXPathresul-1$
        }
       
        if (node instanceof NodeListImpl) {
            NodeListImpl nodeList = (NodeListImpl)node;
            if (nodeList.getLength() == 1) {
                node = nodeList.get(0);
            }
            else {
                throw new XPathException(null, "Cannot set a value on a list of elements" ); // $NLS-XmlSimpleExpression.Cannotsetavalueonalistofelements-1$
            }
        }
       
        Node nodeObj = (Node) node;
        String strValue = (value == null) ? "" : value.toString(); //$NON-NLS-1$
View Full Code Here

                return new XResultUtils.XMLNodeList((NodeList)node);
            }
        }
       

        throw new XPathException(null,"Internal error while executing simple path. Result:",node.toString()); // $NLS-XmlSimpleExpression.Internalerrorwhileexecutingsimple-1$
    }
View Full Code Here

        try {
            Document document = getDocument(node);
            DOMUtil.pushXPathContext(document, getExpression());
        }
        catch (XMLException xe) {
            throw new XPathException(xe);
        }
    }
View Full Code Here

            if (context != null && context.getExpression().equals(getExpression())) {
                DOMUtil.popXPathContext(document);
            }
        }
        catch (XMLException xe) {
            throw new XPathException(xe);
        }
    }
View Full Code Here

                if (node == null) {
                  try {
                    pathContext.createNodes();
                  }
                  catch (XMLException xe) {
                    throw new XPathException(xe);
                  }
                    node = pathContext.getContextNodes();
                }
            }
        }
        if (node == null) {
            throw new XPathException(new NullPointerException("Cannot evaluate an XPath on a null object")); // $NLS-XmlComplexExpression.CannotevaluateanXPathonanullobjec-1$
        }
        // WARN: Xerces is having Node also implementing NodeList
        // We first check Node to be sure.
        if (node instanceof Node) {
            Node nodeObj = (Node)node;
            namespaceContext = resolveNamespaceContext(nodeObj,namespaceContext);
            return domDriver.evaluateXPath(nodeObj,compiledXPath,namespaceContext);
        }
        if (node instanceof NodeList) {
            NodeList nodeList = (NodeList)node;
            namespaceContext = resolveNamespaceContext(nodeList.item(0),namespaceContext);
            XResult r = domDriver.evaluateXPath(nodeList,compiledXPath,namespaceContext);
            return r;
        }
        throw new XPathException(null,"Try to evaluate an XPath on a object that is not a node or a node list"); // $NLS-XmlComplexExpression.TrytoevaluateanXPathonaobjectthat-1$
    }
View Full Code Here

     * @see com.ibm.xfaces.xpath.XPathExpression#createNodes(java.lang.Object,
     *      java.lang.Object)
     */
    protected Object doCreateNodes(Object node, NamespaceContext namespaceContext)
            throws XPathException {    
        throw new XPathException(null,"CREATE nodes not supported by complex expressions."); // $NLS-XmlComplexExpression.CREATEnodesnotsupportedbycomplexe-1$
    }
View Full Code Here

     * @see com.ibm.xfaces.xpath.XPathExpression#setValue(java.lang.Object,
     *      java.lang.Object)
     */
    protected void doSetValue(Object node, Object value, NamespaceContext nsContext, boolean autoCreate) throws XPathException {
        if (node == null) {
            throw new XPathException(new NullPointerException("Cannot set a value on a null object")); // $NLS-XmlComplexExpression.Cannotsetavalueonanullobject-1$
        }
        if (!(node instanceof Node)) {
            throw new XPathException(null,"Try to evaluate to set a value on a object that is not a node"); // $NLS-XmlComplexExpression.Trytoevaluatetosetavalueonaobject-1$
        }

        Node nodeObj = (Node)node;
        nsContext = resolveNamespaceContext(nodeObj,nsContext);
       
        XResult r = domDriver.evaluateXPath(nodeObj,compiledXPath,nsContext);
        if(r.isEmpty()) {
            throw new XPathException(null,"Cannot create XPath {0}",getExpression()); // $NLS-XmlComplexExpression.CannotcreateXPath0-1$
        }
        if(r.isValue()) {
            throw new XPathException(null,"Cannot set a value on a value result, XPath={0}",getExpression()); // $NLS-XmlComplexExpression.CannotsetavalueonavalueresultXPat-1$
        }
        String strValue = Utils.getAsString(value);
        for( Iterator it=r.getNodeIterator(); it.hasNext(); ) {
            Object n = (Object)it.next();
            if( n instanceof Node ) {
View Full Code Here

              throw noXpathAvail();
            }
        };
    }
    private static XPathException noXpathAvail() {
      return new XPathException(null,"XPath engine is not available");//$NLS-DOMUtil.XPathengineisnotavailable-1$
    }
View Full Code Here

        try {
            PrefixResolver pr = nsContext!=null ? new NSResolver(nsContext) : null;
            XObject res = XPathAPI.eval(node,(String)xpath,pr);
            return convertResult(res);
        } catch(Exception e) {
            throw new XPathException(e,"Error while evaluating XPath {0}",xpath.toString()); // $NLS-AbstractXercesDriver.ErrorwhileevaluatingXPath0-1$
        }
    }
View Full Code Here

TOP

Related Classes of com.ibm.commons.xml.xpath.XPathException

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.