You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mi...@apache.org on 2005/07/15 18:50:24 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/compiler Parser.java

minchau     2005/07/15 09:50:24

  Modified:    java/src/org/apache/xalan/xsltc/compiler Parser.java
  Log:
  Fixing a NPE for when _locator is null in the XSLTC Parser.
  Applyin the patch in XALANJ-2154 from Brian Minchau, reiwed and approved by Santiago P.G.
  
  Revision  Changes    Path
  1.70      +20 -10    xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- Parser.java	8 Jun 2005 13:10:08 -0000	1.69
  +++ Parser.java	15 Jul 2005 16:50:24 -0000	1.70
  @@ -273,7 +273,7 @@
   	    if (prefix.equals(XMLNS_PREFIX) == false) {
   		namespace = _symbolTable.lookupNamespace(prefix);
   		if (namespace == null && reportError) {
  -		    final int line = _locator.getLineNumber();
  +		    final int line = getLineNumber();
   		    ErrorMsg err = new ErrorMsg(ErrorMsg.NAMESPACE_UNDEF_ERR,
   						line, prefix);
   		    reportError(ERROR, err);
  @@ -384,7 +384,7 @@
   		while (elements.hasMoreElements()) {
   		    Object child = elements.nextElement();
   		    if (child instanceof Text) {
  -			final int l = _locator.getLineNumber();
  +			final int l = getLineNumber();
   			ErrorMsg err =
   			    new ErrorMsg(ErrorMsg.ILLEGAL_TEXT_NODE_ERR,l,null);
   			reportError(ERROR, err);
  @@ -920,7 +920,7 @@
   		node.setQName(qname);
   		node.setParser(this);
   		if (_locator != null) {
  -		    node.setLineNumber(_locator.getLineNumber());
  +		    node.setLineNumber(getLineNumber());
   		}
   		if (node instanceof Stylesheet) {
   		    _xsltc.setStylesheet((Stylesheet)node);
  @@ -944,7 +944,7 @@
   		    node = new UnsupportedElement(uri, prefix, local, false);
   		    UnsupportedElement element = (UnsupportedElement)node;
   		    ErrorMsg msg = new ErrorMsg(ErrorMsg.UNSUPPORTED_XSL_ERR,
  -						_locator.getLineNumber(),local);
  +						getLineNumber(),local);
   		    element.setErrorMessage(msg);
   		    if (versionIsOne) {
   		    	reportError(UNSUPPORTED,msg);
  @@ -955,7 +955,7 @@
   		    node = new UnsupportedElement(uri, prefix, local, true);
   		    UnsupportedElement element = (UnsupportedElement)node;
   		    ErrorMsg msg = new ErrorMsg(ErrorMsg.UNSUPPORTED_EXT_ERR,
  -						_locator.getLineNumber(),local);
  +						getLineNumber(),local);
   		    element.setErrorMessage(msg);
   		}
   		// Check if this is an extension of some other XSLT processor
  @@ -967,7 +967,7 @@
   			    UnsupportedElement elem = (UnsupportedElement)node;
   			    ErrorMsg msg =
   				new ErrorMsg(ErrorMsg.UNSUPPORTED_EXT_ERR,
  -					     _locator.getLineNumber(),
  +					     getLineNumber(),
   					     prefix+":"+local);
   			    elem.setErrorMessage(msg);
   			}
  @@ -976,7 +976,7 @@
   	    }
   	    if (node == null) {
                   node = new LiteralElement();
  -                node.setLineNumber(_locator.getLineNumber());
  +                node.setLineNumber(getLineNumber());
               }
   	}
   	if ((node != null) && (node instanceof LiteralElement)) {
  @@ -1084,8 +1084,7 @@
        */
       private SyntaxTreeNode parseTopLevel(SyntaxTreeNode parent, String text,
   					 String expression) {
  -	int line = 0;
  -	if (_locator != null) line = _locator.getLineNumber();
  +	int line = getLineNumber();
   
   	try {
   	    _xpathParser.setScanner(new XPathLexer(new StringReader(text)));
  @@ -1378,5 +1377,16 @@
       public void setDocumentLocator(Locator locator) {
   	_locator = locator;
       }
  +    
  +    /**
  +     * Get the line number, or zero
  +     * if there is no _locator.
  +     */
  +    private int getLineNumber() {
  +    	int line = 0;
  +    	if (_locator != null)
  +    		line = _locator.getLineNumber();
  +    	return line;
  +    }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org