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
14 package simgrid.msg;
\r
16 import java.io.InputStream;
\r
17 import java.io.FileNotFoundException;
\r
18 import org.xml.sax.EntityResolver;
\r
19 import org.xml.sax.InputSource;
\r
20 import org.xml.sax.SAXException;
\r
22 public class DTDResolver implements EntityResolver {
\r
24 public InputSource resolveEntity(String publicID, String systemID)
\r
25 throws SAXException {
\r
28 if(!systemID.endsWith("surfxml.dtd")){
\r
29 System.out.println("\n MSG - Warning - the platform used seams invalid\n");
\r
33 /* try to get the DTD from the classpath */
\r
34 InputStream in = getClass().getResourceAsStream("/surfxml.dtd");
\r
37 /* try to get the DTD from the directory Simgrid */
\r
38 in = getClass().getResourceAsStream("/Simgrid/surfxml.dtd");
\r
41 /* try to get the DTD from the directory Simgrid/msg */
\r
42 in = getClass().getResourceAsStream("/Simgrid/msg/surfxml.dtd");
\r
45 System.err.println("\nMSG - XML DTD not found (" + systemID.toString() + ").\n\nPlease put this file in one of the following destinations :\n\n"+
\r
47 " - the directory Simgrid;\n"+
\r
48 " - the directory Simgrid/msg;\n"+
\r
49 " - the directory of you simulation.\n\n"+
\r
50 "Once the DTD puted in one of the previouse destinations, retry you simulation.\n");
\r
53 * If not founded, returning null makes process continue normally (try to get
\r
54 * the DTD from the current directory
\r
59 return new InputSource(in);
\r