Examples of XPathExpressionException


Examples of javax.xml.xpath.XPathExpressionException

            XPathExpressionImpl ximpl = new XPathExpressionImpl (xpath,
                    prefixResolver, functionResolver, variableResolver,
                    featureSecureProcessing, useServiceMechanism, featureManager );
            return ximpl;
        } catch ( javax.xml.transform.TransformerException te ) {
            throw new XPathExpressionException ( te ) ;
        }
    }
View Full Code Here

Examples of javax.xml.xpath.XPathExpressionException

            Document document = getParser().parse( source );

            XObject resultObject = eval( expression, document );
            return getResultAsType( resultObject, returnType );
        } catch ( SAXException e ) {
            throw new XPathExpressionException ( e );
        } catch( IOException e ) {
            throw new XPathExpressionException ( e );
        } catch ( javax.xml.transform.TransformerException te ) {
            Throwable nestedException = te.getException();
            if ( nestedException instanceof javax.xml.xpath.XPathFunctionException ) {
                throw (javax.xml.xpath.XPathFunctionException)nestedException;
            } else {
                throw new XPathExpressionException ( te );
            }
        }

    }
View Full Code Here

Examples of javax.xml.xpath.XPathExpressionException

            if (node instanceof SingletonItem) {
                node = ((SingletonItem)node).getItem();
            }
            if (node instanceof NodeInfo) {
                if (!((NodeInfo)node).getConfiguration().isCompatible(config)) {
                    throw new XPathExpressionException(
                                "Supplied node must be built using the same or a compatible Configuration");
                }
                contextNode = ((NodeInfo)node);
            } else {
                JPConverter converter = JPConverter.allocate(node.getClass(), config);
                ValueRepresentation val;
                try {
                    val = converter.convert(node, new EarlyEvaluationContext(config, null));
                } catch (XPathException e) {
                    throw new XPathExpressionException(
                            "Failure converting a node of class " + node.getClass().getName() +
                            ": " + e.getMessage());
                }
                if (val instanceof NodeInfo) {
                    contextNode = (NodeInfo)val;
                } else {
                    throw new XPathExpressionException(
                            "Cannot locate an object model implementation for nodes of class "
                            + node.getClass().getName());
                }
            }
        }
        XPathContextMajor context = new XPathContextMajor(contextNode, executable);
        context.openStackFrame(stackFrameMap);
        try {
            if (qName.equals(XPathConstants.BOOLEAN)) {
                return Boolean.valueOf(expression.effectiveBooleanValue(context));
            } else if (qName.equals(XPathConstants.STRING)) {
                SequenceIterator iter = expression.iterate(context);

                Item first = iter.next();
                if (first == null) {
                    return "";
                }
                return first.getStringValue();

            } else if (qName.equals(XPathConstants.NUMBER)) {
                if (atomizer == null) {
                    atomizer = new Atomizer(expression);
                }
                SequenceIterator iter = atomizer.iterate(context);

                Item first = iter.next();
                if (first == null) {
                    return new Double(Double.NaN);
                }
                if (first instanceof NumericValue) {
                    return new Double(((NumericValue)first).getDoubleValue());
                } else {
                    DoubleValue v = NumberFn.convert((AtomicValue)first);
                    return new Double(v.getDoubleValue());
                }

            } else if (qName.equals(XPathConstants.NODE)) {
                SequenceIterator iter = expression.iterate(context);
                Item first = iter.next();
                if (first instanceof VirtualNode) {
                    return ((VirtualNode)first).getRealNode();
                }
                if (first == null || first instanceof NodeInfo) {
                    return first;
                }
                throw new XPathExpressionException("Expression result is not a node");
            } else if (qName.equals(XPathConstants.NODESET)) {
                //SequenceIterator iter = expression.iterate(context);
                SequenceIterator iter = rawIterator(context);
                SequenceExtent extent = new SequenceExtent(iter);
                PJConverter converter = PJConverter.allocateNodeListCreator(config, node);
                return converter.convert(extent, Object.class, context);
            } else {
                throw new IllegalArgumentException("qName: Unknown type for expected result");
            }
        } catch (XPathException e) {
            throw new XPathExpressionException(e);
        }
    }
View Full Code Here

Examples of javax.xml.xpath.XPathExpressionException

            if (inputSource != null) {
                doc = config.buildDocument(new SAXSource(inputSource));
            }
            return evaluate(doc, qName);
        } catch (XPathException e) {
            throw new XPathExpressionException(e);
        }
    }
View Full Code Here

Examples of javax.xml.xpath.XPathExpressionException

        }
        try {
            NodeInfo doc = config.buildDocument(new SAXSource(inputSource));
            return (String)evaluate(doc, XPathConstants.STRING);
        } catch (XPathException e) {
            throw new XPathExpressionException(e);
        }
    }
View Full Code Here

Examples of javax.xml.xpath.XPathExpressionException

            Document document = getParser().parse( source );

            XObject resultObject = eval( expression, document );
            return getResultAsType( resultObject, returnType );
        } catch ( SAXException e ) {
            throw new XPathExpressionException ( e );
        } catch( IOException e ) {
            throw new XPathExpressionException ( e );           
        } catch ( javax.xml.transform.TransformerException te ) {
            Throwable nestedException = te.getException();
            if ( nestedException instanceof javax.xml.xpath.XPathFunctionException ) {
                throw (javax.xml.xpath.XPathFunctionException)nestedException;
            } else {
                throw new XPathExpressionException ( te );
            }
        }

    }
View Full Code Here

Examples of javax.xml.xpath.XPathExpressionException

    else
    {
//      if (true)
//        throw new RuntimeException(_e.getCause());
      LOG.info("XPath error", _e);
      return new XPathExpressionException(_e.getMessage()); // stupid but XPathExpressionException(e).getMessage() is null!
    }
  }
View Full Code Here

Examples of javax.xml.xpath.XPathExpressionException

            return eval( item, returnType);
        } catch ( java.lang.NullPointerException npe ) {
            // If VariableResolver returns null Or if we get
            // NullPointerException at this stage for some other reason
            // then we have to reurn XPathException
            throw new XPathExpressionException ( npe );
        } catch ( javax.xml.transform.TransformerException te ) {
            Throwable nestedException = te.getException();
            if ( nestedException instanceof javax.xml.xpath.XPathFunctionException ) {
                throw (javax.xml.xpath.XPathFunctionException)nestedException;
            } else {
                // For any other exceptions we need to throw
                // XPathExpressionException ( as per spec )
                throw new XPathExpressionException( te);
            }
        }

    }
View Full Code Here

Examples of javax.xml.xpath.XPathExpressionException

            }
            db = dbf.newDocumentBuilder();
            Document document = db.parse( source );
            return evaldocument, returnType );
        } catch ( Exception e ) {
            throw new XPathExpressionException ( e );
        }
    }
View Full Code Here

Examples of javax.xml.xpath.XPathExpressionException

            return getResultAsType( resultObject, returnType );
        } catch ( java.lang.NullPointerException npe ) {
            // If VariableResolver returns null Or if we get
            // NullPointerException at this stage for some other reason
            // then we have to reurn XPathException
            throw new XPathExpressionException ( npe );
        } catch ( javax.xml.transform.TransformerException te ) {
            Throwable nestedException = te.getException();
            if ( nestedException instanceof javax.xml.xpath.XPathFunctionException ) {
                throw (javax.xml.xpath.XPathFunctionException)nestedException;
            } else {
                // For any other exceptions we need to throw
                // XPathExpressionException ( as per spec )
                throw new XPathExpressionException ( te );
            }
        }

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.