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/22 06:19:34 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl XMLDTDScannerImpl.java XMLEntityManager.java XMLDocumentFragmentScannerImpl.java

mrglavas    2004/09/21 21:19:34

  Modified:    java/src/org/apache/xerces/impl XMLDTDScannerImpl.java
                        XMLEntityManager.java
                        XMLDocumentFragmentScannerImpl.java
  Log:
  Fixing JIRA Bug #816:
  http://nagoya.apache.org/jira/browse/XERCESJ-816
  
  This had only been partially fixed. A value for the encoding
  attribute specified on an LSInput is authoritative, meaning
  it will override any encoding in an XML or Text declaration.
  Should be covering all of these cases now. Renamed some
  methods in XMLEntityManager.ScannedEntity so that their
  names are more descriptive of what they actually do.
  
  Revision  Changes    Path
  1.51      +4 -2      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.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- XMLDTDScannerImpl.java	1 Sep 2004 03:06:07 -0000	1.50
  +++ XMLDTDScannerImpl.java	22 Sep 2004 04:19:33 -0000	1.51
  @@ -706,7 +706,9 @@
                   encoding = fStrings[1];
   
                   fEntityScanner.setXMLVersion(version);
  -                fEntityScanner.setEncoding(encoding);
  +                if (!fEntityScanner.fCurrentEntity.isEncodingExternallySpecified()) {
  +                    fEntityScanner.setEncoding(encoding);
  +                }
   
                   // call handler
                   if (fDTDHandler != null) {
  
  
  
  1.85      +18 -15    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.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- XMLEntityManager.java	21 Sep 2004 21:22:33 -0000	1.84
  +++ XMLEntityManager.java	22 Sep 2004 04:19:33 -0000	1.85
  @@ -907,8 +907,8 @@
           String literalSystemId = xmlInputSource.getSystemId();
           String baseSystemId = xmlInputSource.getBaseSystemId();
           String encoding = xmlInputSource.getEncoding();
  +        final boolean encodingExternallySpecified = (encoding != null);
           Boolean isBigEndian = null;
  -		boolean declaredEncoding = false;
   
           // create reader
           InputStream stream = null;
  @@ -920,8 +920,6 @@
           }
           if (reader == null) {
               stream = xmlInputSource.getByteStream();
  -			if(stream != null && encoding != null)
  -				declaredEncoding = true;
               if (stream == null) {
                   URL location = new URL(expandedSystemId);
                   URLConnection connect = location.openConnection();
  @@ -1073,7 +1071,7 @@
           fCurrentEntity = new ScannedEntity(name,
                   new XMLResourceIdentifierImpl(publicId, literalSystemId, baseSystemId, expandedSystemId),
                   stream, reader, encoding, literal, false, isExternal);
  -		fCurrentEntity.setDeclaredEncoding(declaredEncoding);
  +		fCurrentEntity.setEncodingExternallySpecified(encodingExternallySpecified);
           fEntityScanner.setCurrentEntity(fCurrentEntity);
           fResourceIdentifier.setValues(publicId, literalSystemId, baseSystemId, expandedSystemId);
           return encoding;
  @@ -2317,8 +2315,11 @@
           /** Auto-detected encoding. */
           public String encoding;
           
  -        /** Encoding has been set externally for eg: using DOMInput*/
  -        boolean declaredEncoding = false;
  +        /** 
  +         * Encoding has been set externally, for example
  +         * using a SAX InputSource or a DOM LSInput.
  +         */
  +        boolean externallySpecifiedEncoding = false;
           
           // version
           
  @@ -2495,6 +2496,16 @@
               return null;
           }
           
  +        /** Returns whether the encoding of this entity was externally specified. **/
  +        public boolean isEncodingExternallySpecified() {
  +            return externallySpecifiedEncoding;
  +        }
  +        
  +        /** Sets whether the encoding of this entity was externally specified. **/
  +        public void setEncodingExternallySpecified(boolean value) {
  +            externallySpecifiedEncoding = value;
  +        }
  +        
           //
           // Object methods
           //
  @@ -2513,14 +2524,6 @@
               return str.toString();
               
           } // toString():String
  -		
  -		public boolean isDeclaredEncoding() {
  -			return declaredEncoding;
  -		}
  -		
  -		public void setDeclaredEncoding(boolean value) {
  -			declaredEncoding = value;
  -		}
   
       } // class ScannedEntity
   
  
  
  
  1.57      +2 -2      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.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- XMLDocumentFragmentScannerImpl.java	1 Sep 2004 03:06:08 -0000	1.56
  +++ XMLDocumentFragmentScannerImpl.java	22 Sep 2004 04:19:34 -0000	1.57
  @@ -680,7 +680,7 @@
           }
   
           // set encoding on reader
  -        if (encoding != null && !fEntityScanner.fCurrentEntity.isDeclaredEncoding()) {
  +        if (encoding != null && !fEntityScanner.fCurrentEntity.isEncodingExternallySpecified()) {
               fEntityScanner.setEncoding(encoding);
           }
   
  
  
  

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