X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2a1f1d17620dc6fff28292e37791e40d77eba401..964fa7d1a4b0fb183a02d8b0020d74b1255312e0:/src/java/simgrid/msg/DTDResolver.java diff --git a/src/java/simgrid/msg/DTDResolver.java b/src/java/simgrid/msg/DTDResolver.java index 5c2ae715c8..e74df9f8f4 100644 --- a/src/java/simgrid/msg/DTDResolver.java +++ b/src/java/simgrid/msg/DTDResolver.java @@ -7,57 +7,53 @@ * This program is free software; you can redistribute * it and/or modify it under the terms of the license *(GNU LGPL) which comes with this package. - */ + */ + package simgrid.msg; + import java.io.InputStream; + import org.xml.sax.EntityResolver; + import org.xml.sax.InputSource; + import org.xml.sax.SAXException; + public class DTDResolver implements EntityResolver { + public InputSource resolveEntity(String publicID, String systemID) + throws SAXException { + if (!systemID.endsWith("surfxml.dtd")) { + System.out. + println("\n MSG - Warning - the platform used seams invalid\n"); + return null; + } + + /* try to get the DTD from the classpath */ + InputStream in = getClass().getResourceAsStream("/surfxml.dtd"); + if (null == in) + + /* try to get the DTD from the surf dir in the jar */ + in = getClass().getResourceAsStream("/surf/surfxml.dtd"); + if (null == in) + + /* try to get the DTD from the directory Simgrid */ + in = getClass().getResourceAsStream("/Simgrid/surfxml.dtd"); + if (null == in) + + /* try to get the DTD from the directory Simgrid/msg */ + in = getClass().getResourceAsStream("/Simgrid/msg/surfxml.dtd"); + if (null == in) { + System.err.println("\nMSG - XML DTD not found (" + + systemID.toString() + + ").\n\nPlease put this file in one of the following destinations :\n\n" + + " - classpath;\n" + + " - the directory Simgrid;\n" + + " - the directory Simgrid/msg;\n" + + " - the directory of you simulation.\n\n" + + "Once the DTD puted in one of the previouse destinations, retry you simulation.\n"); + + /* + * If not founded, returning null makes process continue normally (try to get + * the DTD from the current directory + */ + return null; + } + return new InputSource(in); + } + } + - - -package simgrid.msg; - -import java.io.InputStream; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -public class DTDResolver implements EntityResolver { - - public InputSource resolveEntity(String publicID, String systemID) - throws SAXException { - - - if(!systemID.endsWith("surfxml.dtd")){ - System.out.println("\n MSG - Warning - the platform used seams invalid\n"); - return null; - } - - /* try to get the DTD from the classpath */ - InputStream in = getClass().getResourceAsStream("/surfxml.dtd"); - - if(null == in) - /* try to get the DTD from the surf dir in the jar */ - in = getClass().getResourceAsStream("/surf/surfxml.dtd"); - if(null == in) - /* try to get the DTD from the directory Simgrid */ - in = getClass().getResourceAsStream("/Simgrid/surfxml.dtd"); - - if(null == in) - /* try to get the DTD from the directory Simgrid/msg */ - in = getClass().getResourceAsStream("/Simgrid/msg/surfxml.dtd"); - - if(null == in) { - System.err.println("\nMSG - XML DTD not found (" + systemID.toString() + ").\n\nPlease put this file in one of the following destinations :\n\n"+ - " - classpath;\n"+ - " - the directory Simgrid;\n"+ - " - the directory Simgrid/msg;\n"+ - " - the directory of you simulation.\n\n"+ - "Once the DTD puted in one of the previouse destinations, retry you simulation.\n"); - - /* - * If not founded, returning null makes process continue normally (try to get - * the DTD from the current directory - */ - return null; - } - - return new InputSource(in); - } -}