mrglavas    2004/05/27 05:26:56

  Modified:    java/src/org/apache/xerces/util
                        DOMEntityResolverWrapper.java
               java/src/org/apache/xerces/impl/xs XMLSchemaLoader.java
  Log:
  Fixing a bug in DOMEntityResolverWrapper. The DOM Level 3 LS

  REC states that inputs specified in a LSInput are look at by a LSParser 

  in the following order to determine which will be used:

  

  1) LSInput.characterStream 

  2) LSInput.byteStream 

  3) LSInput.stringData 

  4) LSInput.systemId 

  5) LSInput.publicId

  

  String data was taking higher precedence over byte and character

  streams. Should be fixed now.

  

  Also patching XSLoader's implementation so that it's behaviour when

  reading an LSInput is consistent with what is required of a LSParser.
  
  Revision  Changes    Path
  1.13      +11 -6     
xml-xerces/java/src/org/apache/xerces/util/DOMEntityResolverWrapper.java
  
  Index: DOMEntityResolverWrapper.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/util/DOMEntityResolverWrapper.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DOMEntityResolverWrapper.java     25 Feb 2004 19:46:15 -0000      1.12
  +++ DOMEntityResolverWrapper.java     27 May 2004 12:26:56 -0000      1.13
  @@ -125,18 +125,23 @@
                   Reader charStream = inputSource.getCharacterStream();
                   String encoding = inputSource.getEncoding();
                   String data = inputSource.getStringData();
  +
  +                /**
  +                 * An LSParser looks at inputs specified in LSInput in
  +                 * the following order: characterStream, byteStream,
  +                 * stringData, systemId, publicId.
  +                 */          
                   XMLInputSource xmlInputSource =
                       new XMLInputSource(publicId, systemId, baseSystemId);
  -
  +                
                   if (charStream != null) {
                       xmlInputSource.setCharacterStream(charStream);
                   }
  -                if (byteStream != null) {
  +                else if (byteStream != null) {
                       xmlInputSource.setByteStream((InputStream) byteStream);
                   }
  -                if (data != null && data.length() != 0) {
  -                    xmlInputSource.setCharacterStream(
  -                        new StringReader(data));
  +                else if (data != null && data.length() != 0) {
  +                    xmlInputSource.setCharacterStream(new StringReader(data));
                   }
                   xmlInputSource.setEncoding(encoding);
                   return xmlInputSource;
  
  
  
  1.28      +25 -17    
xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
  
  Index: XMLSchemaLoader.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- XMLSchemaLoader.java      24 Feb 2004 22:59:11 -0000      1.27
  +++ XMLSchemaLoader.java      27 May 2004 12:26:56 -0000      1.28
  @@ -1219,30 +1219,38 @@
        private XMLInputSource dom2xmlInputSource(LSInput is) {
                // need to wrap the LSInput with an XMLInputSource
                XMLInputSource xis = null;
  -             // if there is a string data, use a StringReader
  -             // according to DOM, we need to treat such data as "UTF-16".
  -             if (is.getStringData() != null) {
  -                     xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
  -                                                                      
is.getBaseURI(), new StringReader(is.getStringData()),
  -                                                                      "UTF-16");
  -             }
  +        
  +             /**
  +              * An LSParser looks at inputs specified in LSInput in
  +              * the following order: characterStream, byteStream,
  +              * stringData, systemId, publicId. For consistency
  +              * have the same behaviour for XSLoader.
  +              */
  +             
                // check whether there is a Reader
                // according to DOM, we need to treat such reader as "UTF-16".
  -             else if (is.getCharacterStream() != null) {
  -                     xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
  -                                                                      
is.getBaseURI(), is.getCharacterStream(),
  -                                                                      "UTF-16");
  +             if (is.getCharacterStream() != null) {
  +                 xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
  +                                          is.getBaseURI(), is.getCharacterStream(),
  +                                          "UTF-16");
                }
                // check whether there is an InputStream
                else if (is.getByteStream() != null) {
  -                     xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
  -                                                                      
is.getBaseURI(), is.getByteStream(),
  -                                                                      
is.getEncoding());
  +                 xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
  +                                          is.getBaseURI(), is.getByteStream(),
  +                                          is.getEncoding());
  +             }
  +             // if there is a string data, use a StringReader
  +             // according to DOM, we need to treat such data as "UTF-16".
  +             else if (is.getStringData() != null && is.getStringData().length() != 
0) {
  +                 xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
  +                                          is.getBaseURI(), new 
StringReader(is.getStringData()),
  +                                          "UTF-16");
                }
                // otherwise, just use the public/system/base Ids
                else {
  -                     xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
  -                                                                      
is.getBaseURI());
  +                 xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
  +                                          is.getBaseURI());
                }
   
                return xis;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to