You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2004/09/01 05:06:08 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs/util SimpleLocator.java

mrglavas    2004/08/31 20:06:08

  Modified:    java/src/org/apache/xerces/parsers AbstractSAXParser.java
               java/src/org/apache/xerces/impl XMLEntityScanner.java
                        XMLDTDScannerImpl.java XMLEntityManager.java
                        XMLDocumentFragmentScannerImpl.java
               java/src/org/apache/xerces/util ErrorHandlerWrapper.java
               java/src/org/apache/xerces/impl/xs/util SimpleLocator.java
  Log:
  Updating the implementation to work with the changes
  to XNI's XMLLocator. Implemented getXMLVersion in
  XMLEntityScanner and XMLEntityManager, propogating
  this to the SAX parser. Also removed some setter methods
  which have long been removed from the XMLLocator
  interface.
  
  Revision  Changes    Path
  1.57      +2 -2      xml-xerces/java/src/org/apache/xerces/parsers/AbstractSAXParser.java
  
  Index: AbstractSAXParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/AbstractSAXParser.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- AbstractSAXParser.java	22 Jul 2004 21:15:20 -0000	1.56
  +++ AbstractSAXParser.java	1 Sep 2004 03:06:07 -0000	1.57
  @@ -2231,7 +2231,7 @@
   
           // Locator2 methods
           public String getXMLVersion() {
  -            return fVersion;
  +            return fLocator.getXMLVersion();
           }
   
           public String getEncoding() {
  
  
  
  1.21      +66 -57    xml-xerces/java/src/org/apache/xerces/impl/XMLEntityScanner.java
  
  Index: XMLEntityScanner.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLEntityScanner.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- XMLEntityScanner.java	24 Feb 2004 23:03:46 -0000	1.20
  +++ XMLEntityScanner.java	1 Sep 2004 03:06:07 -0000	1.21
  @@ -153,6 +153,17 @@
           }
   
       } // setEncoding(String)
  +    
  +    /**
  +     * Sets the XML version. This method is used by the
  +     * scanners to report the value of the version pseudo-attribute
  +     * in an XML or text declaration.
  +     *
  +     * @param xmlVersion the XML version of the current entity
  +     */
  +    public void setXMLVersion(String xmlVersion) {
  +        fCurrentEntity.xmlVersion = xmlVersion;
  +    } // setXMLVersion(String)
   
       /** Returns true if the current entity being scanned is external. */
       public boolean isExternal() {
  @@ -1504,7 +1515,7 @@
       } // getLiteralSystemId():String
   
       /**
  -     * Return the line number where the current document event ends.
  +     * Returns the line number where the current document event ends.
        * <p>
        * <strong>Warning:</strong> The return value from the method
        * is intended only as an approximation for the sake of error
  @@ -1515,9 +1526,9 @@
        * in the document entity or external parsed entity where the
        * markup triggering the event appears.
        * <p>
  -     * If possible, the SAX driver should provide the line position
  -     * of the first character after the text associated with the document
  -     * event.  The first line in the document is line 1.
  +     * If possible, the line position of the first character after the 
  +     * text associated with the document event should be provided.
  +     * The first line in the document is line 1.
        *
        * @return The line number, or -1 if none is available.
        */
  @@ -1537,7 +1548,7 @@
       } // getLineNumber():int
   
       /**
  -     * Return the column number where the current document event ends.
  +     * Returns the column number where the current document event ends.
        * <p>
        * <strong>Warning:</strong> The return value from the method
        * is intended only as an approximation for the sake of error
  @@ -1548,13 +1559,9 @@
        * in the document entity or external parsed entity where the
        * markup triggering the event appears.
        * <p>
  -     * If possible, the SAX driver should provide the line position
  -     * of the first character after the text associated with the document
  -     * event.
  -     * <p>
  -     * If possible, the SAX driver should provide the line position
  -     * of the first character after the text associated with the document
  -     * event.  The first column in each line is column 1.
  +     * If possible, the line position of the first character after the 
  +     * text associated with the document event should be provided.
  +     * The first column in each line is column 1.
        *
        * @return The column number, or -1 if none is available.
        */
  @@ -1572,7 +1579,30 @@
           return -1;
       } // getColumnNumber():int
       
  -    /** Returns the encoding of the current entity.  
  +    /**
  +     * Returns the character offset where the current document event ends.
  +     * <p>
  +     * <strong>Warning:</strong> The return value from the method
  +     * is intended only as an approximation for the sake of error
  +     * reporting; it is not intended to provide sufficient information
  +     * to edit the character content of the original XML document.
  +     * <p>
  +     * The return value is an approximation of the character offset
  +     * in the document entity or external parsed entity where the
  +     * markup triggering the event appears.
  +     * <p>
  +     * If possible, the character offset of the first character after the 
  +     * text associated with the document event should be provided.
  +     *
  +     * @return The character offset, or -1 if none is available.
  +     */
  +    public int getCharacterOffset() {
  +        /** TODO: Implement this method. **/
  +        return -1;
  +    } // getCharacterOffset():int
  +    
  +    /** 
  +     * Returns the encoding of the current entity.  
        * Note that, for a given entity, this value can only be
        * considered final once the encoding declaration has been read (or once it
        * has been determined that there is no such declaration) since, no encoding
  @@ -1585,56 +1615,35 @@
                   return fCurrentEntity.encoding;
               }
               else {
  -                // ask current entity to find appropriate column number
  +                // ask current entity to find appropriate encoding
                   return fCurrentEntity.getEncoding();
               }
           }
  -
           return null;
       } // getEncoding():String
       
  -    /**
  -     * @see org.apache.xerces.xni.XMLLocator#setColumnNumber(int)
  +    /** 
  +     * Returns the XML version of the current entity. This will normally be the
  +     * value from the XML or text declaration or defaulted by the parser. Note that
  +     * that this value may be different than the version of the processing rules 
  +     * applied to the current entity. For instance, an XML 1.1 document may refer to
  +     * XML 1.0 entities. In such a case the rules of XML 1.1 are applied to the entire 
  +     * document. Also note that, for a given entity, this value can only be considered
  +     * final once the XML or text declaration has been read or once it has been
  +     * determined that there is no such declaration.
        */
  -    public void setColumnNumber(int col) {
  -        // no-op
  -    }
  -
  -    /**
  -     * @see org.apache.xerces.xni.XMLLocator#setLineNumber(int)
  -     */
  -    public void setLineNumber(int line) {
  -        //no-op
  -    }
  -    
  -        /**
  -     * @see org.apache.xerces.xni.XMLResourceIdentifier#setBaseSystemId(String)
  -     */
  -    public void setBaseSystemId(String systemId) {        
  -        //no-op
  -    }
  -
  -
  -    /**
  -     * @see org.apache.xerces.xni.XMLResourceIdentifier#setExpandedSystemId(String)
  -     */
  -    public void setExpandedSystemId(String systemId) {
  -        //no-op
  -    }
  -
  -    /**
  -     * @see org.apache.xerces.xni.XMLResourceIdentifier#setLiteralSystemId(String)
  -     */
  -    public void setLiteralSystemId(String systemId) {
  -        //no-op
  -    }
  -
  -    /**
  -     * @see org.apache.xerces.xni.XMLResourceIdentifier#setPublicId(String)
  -     */
  -    public void setPublicId(String publicId) {
  -        //no-op
  -    }
  +    public String getXMLVersion() {
  +        if (fCurrentEntity != null) {
  +            if (fCurrentEntity.isExternal()) {
  +                return fCurrentEntity.xmlVersion;
  +            }
  +            else {
  +                // ask current entity to find the appropriate XML version
  +                return fCurrentEntity.getXMLVersion();
  +            }
  +        }
  +        return null;
  +    } // getXMLVersion():String
   
       // allow entity manager to tell us what the current entityis:
       public void setCurrentEntity(XMLEntityManager.ScannedEntity ent) {
  
  
  
  1.50      +2 -1      xml-xerces/java/src/org/apache/xerces/impl/XMLDTDScannerImpl.java
  
  Index: XMLDTDScannerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDTDScannerImpl.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- XMLDTDScannerImpl.java	27 Feb 2004 20:36:07 -0000	1.49
  +++ XMLDTDScannerImpl.java	1 Sep 2004 03:06:07 -0000	1.50
  @@ -705,6 +705,7 @@
                   version = fStrings[0];
                   encoding = fStrings[1];
   
  +                fEntityScanner.setXMLVersion(version);
                   fEntityScanner.setEncoding(encoding);
   
                   // call handler
  
  
  
  1.82      +22 -4     xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java
  
  Index: XMLEntityManager.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- XMLEntityManager.java	9 Jul 2004 03:01:58 -0000	1.81
  +++ XMLEntityManager.java	1 Sep 2004 03:06:07 -0000	1.82
  @@ -2310,9 +2310,14 @@
   
           /** Auto-detected encoding. */
           public String encoding;
  -
  -		/** Encoding has been set externally for eg: using DOMInput*/
  -		boolean declaredEncoding = false;
  +        
  +        /** Encoding has been set externally for eg: using DOMInput*/
  +        boolean declaredEncoding = false;
  +        
  +        // version
  +        
  +        /** XML version. **/
  +        public String xmlVersion = "1.0";
           
   		// status
   
  @@ -2446,6 +2451,19 @@
                  ScannedEntity firstExternalEntity = (ScannedEntity)fEntityStack.elementAt(i);
                   if (firstExternalEntity.isExternal()) {
                       return firstExternalEntity.encoding;
  +                }
  +            }
  +            return null;
  +        }
  +        
  +        // return xml version of most recent external entity
  +        public String getXMLVersion() {
  +            // search for the first external entity on the stack
  +            int size = fEntityStack.size();
  +            for (int i=size-1; i>0 ; i--) {
  +               ScannedEntity firstExternalEntity = (ScannedEntity)fEntityStack.elementAt(i);
  +                if (firstExternalEntity.isExternal()) {
  +                    return firstExternalEntity.xmlVersion;
                   }
               }
               return null;
  
  
  
  1.56      +4 -1      xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java
  
  Index: XMLDocumentFragmentScannerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- XMLDocumentFragmentScannerImpl.java	12 Aug 2004 18:24:56 -0000	1.55
  +++ XMLDocumentFragmentScannerImpl.java	1 Sep 2004 03:06:08 -0000	1.56
  @@ -665,6 +665,9 @@
           // set standalone
           fStandalone = standalone != null && standalone.equals("yes");
           fEntityManager.setStandalone(fStandalone);
  +        
  +        // set version on reader
  +        fEntityScanner.setXMLVersion(version);
   
           // call handler
           if (fDocumentHandler != null) {
  
  
  
  1.12      +3 -7      xml-xerces/java/src/org/apache/xerces/util/ErrorHandlerWrapper.java
  
  Index: ErrorHandlerWrapper.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/util/ErrorHandlerWrapper.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ErrorHandlerWrapper.java	24 Feb 2004 23:15:53 -0000	1.11
  +++ ErrorHandlerWrapper.java	1 Sep 2004 03:06:08 -0000	1.12
  @@ -207,19 +207,15 @@
           final int fLineNumber = exception.getLineNumber();
           final int fColumnNumber = exception.getColumnNumber();
           XMLLocator location = new XMLLocator() {
  -            public void setPublicId(String id) {}
               public String getPublicId() { return fPublicId; }
  -            public void setExpandedSystemId( String id) {}
               public String getExpandedSystemId() { return fExpandedSystemId; }
  -            public void setBaseSystemId(String id) {}
               public String getBaseSystemId() { return null; }
  -            public void setLiteralSystemId(String id) {}
               public String getLiteralSystemId() { return null; }
               public int getColumnNumber() { return fColumnNumber; }
  -            public void setColumnNumber(int col) {}
               public int getLineNumber() { return fLineNumber; }
  -            public void setLineNumber(int line) {}
  +            public int getCharacterOffset() { return -1; }
               public String getEncoding() { return null; }
  +            public String getXMLVersion() { return null; }
           };
           return new XMLParseException(location, exception.getMessage(),exception);
       } // createXMLParseException(SAXParseException):XMLParseException
  
  
  
  1.5       +9 -1      xml-xerces/java/src/org/apache/xerces/impl/xs/util/SimpleLocator.java
  
  Index: SimpleLocator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/util/SimpleLocator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleLocator.java	24 Feb 2004 22:59:13 -0000	1.4
  +++ SimpleLocator.java	1 Sep 2004 03:06:08 -0000	1.5
  @@ -52,6 +52,10 @@
       public int getColumnNumber() {
           return column;
       }
  +    
  +    public int getCharacterOffset() {
  +        return -1;
  +    }
   
       public String getPublicId() {
           return null;
  @@ -113,6 +117,10 @@
        * with encoding information.
        */
       public String getEncoding() {
  +        return null;
  +    }
  +    
  +    public String getXMLVersion() {
           return null;
       }
   
  
  
  

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