Login | Register
My pages Projects Community openCollabNet

Discussions > dev > patch for PGMLParser.java

gef
Discussion topic

Back to topic list

patch for PGMLParser.java

Reply

Author guillomovitch
Full name Guillaume Rousse
Date 2002-02-11 07:30:07 PST
Message This patch solve the 'pgml.dtd' not found error message. Please apply to make
argouml work not only from source directory :-)

--- src/org/tigris/gef/x​ml/pgml/PGMLParser.j​ava Mon Feb 11 12:30:08 2002
+++ src/org/tigris/gef/x​ml/pgml/PGMLParser.j​ava.new Mon Feb 11 12:32:01 2002
@@ -847,52 +847,47 @@
   }
 
 
- public InputSource resolveEntity(java.lang.String publicId,
- java.lang.String systemId) {
+ public InputSource resolveEntity(java.lang.String publicId,
java.lang.String systemId) {
         InputSource source = null;
+
         try {
+ // first try to get an url from systemId
             java.net.URL url = new java.net.URL(systemId);
- try {
- source = new InputSource(url.openStream());
+ source = new InputSource(url.openStream());
             source.setSystemId(systemId);
- if (publicId != null) source.setPublicId(publicId);
- }
- catch (java.io.IOException e) {
- if (systemId.endsWith(".dtd")) {
- int i = systemId.lastIndexOf('/');
- i++; // go past '/' if there, otherwise advance to 0
- String[] entityPaths = getEntityPaths();
- InputStream is = null;
- for(int pathIndex = 0; pathIndex < entityPaths.length &&
is == null; pathIndex++) {
- String DTD_DIR = entityPaths[pathIndex];
- is = getClass().getResour​ceAsStream(DTD_DIR +
systemId.substring(i));
- if(is == null) {
- try {
- is = new
FileInputStream(DTD_​DIR.substring(1) + systemId.substring(i));
- }
- catch(Exception ex) {}
- }
- }
- if(is != null) {
- source = new InputSource(is);
- source.setSystemId(systemId);
- if(publicId != null) source.setPublicId(publicId);
+ if (publicId != null) source.setPublicId(publicId);
+ } catch (Exception e) {
+ // if something fails and entity is a dtd, try included resources
+ if (systemId.endsWith(".dtd")) {
+ int i = systemId.lastIndexOf('/');
+ i++; // go past '/' if there, otherwise advance to 0
+ String[] entityPaths = getEntityPaths();
+ InputStream is = null;
+ for(int pathIndex = 0; pathIndex < entityPaths.length && is
== null; pathIndex++) {
+ String DTD_DIR = entityPaths[pathIndex];
+ is = getClass().getResour​ceAsStream(DTD_DIR +
systemId.substring(i));
+ if(is == null) {
+ try {
+ is = new FileInputStream(DTD_​DIR.substring(1) +
systemId.substring(i));
+ } catch(Exception ex) {}
                     }
                 }
+ if(is != null) {
+ source = new InputSource(is);
+ source.setSystemId(systemId);
+ if(publicId != null) source.setPublicId(publicId);
+ }
             }
- }
- catch(Exception ex) {
         }
 
- //
- // returning an "empty" source is better than failing
- //
- if(source == null) {
+ // returning an "empty" source is better than failing
+ if (source == null) {
             source = new InputSource();
             source.setSystemId(systemId);
         }
+
         return source;
- }
+ }
 
    public void setSystemId(String id) {
        systemId = id;
--
Guillaume Rousse <rousse at ccr dot jussieu dot fr>
GPG key http://lis.snv.jussi​eu.fr/~rousse/gpgkey​.html

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: dev-unsubscribe at gef dot tigris dot org
For additional commands, e-mail: dev-help at gef dot tigris dot org

« Previous message in topic | 1 of 6 | Next message in topic »

Messages

Show all messages in topic

patch for PGMLParser.java guillomovitch Guillaume Rousse 2002-02-11 07:30:07 PST
     Re: patch for PGMLParser.java andreas Andreas Rueckert 2002-02-12 05:34:10 PST
         Re: patch for PGMLParser.java guillomovitch Guillaume Rousse 2002-02-12 07:24:59 PST
     Re: patch for PGMLParser.java 1sturm Thorsten Sturm 2002-02-12 07:04:47 PST
         Re: patch for PGMLParser.java guillomovitch Guillaume Rousse 2002-02-12 07:24:12 PST
             Re: patch for PGMLParser.java andreas Andreas Rueckert 2002-02-12 11:18:02 PST
Messages per page: