2 * simgrid.msg.DTDResolver.java 1.00 07/05/01
\r
4 * Copyright 2006,2007 Martin Quinson, Malek Cherier
\r
5 * All right reserved.
\r
7 * This program is free software; you can redistribute
\r
8 * it and/or modify it under the terms of the license
\r
9 *(GNU LGPL) which comes with this package.
\r
11 package simgrid.msg;
\r
12 import java.io.InputStream;
\r
13 import org.xml.sax.EntityResolver;
\r
14 import org.xml.sax.InputSource;
\r
15 import org.xml.sax.SAXException;
\r
16 public class DTDResolver implements EntityResolver {
\r
17 public InputSource resolveEntity(String publicID, String systemID)
\r
18 throws SAXException {
\r
19 if (!systemID.endsWith("simgrid.dtd")) {
\r
21 println("\n MSG - Warning - the platform used seams invalid\n");
\r
25 /* try to get the DTD from the classpath */
\r
26 InputStream in = getClass().getResourceAsStream("/simgrid.dtd");
\r
29 /* try to get the DTD from the surf dir in the jar */
\r
30 in = getClass().getResourceAsStream("/surf/simgrid.dtd");
\r
33 /* try to get the DTD from the directory Simgrid */
\r
34 in = getClass().getResourceAsStream("/Simgrid/simgrid.dtd");
\r
37 /* try to get the DTD from the directory Simgrid/msg */
\r
38 in = getClass().getResourceAsStream("/Simgrid/msg/simgrid.dtd");
\r
40 System.err.println("\nMSG - XML DTD not found (" +
\r
41 systemID.toString() +
\r
42 ").\n\nPlease put this file in one of the following destinations :\n\n"
\r
43 + " - classpath;\n" +
\r
44 " - the directory Simgrid;\n" +
\r
45 " - the directory Simgrid/msg;\n" +
\r
46 " - the directory of you simulation.\n\n" +
\r
47 "Once the DTD puted in one of the previouse destinations, retry you simulation.\n");
\r
50 * If not founded, returning null makes process continue normally (try to get
\r
51 * the DTD from the current directory
\r
55 return new InputSource(in);
\r