mrglavas    2004/03/24 13:32:43

  Modified:    java/src/org/apache/xerces/parsers DOMParserImpl.java
  Log:
  Fixing Bug #27872:

  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27872

  

  The LSParser was not using the given order:

  

  1. LSInput.characterStream 

  2. LSInput.byteStream 

  3. LSInput.stringData 

  4. LSInput.systemId 

  5. LSInput.publicId 

  

  for determining which input will be used. Also, we weren't

  raising a DOMError if all the inputs are null (or empty strings

  where applicable).

  

  Fixed thanks to the patch from Naela Nissar; slightly modified

  to check for empty strings for the following fields: stringData, 

  systemId and publicId.
  
  Revision  Changes    Path
  1.21      +22 -11    xml-xerces/java/src/org/apache/xerces/parsers/DOMParserImpl.java
  
  Index: DOMParserImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/DOMParserImpl.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DOMParserImpl.java        19 Mar 2004 19:46:54 -0000      1.20
  +++ DOMParserImpl.java        24 Mar 2004 21:32:43 -0000      1.21
  @@ -909,16 +909,9 @@
       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");
  -        }
           // check whether there is a Reader
           // according to DOM, we need to treat such reader as "UTF-16".
  -        else if (is.getCharacterStream () != null) {
  +        if (is.getCharacterStream () != null) {
               xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
               is.getBaseURI (), is.getCharacterStream (),
               "UTF-16");
  @@ -929,12 +922,30 @@
               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 {
  +        else if ((is.getSystemId() != null && is.getSystemId().length() > 0) || 
  +            (is.getPublicId() != null && is.getPublicId().length() > 0)) {
               xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
               is.getBaseURI ());
           }
  -
  +        else { 
  +            // all inputs are null
  +            if (fErrorHandler != null) {
  +                DOMErrorImpl error = new DOMErrorImpl();
  +                error.fType = "no-input-specified";
  +                error.fMessage = "no-input-specified";
  +                error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
  +                fErrorHandler.handleError(error);
  +            }
  +            throw new LSException(LSException.PARSE_ERR, "no-input-specified");
  +        }
           return xis;
       }
   
  
  
  

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

Reply via email to