Package com.ibm.commons.xml.xpath

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


        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


                for( int i=0; i<nodeList.getLength(); i++ ) {
                    XObject res = XPathAPI.eval(nodeList.item(i),(String)xpath,pr);
                    switch(res.getType()) {
                        case XObject.CLASS_BOOLEAN: {
                            if(nodes!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval-1$
                            }
                            if(result!=null) {
                                throw new XPathException(null,"XPath exception cannot return multiple values"); // $NLS-AbstractXercesDriver.AnXPathExceptioncannotreturnmulti-1$
                            }
                            result = new XResultUtils.BooleanValue(res.bool());
                        } break;
                        case XObject.CLASS_NUMBER: {
                            if(nodes!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval.1-1$
                            }
                            if(result!=null) {
                                throw new XPathException(null,"XPath exception cannot return multiple values"); // $NLS-AbstractXercesDriver.AnXPathExceptioncannotreturnmulti.1-1$
                            }
                            result = new XResultUtils.NumberValue(res.num());
                        } break;
                        case XObject.CLASS_STRING: {
                            if(nodes!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval.2-1$
                            }
                            if(result!=null) {
                                throw new XPathException(null,"XPath exception cannot return multiple values"); // $NLS-AbstractXercesDriver.AnXPathExceptioncannotreturnmulti.2-1$
                            }
                            result = new XResultUtils.StringValue(res.str());
                        } break;
                        case XObject.CLASS_NODESET: {
                            if(result!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval.3-1$
                            }
                            NodeList nl = res.nodelist();
                            int len = nl.getLength();
                            if(len>0) {
                                if(nodes==null) {
                                    nodes = new NodeListImpl();
                                }
                                for( int j=0; j<nl.getLength(); j++ ) {
                                    nodes.add(nl.item(j));
                                }
                            }
                        }
                    }
                }
                if(result!=null) {
                    return result;
                }
                if(nodes!=null) {
                    int len = nodes.getLength();
                    if(len==0) {
                        return XResultUtils.emptyResult;
                    } else if(len==1) {
                        return new XResultUtils.XMLNode(nodes.item(0));
                    } else {
                        return new XResultUtils.XMLNodeList(nodes);
                    }
                }
            }
            return XResultUtils.emptyResult;
        } catch(Exception e) {
            throw new XPathException(e,"Error evaluating XPath {0}",xpath.toString()); // $NLS-AbstractXercesDriver.ErrorwhileevaluatingXPath0.1-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

                for( int i=0; i<nodeList.getLength(); i++ ) {
                    XObject res = XPathAPI.eval(nodeList.item(i),(String)xpath,pr);
                    switch(res.getType()) {
                        case XObject.CLASS_BOOLEAN: {
                            if(nodes!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval-1$
                            }
                            if(result!=null) {
                                throw new XPathException(null,"XPath exception cannot return multiple values"); // $NLS-AbstractXercesDriver.AnXPathExceptioncannotreturnmulti-1$
                            }
                            result = new XResultUtils.BooleanValue(res.bool());
                        } break;
                        case XObject.CLASS_NUMBER: {
                            if(nodes!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval.1-1$
                            }
                            if(result!=null) {
                                throw new XPathException(null,"XPath exception cannot return multiple values"); // $NLS-AbstractXercesDriver.AnXPathExceptioncannotreturnmulti.1-1$
                            }
                            result = new XResultUtils.NumberValue(res.num());
                        } break;
                        case XObject.CLASS_STRING: {
                            if(nodes!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval.2-1$
                            }
                            if(result!=null) {
                                throw new XPathException(null,"XPath exception cannot return multiple values"); // $NLS-AbstractXercesDriver.AnXPathExceptioncannotreturnmulti.2-1$
                            }
                            result = new XResultUtils.StringValue(res.str());
                        } break;
                        case XObject.CLASS_NODESET: {
                            if(result!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval.3-1$
                            }
                            NodeList nl = res.nodelist();
                            int len = nl.getLength();
                            if(len>0) {
                                if(nodes==null) {
                                    nodes = new NodeListImpl();
                                }
                                for( int j=0; j<nl.getLength(); j++ ) {
                                    nodes.add(nl.item(j));
                                }
                            }
                        }
                    }
                }
                if(result!=null) {
                    return result;
                }
                if(nodes!=null) {
                    int len = nodes.getLength();
                    if(len==0) {
                        return XResultUtils.emptyResult;
                    } else if(len==1) {
                        return new XResultUtils.XMLNode(nodes.item(0));
                    } else {
                        return new XResultUtils.XMLNodeList(nodes);
                    }
                }
            }
            return XResultUtils.emptyResult;
        } catch(Exception e) {
            throw new XPathException(e,"Error evaluating XPath {0}",xpath.toString()); // $NLS-AbstractXercesDriver.ErrorwhileevaluatingXPath0.1-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

                for( int i=0; i<nodeList.getLength(); i++ ) {
                    XObject res = XPathAPI.eval(nodeList.item(i),(String)xpath,pr);
                    switch(res.getType()) {
                        case XObject.CLASS_BOOLEAN: {
                            if(nodes!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval-1$
                            }
                            if(result!=null) {
                                throw new XPathException(null,"XPath exception cannot return multiple values"); // $NLS-AbstractXercesDriver.AnXPathExceptioncannotreturnmulti-1$
                            }
                            result = new XResultUtils.BooleanValue(res.bool());
                        } break;
                        case XObject.CLASS_NUMBER: {
                            if(nodes!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval.1-1$
                            }
                            if(result!=null) {
                                throw new XPathException(null,"XPath exception cannot return multiple values"); // $NLS-AbstractXercesDriver.AnXPathExceptioncannotreturnmulti.1-1$
                            }
                            result = new XResultUtils.NumberValue(res.num());
                        } break;
                        case XObject.CLASS_STRING: {
                            if(nodes!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval.2-1$
                            }
                            if(result!=null) {
                                throw new XPathException(null,"XPath exception cannot return multiple values"); // $NLS-AbstractXercesDriver.AnXPathExceptioncannotreturnmulti.2-1$
                            }
                            result = new XResultUtils.StringValue(res.str());
                        } break;
                        case XObject.CLASS_NODESET: {
                            if(result!=null) {
                                throw new XPathException(null,"XPath result cannot contain both values and nodes"); // $NLS-AbstractXercesDriver.AnXPathresultcannotcontainbothval.3-1$
                            }
                            NodeList nl = res.nodelist();
                            int len = nl.getLength();
                            if(len>0) {
                                if(nodes==null) {
                                    nodes = new NodeListImpl();
                                }
                                for( int j=0; j<nl.getLength(); j++ ) {
                                    nodes.add(nl.item(j));
                                }
                            }
                        }
                    }
                }
                if(result!=null) {
                    return result;
                }
                if(nodes!=null) {
                    int len = nodes.getLength();
                    if(len==0) {
                        return XResultUtils.emptyResult;
                    } else if(len==1) {
                        return new XResultUtils.XMLNode(nodes.item(0));
                    } else {
                        return new XResultUtils.XMLNodeList(nodes);
                    }
                }
            }
            return XResultUtils.emptyResult;
        } catch(Exception e) {
            throw new XPathException(e,"Error evaluating XPath {0}",xpath.toString()); // $NLS-AbstractXercesDriver.ErrorwhileevaluatingXPath0.1-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-XmlSimpleExpression.CannotevaluateanXPathonanullobjec-1$
        }
        return super.doEval(node, namespaceContext);
    }
View Full Code Here

                    try {
                        pathContext.createNodes();
                        node = ((NodeList)pathContext.getContextNodes()).item(0);
                    }
                    catch (XMLException xe) {
                        throw new XPathException(xe);
                    }
                }
            }
        }
        super.doSetValue(node, value, namespaceContext, autoCreate);
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.