Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mv surfxml.dtd simgrid.dtd
[simgrid.git] / src / java / simgrid / msg / DTDResolver.java
1 /*\r
2  * simgrid.msg.DTDResolver.java    1.00 07/05/01\r
3  *\r
4  * Copyright 2006,2007 Martin Quinson, Malek Cherier           \r
5  * All right reserved. \r
6  *\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
10  */  \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
20       System.out.\r
21         println("\n MSG - Warning - the platform used seams invalid\n");\r
22       return null;\r
23     }\r
24     \r
25       /* try to get the DTD from the classpath */ \r
26       InputStream in = getClass().getResourceAsStream("/simgrid.dtd");\r
27     if (null == in)\r
28       \r
29         /* try to get the DTD from the surf dir in the jar */ \r
30         in = getClass().getResourceAsStream("/surf/simgrid.dtd");\r
31     if (null == in)\r
32       \r
33         /* try to get the DTD from the directory Simgrid */ \r
34         in = getClass().getResourceAsStream("/Simgrid/simgrid.dtd");\r
35     if (null == in)\r
36       \r
37         /* try to get the DTD from the directory Simgrid/msg */ \r
38         in = getClass().getResourceAsStream("/Simgrid/msg/simgrid.dtd");\r
39     if (null == in) {\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
48       \r
49         /* \r
50          * If not founded, returning null makes process continue normally (try to get \r
51          * the DTD from the current directory \r
52          */ \r
53         return null;\r
54     }\r
55     return new InputSource(in);\r
56   }\r
57 }\r
58 \r
59 \r