Package org.jaxen.saxpath

Examples of org.jaxen.saxpath.XPathReader


        System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
                            "org.jaxen.saxpath.helpers.MockXPathReader"  );

        try
        {
            XPathReader reader = XPathReaderFactory.createReader();

            assertNotNull( reader );

            assertSame( MockXPathReader.class,
                        reader.getClass() );
        }
        catch (org.jaxen.saxpath.SAXPathException e)
        {
            fail( e.getMessage() );
        }
View Full Code Here


        System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
                            "java.lang.String" );

        try
        {
            XPathReader reader = XPathReaderFactory.createReader();

            fail( "Should have thrown SAXPathException" );
        }
        catch (org.jaxen.saxpath.SAXPathException e)
        {
View Full Code Here

        System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
                            "i.am.a.class.that.does.not.Exist" );

        try
        {
            XPathReader reader = XPathReaderFactory.createReader();

            fail( "Should have thrown SAXPathException" );
        }
        catch (org.jaxen.saxpath.SAXPathException e)
        {
View Full Code Here

    public void testValidExplicit()
    {
        try
        {
            XPathReader reader = XPathReaderFactory.createReader( "org.jaxen.saxpath.helpers.MockXPathReader" );

            assertNotNull( reader );

            assertSame( MockXPathReader.class,
                        reader.getClass() );
        }
        catch (org.jaxen.saxpath.SAXPathException e)
        {
            fail( e.getMessage() );
        }
View Full Code Here

    public void testInvalidExplicit()
    {
        try
        {
            XPathReader reader = XPathReaderFactory.createReader( "java.lang.String" );

            fail( "Should have thrown SAXPathException" );
        }
        catch (org.jaxen.saxpath.SAXPathException e)
        {
View Full Code Here

    public void testNonExistantExplicit()
    {
        try
        {
            XPathReader reader = XPathReaderFactory.createReader( "i.am.a.class.that.does.not.Exist" );

            fail( "Should havfe thrown SAXPathException" );
        }
        catch (org.jaxen.saxpath.SAXPathException e)
        {
View Full Code Here

        if ( USE_HANDLER )

        {

            XPathReader reader = XPathReaderFactory.createReader();

            PatternHandler handler = new PatternHandler();      

           

            handler.setXPathFactory( new DefaultXPathFactory() );           

            reader.setXPathHandler( handler );

            reader.parse( text );

           

            return handler.getPattern();

        }

        else

        {

            XPathReader reader = XPathReaderFactory.createReader();

            JaxenHandler handler = new JaxenHandler();

           

            handler.setXPathFactory( new DefaultXPathFactory() );           

            reader.setXPathHandler( handler );

            reader.parse( text );



            Pattern pattern = convertExpr( handler.getXPathExpr().getRootExpr() );
View Full Code Here

     */
    protected BaseXPath(String xpathExpr) throws JaxenException
    {
        try
        {
            XPathReader reader = XPathReaderFactory.createReader();
           
            JaxenHandler handler = new JaxenHandler();
           
            reader.setXPathHandler( handler );
           
            reader.parse( xpathExpr );

            this.xpath = handler.getXPathExpr();
        }
        catch (org.jaxen.saxpath.XPathSyntaxException e)
        {
View Full Code Here

     *          interface
     */
    public static XPathReader createReader(String className) throws SAXPathException
    {
        Class readerClass  = null;
        XPathReader reader = null;

        try
        {
            // Use the full version of Class.forName(), so as to
            // work better in sandboxed environments, such as
View Full Code Here

     */
    private static SelectorStep[] _buildSteps(String selectorExpression) throws SAXPathException {
        AssertArgument.isNotNull(selectorExpression, "selectorExpression");

        String xpathExpression = toXPathExpression(selectorExpression);
        XPathReader reader = XPathReaderFactory.createReader();
        JaxenHandler handler = new JaxenHandler();
        List<SelectorStep> selectorSteps = new ArrayList<SelectorStep>();
        boolean isRooted = false;
        boolean endsStarStar = false;

        if(xpathExpression.startsWith("/")) {
            isRooted = true;
        } else if(isEncodedToken(xpathExpression)) {
            String[] tokens = xpathExpression.split("/");

            selectorSteps.add(new SelectorStep(tokens[0]));

            StringBuilder reconstructedExpression = new StringBuilder();
            for(int i = 1; i < tokens.length; i++) {
                if(reconstructedExpression.length() > 0) {
                    reconstructedExpression.append('/');
                }
                reconstructedExpression.append(tokens[i]);
            }
            xpathExpression = reconstructedExpression.toString();
        }
        if(xpathExpression.endsWith("//")) {
            endsStarStar = true;
            xpathExpression = xpathExpression.substring(0, xpathExpression.length() - 2);
        }

        if(xpathExpression.trim().length() > 0) {
            reader.setXPathHandler(handler);
            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() + "'.");
View Full Code Here

TOP

Related Classes of org.jaxen.saxpath.XPathReader

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.