Coverage Report - org.jaxen.saxpath.base.XPathReader
 
Classes in this File Line Coverage Branch Coverage Complexity
XPathReader
99%
397/403
100%
44/44
4.256
 
 1  
 /*
 2  
  * $Header: /home/projects/jaxen/scm/jaxen/src/java/main/org/jaxen/saxpath/base/XPathReader.java,v 1.32 2006/04/07 23:47:37 elharo Exp $
 3  
  * $Revision: 1.32 $
 4  
  * $Date: 2006/04/07 23:47:37 $
 5  
  *
 6  
  * ====================================================================
 7  
  *
 8  
  * Copyright 2000-2002 bob mcwhirter & James Strachan.
 9  
  * All rights reserved.
 10  
  *
 11  
  *
 12  
  * Redistribution and use in source and binary forms, with or without
 13  
  * modification, are permitted provided that the following conditions are
 14  
  * met:
 15  
  * 
 16  
  *   * Redistributions of source code must retain the above copyright
 17  
  *     notice, this list of conditions and the following disclaimer.
 18  
  * 
 19  
  *   * Redistributions in binary form must reproduce the above copyright
 20  
  *     notice, this list of conditions and the following disclaimer in the
 21  
  *     documentation and/or other materials provided with the distribution.
 22  
  * 
 23  
  *   * Neither the name of the Jaxen Project nor the names of its
 24  
  *     contributors may be used to endorse or promote products derived 
 25  
  *     from this software without specific prior written permission.
 26  
  * 
 27  
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 28  
  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 29  
  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 30  
  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
 31  
  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 32  
  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 33  
  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 34  
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 35  
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 36  
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 37  
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 38  
  *
 39  
  * ====================================================================
 40  
  * This software consists of voluntary contributions made by many
 41  
  * individuals on behalf of the Jaxen Project and was originally
 42  
  * created by bob mcwhirter <bob@werken.com> and
 43  
  * James Strachan <jstrachan@apache.org>.  For more information on the
 44  
  * Jaxen Project, please see <http://www.jaxen.org/>.
 45  
  *
 46  
  * $Id: XPathReader.java,v 1.32 2006/04/07 23:47:37 elharo Exp $
 47  
  */
 48  
 
 49  
 
 50  
 package org.jaxen.saxpath.base;
 51  
 
 52  
 import java.util.ArrayList;
 53  
 
 54  
 import org.jaxen.saxpath.Axis;
 55  
 import org.jaxen.saxpath.Operator;
 56  
 import org.jaxen.saxpath.SAXPathException;
 57  
 import org.jaxen.saxpath.XPathHandler;
 58  
 import org.jaxen.saxpath.XPathSyntaxException;
 59  
 import org.jaxen.saxpath.helpers.DefaultXPathHandler;
 60  
 
 61  
 /** Implementation of SAXPath's <code>XPathReader</code> which
 62  
  *  generates callbacks to an <code>XPathHandler</code>.
 63  
  *
 64  
  *  @author bob mcwhirter (bob@werken.com)
 65  
  */
 66  
 public class XPathReader implements org.jaxen.saxpath.XPathReader
 67  
 {
 68  
     private ArrayList  tokens;
 69  
     private XPathLexer lexer;
 70  
 
 71  
     private XPathHandler handler;
 72  
     
 73  118
     private static XPathHandler defaultHandler = new DefaultXPathHandler();
 74  
 
 75  
     /**
 76  
      * Create a new <code>XPathReader</code> with a do-nothing
 77  
      * <code>XPathHandler</code>.
 78  
      */
 79  
     public XPathReader()
 80  6156
     {
 81  6156
         setXPathHandler( defaultHandler );
 82  6156
     }
 83  
 
 84  
     public void setXPathHandler(XPathHandler handler)
 85  
     {
 86  12310
         this.handler = handler;
 87  12310
     }
 88  
 
 89  
     public XPathHandler getXPathHandler()
 90  
     {
 91  188328
         return this.handler;
 92  
     }
 93  
 
 94  
     public void parse(String xpath) throws SAXPathException
 95  
     {
 96  6236
         setUpParse( xpath );
 97  
 
 98  6236
         getXPathHandler().startXPath();
 99  
 
 100  6236
         expr();
 101  
 
 102  6142
         getXPathHandler().endXPath();
 103  
 
 104  6142
         if ( LA(1) != TokenTypes.EOF )
 105  
         {
 106  18
             XPathSyntaxException ex = createSyntaxException( "Unexpected '" + LT(1).getTokenText() + "'" );
 107  18
             throw ex;
 108  
         }
 109  
 
 110  6124
         lexer  = null;
 111  6124
         tokens = null;
 112  6124
     }
 113  
 
 114  
     void setUpParse(String xpath)
 115  
     {
 116  6236
         this.tokens = new ArrayList();
 117  6236
         this.lexer = new XPathLexer( xpath );
 118  6236
     }
 119  
 
 120  
     private void pathExpr() throws SAXPathException
 121  
     {
 122  14974
         getXPathHandler().startPathExpr();
 123  
 
 124  14974
         switch ( LA(1) )
 125  
         {
 126  
             case TokenTypes.DOUBLE:
 127  
             case TokenTypes.LITERAL:
 128  
             {
 129  5364
                 filterExpr();
 130  
 
 131  5364
                 if ( LA(1) == TokenTypes.SLASH || LA(1) == TokenTypes.DOUBLE_SLASH )
 132  
                 {
 133  2
                     XPathSyntaxException ex = createSyntaxException("Node-set expected");
 134  2
                     throw ex;
 135  
                 }
 136  
 
 137  
                 break;
 138  
             }                
 139  
             case TokenTypes.LEFT_PAREN:
 140  
             case TokenTypes.DOLLAR:
 141  
             {
 142  1496
                 filterExpr();
 143  
                     
 144  1486
                 if ( LA(1) == TokenTypes.SLASH || LA(1) == TokenTypes.DOUBLE_SLASH)
 145  
                 {
 146  14
                     locationPath( false );
 147  14
                 }
 148  
                 break;
 149  
             }
 150  
             case TokenTypes.IDENTIFIER:
 151  
             {
 152  
 
 153  4376
                 if ( ( LA(2) == TokenTypes.LEFT_PAREN
 154  
                      &&
 155  
                        ! isNodeTypeName( LT(1) ) )
 156  
                      ||
 157  
                     ( LA(2) == TokenTypes.COLON
 158  
                       &&
 159  
                       LA(4) == TokenTypes.LEFT_PAREN) ) 
 160  
                 {
 161  2644
                     filterExpr();
 162  
                     
 163  2636
                     if ( LA(1) == TokenTypes.SLASH || LA(1) == TokenTypes.DOUBLE_SLASH)
 164  
                     {
 165  100
                         locationPath( false );
 166  96
                     }
 167  
                 }
 168  
                 else
 169  
                 {
 170  1732
                     locationPath( false );
 171  
                 }
 172  1720
                 break;
 173  
             }
 174  
             case TokenTypes.DOT:
 175  
             case TokenTypes.DOT_DOT:
 176  
             case TokenTypes.STAR:
 177  
             case TokenTypes.AT:
 178  
             {
 179  554
                 locationPath( false );
 180  554
                 break;
 181  
             }
 182  
             case TokenTypes.SLASH:
 183  
             case TokenTypes.DOUBLE_SLASH:
 184  
             {
 185  3166
                 locationPath( true );
 186  3116
                 break;
 187  
             }
 188  
             default:
 189  
             {
 190  18
                 XPathSyntaxException ex = createSyntaxException( "Unexpected '" + LT(1).getTokenText() + "'" );
 191  18
                 throw ex;
 192  
             }
 193  
         }
 194  
 
 195  14870
         getXPathHandler().endPathExpr();
 196  14870
     }
 197  
 
 198  
     private void literal() throws SAXPathException
 199  
     {
 200  2210
         Token token = match( TokenTypes.LITERAL );
 201  
 
 202  2210
         getXPathHandler().literal( token.getTokenText() );
 203  2210
     }
 204  
 
 205  
     private void functionCall() throws SAXPathException
 206  
     {
 207  2644
         String prefix       = null;
 208  2644
         String functionName = null;
 209  
 
 210  2644
         if ( LA(2) == TokenTypes.COLON )
 211  
         {
 212  4
             prefix = match( TokenTypes.IDENTIFIER ).getTokenText();
 213  4
             match( TokenTypes.COLON );
 214  4
         }
 215  
         else
 216  
         {
 217  2640
             prefix = "";
 218  
         }
 219  
 
 220  2644
         functionName = match( TokenTypes.IDENTIFIER ).getTokenText();
 221  
 
 222  2644
         getXPathHandler().startFunction( prefix,
 223  
                                          functionName );
 224  
 
 225  2644
         match ( TokenTypes.LEFT_PAREN );
 226  
 
 227  2644
         arguments();
 228  
 
 229  2636
         match ( TokenTypes.RIGHT_PAREN );
 230  
 
 231  2636
         getXPathHandler().endFunction();
 232  2636
     }
 233  
 
 234  
     private void arguments() throws SAXPathException
 235  
     {
 236  3670
         while ( LA(1) != TokenTypes.RIGHT_PAREN )
 237  
         {
 238  3030
             expr();
 239  
 
 240  3022
             if ( LA(1) == TokenTypes.COMMA )
 241  
             {
 242  1026
                 match( TokenTypes.COMMA );
 243  1026
             }
 244  
             else
 245  
             {
 246  
                 break;
 247  
             }
 248  
         }
 249  2636
     }
 250  
 
 251  
     private void filterExpr() throws SAXPathException
 252  
     {
 253  
 
 254  9504
         getXPathHandler().startFilterExpr();
 255  
 
 256  9504
         switch ( LA(1) )
 257  
         {
 258  
             case TokenTypes.DOUBLE:
 259  
             {
 260  3154
                 Token token = match( TokenTypes.DOUBLE );
 261  
                 
 262  3154
                 getXPathHandler().number( Double.parseDouble( token.getTokenText() ) );
 263  3154
                 break;
 264  
             }
 265  
             case TokenTypes.LITERAL:
 266  
             {
 267  2210
                 literal();
 268  2210
                 break;
 269  
             }
 270  
             case TokenTypes.LEFT_PAREN:
 271  
             {
 272  1414
                 match( TokenTypes.LEFT_PAREN );
 273  1414
                 expr();
 274  1414
                 match( TokenTypes.RIGHT_PAREN );
 275  1404
                 break;
 276  
             }
 277  
             case TokenTypes.IDENTIFIER:
 278  
             {
 279  2644
                 functionCall();
 280  2636
                 break;
 281  
             }
 282  
             case TokenTypes.DOLLAR:
 283  
             {
 284  82
                 variableReference();
 285  
                 break;
 286  
             }
 287  
         }
 288  
 
 289  9486
         predicates();
 290  
 
 291  9486
         getXPathHandler().endFilterExpr();
 292  9486
     }
 293  
 
 294  
     private void variableReference() throws SAXPathException
 295  
     {
 296  82
         match( TokenTypes.DOLLAR );
 297  
 
 298  82
         String prefix       = null;
 299  82
         String variableName = null;
 300  
 
 301  82
         if ( LA(2) == TokenTypes.COLON )
 302  
         {
 303  2
             prefix = match( TokenTypes.IDENTIFIER ).getTokenText();
 304  2
             match( TokenTypes.COLON );
 305  2
         }
 306  
         else
 307  
         {
 308  80
             prefix = "";
 309  
         }
 310  
 
 311  82
         variableName = match( TokenTypes.IDENTIFIER ).getTokenText();
 312  
 
 313  82
         getXPathHandler().variableReference( prefix,
 314  
                                              variableName );
 315  82
     }
 316  
 
 317  
     void locationPath(boolean isAbsolute) throws SAXPathException
 318  
     {
 319  5566
         switch ( LA(1) )
 320  
         {
 321  
             case TokenTypes.SLASH:
 322  
             case TokenTypes.DOUBLE_SLASH:
 323  
             {
 324  3280
                 if ( isAbsolute )
 325  
                 {
 326  3166
                     absoluteLocationPath();
 327  3116
                 }
 328  
                 else
 329  
                 {
 330  114
                     relativeLocationPath();
 331  
                 }
 332  110
                 break;
 333  
             }
 334  
             case TokenTypes.AT:
 335  
             case TokenTypes.IDENTIFIER:
 336  
             case TokenTypes.DOT:
 337  
             case TokenTypes.DOT_DOT:
 338  
             case TokenTypes.STAR:
 339  
             {
 340  2286
                 relativeLocationPath();
 341  2274
                 break;
 342  
             }
 343  
             default:
 344  
             {
 345  0
                 XPathSyntaxException ex = createSyntaxException( "Unexpected '" + LT(1).getTokenText() + "'" );
 346  0
                 throw ex;
 347  
             }
 348  
         }
 349  5500
     }
 350  
 
 351  
     private void absoluteLocationPath() throws SAXPathException
 352  
     {
 353  3166
         getXPathHandler().startAbsoluteLocationPath();
 354  
 
 355  3166
         switch ( LA(1) )
 356  
         {
 357  
             case TokenTypes.SLASH:
 358  
             {
 359  2810
                 match( TokenTypes.SLASH );
 360  
 
 361  2810
                 switch ( LA(1) )
 362  
                 {
 363  
 
 364  
                     case TokenTypes.DOT:
 365  
                     case TokenTypes.DOT_DOT:
 366  
                     case TokenTypes.AT:
 367  
                     case TokenTypes.IDENTIFIER:
 368  
                     case TokenTypes.STAR:
 369  
                     {
 370  2470
                         steps();
 371  
                         break;
 372  
                     }
 373  
                 }
 374  2770
                 break;
 375  
             }
 376  
             case TokenTypes.DOUBLE_SLASH:
 377  
             {
 378  356
                 getXPathHandler().startAllNodeStep( Axis.DESCENDANT_OR_SELF );
 379  356
                 getXPathHandler().endAllNodeStep();
 380  
 
 381  356
                 match( TokenTypes.DOUBLE_SLASH );
 382  356
                 switch ( LA(1) )
 383  
                 {
 384  
                     case TokenTypes.DOT:
 385  
                     case TokenTypes.DOT_DOT:
 386  
                     case TokenTypes.AT:
 387  
                     case TokenTypes.IDENTIFIER:
 388  
                     case TokenTypes.STAR:
 389  
                     {
 390  346
                         steps();
 391  346
                         break;
 392  
                     }
 393  
                     default:
 394  10
                         XPathSyntaxException ex = this.createSyntaxException("Location path cannot end with //");
 395  10
                         throw ex;
 396  
                 }
 397  
                 break;
 398  
             }
 399  
         }
 400  
         
 401  3116
         getXPathHandler().endAbsoluteLocationPath();
 402  3116
     }
 403  
 
 404  
     private void relativeLocationPath() throws SAXPathException
 405  
     {
 406  2400
         getXPathHandler().startRelativeLocationPath();
 407  
 
 408  2400
         switch ( LA(1) )
 409  
         {
 410  
             case TokenTypes.SLASH:
 411  
             {
 412  114
                 match( TokenTypes.SLASH );
 413  114
                 break;
 414  
             }
 415  
             case TokenTypes.DOUBLE_SLASH:
 416  
             {
 417  0
                 getXPathHandler().startAllNodeStep( Axis.DESCENDANT_OR_SELF );
 418  0
                 getXPathHandler().endAllNodeStep();
 419  
 
 420  0
                 match( TokenTypes.DOUBLE_SLASH );
 421  
 
 422  
                 break;
 423  
             }
 424  
         }
 425  
 
 426  2400
         steps();
 427  
 
 428  2384
         getXPathHandler().endRelativeLocationPath();
 429  2384
     }
 430  
 
 431  
     private void steps() throws SAXPathException
 432  
     {
 433  5216
         switch ( LA(1) )
 434  
         {
 435  
 
 436  
             case TokenTypes.DOT:
 437  
             case TokenTypes.DOT_DOT:
 438  
             case TokenTypes.AT:
 439  
             case TokenTypes.IDENTIFIER:
 440  
             case TokenTypes.STAR:
 441  
             {
 442  5212
                 step();
 443  5200
                 break;
 444  
             }
 445  
             case TokenTypes.EOF:
 446  
             {
 447  0
                 return;
 448  
             }
 449  
             default:
 450  
             {
 451  4
                 XPathSyntaxException ex = createSyntaxException( "Expected one of '.', '..', '@', '*', <QName>" );
 452  4
                 throw ex;
 453  
             }
 454  
         }
 455  
 
 456  
         do
 457  
         {
 458  8872
             if ( ( LA(1) == TokenTypes.SLASH)
 459  
                  ||
 460  
                  ( LA(1) == TokenTypes.DOUBLE_SLASH ) )
 461  
             {
 462  3712
                 switch ( LA(1) )
 463  
                 {
 464  
                     case TokenTypes.SLASH:
 465  
                     {
 466  3688
                         match( TokenTypes.SLASH );
 467  3688
                         break;
 468  
                     }
 469  
                     case TokenTypes.DOUBLE_SLASH:
 470  
                     {
 471  24
                         getXPathHandler().startAllNodeStep( Axis.DESCENDANT_OR_SELF );
 472  24
                         getXPathHandler().endAllNodeStep();
 473  
 
 474  24
                         match( TokenTypes.DOUBLE_SLASH );
 475  
                         break;
 476  
                     }
 477  
                 }
 478  3712
             }
 479  
             else
 480  
             {
 481  5160
                 return;
 482  
             }
 483  
             
 484  3712
             switch ( LA(1) )
 485  
             {
 486  
                 case TokenTypes.DOT:
 487  
                 case TokenTypes.DOT_DOT:
 488  
                 case TokenTypes.AT:
 489  
                 case TokenTypes.IDENTIFIER:
 490  
                 case TokenTypes.STAR:
 491  
                 {
 492  3704
                     step();
 493  3672
                     break;
 494  
                 }
 495  
                 default:
 496  
                 {
 497  8
                     XPathSyntaxException ex = createSyntaxException( "Expected one of '.', '..', '@', '*', <QName>" );
 498  8
                     throw ex;
 499  
                 }
 500  
             }
 501  
 
 502  
         } while ( true );
 503  
     }
 504  
 
 505  
     void step() throws SAXPathException
 506  
     {
 507  8916
         int axis = 0;
 508  
 
 509  8916
         switch ( LA(1) )
 510  
         {
 511  
             case TokenTypes.DOT:
 512  
             case TokenTypes.DOT_DOT:
 513  
             {
 514  222
                 abbrStep();
 515  222
                 return;
 516  
             }
 517  
             case TokenTypes.AT:
 518  
             {
 519  438
                 axis = axisSpecifier();
 520  438
                 break;
 521  
             }
 522  
             case TokenTypes.IDENTIFIER:
 523  
             {
 524  7782
                 if ( LA(2) == TokenTypes.DOUBLE_COLON )
 525  
                 {
 526  4626
                     axis = axisSpecifier();
 527  4622
                 }
 528  
                 else
 529  
                 {
 530  3156
                     axis = Axis.CHILD;
 531  
                 }
 532  3156
                 break;
 533  
             }
 534  
             case TokenTypes.STAR:
 535  
             {
 536  474
                 axis = Axis.CHILD;
 537  
                 break;
 538  
             }
 539  
         }
 540  
 
 541  8690
         nodeTest( axis );
 542  8650
     }
 543  
 
 544  
     private int axisSpecifier() throws SAXPathException
 545  
     {
 546  5064
         int axis = 0;
 547  
 
 548  5064
         switch ( LA(1) )
 549  
         {
 550  
             case TokenTypes.AT:
 551  
             {
 552  438
                 match( TokenTypes.AT );
 553  438
                 axis = Axis.ATTRIBUTE;
 554  438
                 break;
 555  
             }
 556  
             case TokenTypes.IDENTIFIER:
 557  
             {
 558  4626
                 Token token = LT( 1 );
 559  
 
 560  4626
                 axis = Axis.lookup( token.getTokenText() );
 561  
 
 562  4626
                 if ( axis == Axis.INVALID_AXIS )
 563  
                 {
 564  4
                     throwInvalidAxis( token.getTokenText() );
 565  
                 }
 566  
 
 567  4622
                 match( TokenTypes.IDENTIFIER );
 568  4622
                 match( TokenTypes.DOUBLE_COLON );
 569  
 
 570  4622
                 break;
 571  
             }
 572  
         }
 573  
 
 574  5060
         return axis;
 575  
     }
 576  
 
 577  
     private void nodeTest(int axis) throws SAXPathException
 578  
     {
 579  8690
         switch ( LA(1) )
 580  
         {
 581  
             case TokenTypes.IDENTIFIER:
 582  
             {
 583  7172
                 switch ( LA(2) )
 584  
                 {
 585  
                     case TokenTypes.LEFT_PAREN:
 586  
                     {
 587  1072
                         nodeTypeTest( axis );
 588  1068
                         break;
 589  
                     }
 590  
                     default:
 591  
                     {
 592  6100
                         nameTest( axis );
 593  6080
                         break;
 594  
                     }
 595  
                 }
 596  
                 break;
 597  
             }
 598  
             case TokenTypes.STAR:
 599  
             {
 600  1502
                 nameTest( axis );
 601  1502
                 break;
 602  
             }
 603  
             default:
 604  16
                 XPathSyntaxException ex = createSyntaxException("Expected <QName> or *");
 605  16
                 throw ex;
 606  
         }
 607  8650
     }
 608  
 
 609  
     private void nodeTypeTest(int axis) throws SAXPathException
 610  
     {
 611  1072
         Token  nodeTypeToken = match( TokenTypes.IDENTIFIER );
 612  1072
         String nodeType      = nodeTypeToken.getTokenText();
 613  
 
 614  1072
         match( TokenTypes.LEFT_PAREN );
 615  
 
 616  1072
         if ( "processing-instruction".equals( nodeType ) )
 617  
         {
 618  140
             String piName = "";
 619  
 
 620  140
             if ( LA(1) == TokenTypes.LITERAL )
 621  
             {
 622  36
                 piName = match( TokenTypes.LITERAL ).getTokenText();
 623  
             }
 624  
 
 625  140
             match( TokenTypes.RIGHT_PAREN );
 626  
 
 627  140
             getXPathHandler().startProcessingInstructionNodeStep( axis,
 628  
                                                                   piName );
 629  
 
 630  140
             predicates();
 631  
 
 632  140
             getXPathHandler().endProcessingInstructionNodeStep();
 633  140
         }
 634  932
         else if ( "node".equals( nodeType ) )
 635  
         {
 636  682
             match( TokenTypes.RIGHT_PAREN );
 637  
 
 638  682
             getXPathHandler().startAllNodeStep( axis );
 639  
 
 640  682
             predicates();
 641  
 
 642  682
             getXPathHandler().endAllNodeStep();
 643  682
         }
 644  250
         else if ( "text".equals( nodeType ) )
 645  
         {
 646  156
             match( TokenTypes.RIGHT_PAREN );
 647  
 
 648  156
             getXPathHandler().startTextNodeStep( axis );
 649  
 
 650  156
             predicates();
 651  
 
 652  156
             getXPathHandler().endTextNodeStep();
 653  156
         }
 654  94
         else if ( "comment".equals( nodeType ) )
 655  
         {
 656  90
             match( TokenTypes.RIGHT_PAREN );
 657  
 
 658  90
             getXPathHandler().startCommentNodeStep( axis );
 659  
 
 660  90
             predicates();
 661  
 
 662  90
             getXPathHandler().endCommentNodeStep();
 663  90
         }
 664  
         else
 665  
         {
 666  4
             XPathSyntaxException ex = createSyntaxException( "Expected node-type" );
 667  4
             throw ex;
 668  
         }
 669  1068
     }
 670  
 
 671  
     private void nameTest(int axis) throws SAXPathException
 672  
     {
 673  7602
         String prefix    = null;
 674  7602
         String localName = null;
 675  
 
 676  7602
         switch ( LA(2) )
 677  
         {
 678  
             case TokenTypes.COLON:
 679  
             {
 680  336
                 switch ( LA(1) )
 681  
                 {
 682  
                     case TokenTypes.IDENTIFIER:
 683  
                     {
 684  334
                         prefix = match( TokenTypes.IDENTIFIER ).getTokenText();
 685  334
                         match( TokenTypes.COLON );
 686  
                         break;
 687  
                     }
 688  
                 }
 689  
                 break;
 690  
             }
 691  
         }
 692  
         
 693  7602
         switch ( LA(1) )
 694  
         {
 695  
             case TokenTypes.IDENTIFIER:
 696  
             {
 697  6096
                 localName = match( TokenTypes.IDENTIFIER ).getTokenText();
 698  6096
                 break;
 699  
             }
 700  
             case TokenTypes.STAR:
 701  
             {
 702  1506
                 match( TokenTypes.STAR );
 703  1506
                 localName = "*";
 704  
                 break;
 705  
             }
 706  
         }
 707  
 
 708  7602
         if ( prefix == null )
 709  
         {
 710  7268
             prefix = "";
 711  
         }
 712  
         
 713  7602
         getXPathHandler().startNameStep( axis,
 714  
                                          prefix,
 715  
                                          localName );
 716  
 
 717  7602
         predicates();
 718  
 
 719  7582
         getXPathHandler().endNameStep();
 720  7582
     }
 721  
 
 722  
     private void abbrStep() throws SAXPathException
 723  
     {
 724  222
         switch ( LA(1) )
 725  
         {
 726  
             case TokenTypes.DOT:
 727  
             {
 728  156
                 match( TokenTypes.DOT );
 729  156
                 getXPathHandler().startAllNodeStep( Axis.SELF );
 730  156
                 predicates();
 731  156
                 getXPathHandler().endAllNodeStep();