Package org.jaxen.saxpath

Examples of org.jaxen.saxpath.SAXPathException


            // Double-check that it's actually the right kind of class
            // before attempting instantiation.
           
            if ( ! XPathReader.class.isAssignableFrom( readerClass ) )
            {
                throw new SAXPathException( "Class [" + className
                  + "] does not implement the org.jaxen.saxpath.XPathReader interface." );
            }
        }
        catch (ClassNotFoundException e)
        {
            throw new SAXPathException( e );
        }

        try
        {
            reader = (XPathReader) readerClass.newInstance();
        }
        catch (IllegalAccessException e)
        {
            throw new SAXPathException( e );
        }
        catch (InstantiationException e)
        {
            throw new SAXPathException( e );
        }
       
        return reader;
    }
View Full Code Here


    public SAXPathExceptionTest(String name) {
        super(name);
    }

    public void testMessageIsNonNull() {
        SAXPathException ex = new SAXPathException("Hello");
        assertEquals("Hello", ex.getMessage());
    }   
View Full Code Here

        assertEquals("Hello", ex.getMessage());
    }   
 
    public void testPrintStackTrace() {
        StringIndexOutOfBoundsException cause = new StringIndexOutOfBoundsException("1234");
        SAXPathException ex = new SAXPathException(cause);
        StringWriter out = new StringWriter();
        PrintWriter pw = new PrintWriter(out);
        ex.printStackTrace(pw);
        pw.close();
        assertTrue(out.toString().indexOf("Caused by: java.lang.StringIndexOutOfBoundsException") > 0);
        assertTrue(out.toString().indexOf("1234") > 0);
    }
View Full Code Here

            // Double-check that it's actually the right kind of class
            // before attempting instantiation.
           
            if ( ! XPathReader.class.isAssignableFrom( readerClass ) )
            {
                throw new SAXPathException( "Class [" + className
                  + "] does not implement the org.jaxen.saxpath.XPathReader interface." );
            }
        }
        catch (ClassNotFoundException e)
        {
            throw new SAXPathException( e );
        }

        try
        {
            reader = (XPathReader) readerClass.newInstance();
        }
        catch (IllegalAccessException e)
        {
            throw new SAXPathException( e );
        }
        catch (InstantiationException e)
        {
            throw new SAXPathException( e );
        }
       
        return reader;
    }
View Full Code Here

    public XPathExpressionEvaluator build() throws SAXPathException, NotFoundException, CannotCompileException, InstantiationException, IllegalAccessException {
        PredicatesEvaluator evaluator = new PredicatesEvaluator();

        if (!(step instanceof NameStep)) {
            throw new SAXPathException("Unsupported step '" + step.getText() + "'.");
        }

        addEvaluators(step, evaluator);

        // Add the evaluators for the attribute step...
View Full Code Here

        String namespace = namespaces.getProperty(nsPrefix);

        if(namespace == null) {
            namespace = Namespace.SMOOKS_PREFIX_MAPPINGS.getProperty(nsPrefix);
            if(namespace == null) {
                throw new SAXPathException("Unknown namespace prefix '" + nsPrefix + "'.  You must define the namespace prefix-to-uri mappings in the Smooks <core:namespaces> configuration section.");
            }
        }
        return namespace;
    }
View Full Code Here

            return new AbsoluteValue((NumberExpr) expr);
        } else if(expr instanceof LiteralExpr) {
            return new AbsoluteValue((LiteralExpr) expr);
        }

        throw new SAXPathException("Unsupported XPath value token '" + expr.getText() + "'.");
    }
View Full Code Here

            reader.parse(xpathExpression);

            XPathExpr xpath = handler.getXPathExpr();
            Expr expr = xpath.getRootExpr();
            if (!(expr instanceof LocationPath)) {
                throw new SAXPathException("Invalid XPath expression '" + xpathExpression + "'.  Selector must be a LocationPath expression. Is '" + expr.getText() + "'.");
            }

            LocationPath path = (LocationPath) expr;
            List<Step> steps = path.getSteps();

            for (int i = 0; i < steps.size(); i++) {
                Step step = steps.get(i);

                try {
                    if(step.getAxis() == Axis.ATTRIBUTE && i < steps.size() - 1) {
                        // Attribute steps are only supported as the last step...
                        throw new SAXPathException("Attribute axis steps are only supported at the end of the expression.  '" + step.getText() + "' is not at the end.");
                    } else if(step.getAxis() == Axis.DESCENDANT_OR_SELF) {
                        selectorSteps.add(new SelectorStep(xpathExpression, "**"));
                    } else if(step.getAxis() != Axis.CHILD && step.getAxis() != Axis.ATTRIBUTE) {
                        throw new SAXPathException("XPath step '" + step.getText() + "' not supported.");
                    } else {
                        if(i == steps.size() - 2) {
                            Step nextStep = steps.get(i + 1);
                            if(nextStep.getAxis() == Axis.ATTRIBUTE) {
                                selectorSteps.add(new SelectorStep(xpathExpression, step, nextStep));
                                // We end here.  The next step is the last step and we've merged it into
                                // the last evaluator...
                                break;
                            } else {
                                selectorSteps.add(new SelectorStep(xpathExpression, step));
                            }
                        } else {
                            selectorSteps.add(new SelectorStep(xpathExpression, step));
                        }
                    }
                } catch (SAXPathException e) {
                    throw new SAXPathException("Error processing XPath selector expression '" + xpathExpression + "'.", e);
                } catch (Exception e) {
                    throw new SAXPathException("Error building step evaluator.", e);
                }
            }
        }

        if(isRooted) {
View Full Code Here

        if(step != null) {
            PredicatesEvaluatorBuilder builder = new PredicatesEvaluatorBuilder(step, attributeStep, this, namespaces);
            try {
                predicatesEvaluator = builder.build();
            } catch (SAXPathException e) {
                throw new SAXPathException("Error processing XPath selector expression '" + xpathExpression + "'.", e);
            }

            // And update the QNames again now that we have the namespaces...
            targetElement = toQName(step, builder);
            if(attributeStep != null) {
View Full Code Here

            try {
                step.buildPredicatesEvaluator(namespaces);
            } catch (SAXPathException e) {
                throw e;
            } catch (Exception e) {
                throw new SAXPathException("Error compiling PredicatesEvaluator.", e);
            }

            //
            if(i < steps.length - 1 && step.accessesText()) {
                throw new SAXPathException("Unsupported XPath selector expression '" + step.getXPathExpression() + "'.  XPath 'text()' tokens are only supported in the last step.");
            }
        }

        return steps;
    }
View Full Code Here

TOP

Related Classes of org.jaxen.saxpath.SAXPathException

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.