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 \r\r\rpackage simgrid.msg;
12 \r\rimport java.io.InputStream;
13 \rimport org.xml.sax.EntityResolver;
14 \rimport org.xml.sax.InputSource;
15 \rimport org.xml.sax.SAXException;
16 \r\rpublic class DTDResolver implements EntityResolver {
17 \r\rpublic InputSource resolveEntity(String publicID, String systemID)
\r
19 \r\r\rif (!systemID.endsWith("surfxml.dtd")) {
21 println("\n MSG - Warning - the platform used seams invalid\n");
25 /* try to get the DTD from the classpath */
\r
26 InputStream in = getClass().getResourceAsStream("/surfxml.dtd");
29 /* try to get the DTD from the surf dir in the jar */
\r
30 in = getClass().getResourceAsStream("/surf/surfxml.dtd");
33 /* try to get the DTD from the directory Simgrid */
\r
34 in = getClass().getResourceAsStream("/Simgrid/surfxml.dtd");
37 /* try to get the DTD from the directory Simgrid/msg */
\r
38 in = getClass().getResourceAsStream("/Simgrid/msg/surfxml.dtd");
40 \rSystem.err.println("\nMSG - XML DTD not found (" +
42 ").\n\nPlease put this file in one of the following destinations :\n\n"
43 +
\r" - classpath;\n" +
44 \r" - the directory Simgrid;\n" +
45 \r" - the directory Simgrid/msg;\n" +
46 \r" - the directory of you simulation.\n\n" +
47 \r"Once the DTD puted in one of the previouse destinations, retry you simulation.\n");
50 * If not founded, returning null makes process continue normally (try to get
\r
51 * the DTD from the current directory
\r
55 \r\rreturn new InputSource(in);