commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From patri...@apache.org
Subject cvs commit: jakarta-commons/digester/src/java/org/apache/commons/digester Digester.java
Date Sat, 10 Aug 2002 22:05:42 GMT
patrickl    2002/08/10 15:05:42

  Modified:    digester/src/java/org/apache/commons/digester Digester.java
  Log:
  This patch optimizes the way the resolveEntity resolves schema and dtd. The same approach
is used for both DTD and Schema.
  Submitted by:	Jean-Francois Arcand (jeanfrancois.arcand@sun.com)
  
  Revision  Changes    Path
  1.63      +16 -33    jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java
  
  Index: Digester.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- Digester.java	10 Aug 2002 09:45:54 -0000	1.62
  +++ Digester.java	10 Aug 2002 22:05:42 -0000	1.63
  @@ -1327,6 +1327,7 @@
        * @param systemId The system identifier of the entity being referenced
        *
        * @exception SAXException if a parsing exception occurs
  +     * <
        */
         public InputSource resolveEntity(String publicId, String systemId)
               throws SAXException {     
  @@ -1343,39 +1344,21 @@
           if (publicId != null) {
               entityURL = (String) entityValidator.get(publicId);
           }
  -        
  -        // Redirect the schema/dtd location to a local destination.
  -        if (schemaLocation != null && entityValidator != null && entityURL
== null){
  -            try {    
  -                String schemaName = null;
  -                String localURI = null;
  -                try{
  -                    schemaName = systemId.substring(systemId.lastIndexOf("/") + 1);
  -                    localURI = (String)entityValidator.get(schemaName);
  -                } catch(IndexOutOfBoundsException ex){
  -                    if (debug) {
  -                        log.debug(" Not registered, use system identifier");
  -                    }
  -                    return null;
  -                }   
  -                
  -                if ( localURI == null ){
  -                    if (debug) {
  -                        log.debug(" Not registered, use system identifier");
  -                    }
  -                    return null;
  -                }         
  -                return new InputSource(localURI);         
  -            } catch (Exception e) {
  -               throw createSAXException(e);
  -            }
  -        }
  -
  +         
  +        // Redirect the schema location to a local destination
  +        if (schemaLocation != null && entityURL == null && systemId !=
null){
  +            entityURL = (String)entityValidator.get(systemId);
  +        } 
   
  +        if (entityURL == null){
  +           return (null); 
  +        }
  +        
           // Return an input source to our alternative URL
           if (debug) {
               log.debug(" Resolving to alternate DTD '" + entityURL + "'");
           }
  +        
           try {
               URL url = new URL(entityURL);
               InputStream stream = url.openStream();
  @@ -1383,7 +1366,7 @@
           } catch (Exception e) {
               throw createSAXException(e);
           }
  -
  + 
       }
   
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message