View Javadoc

1   /*
2    * UML2MMBase module.
3    *
4    * The contents of this file are subject to the Mozilla Public License
5    * Version 1.0 (the "License"); you may not use this file except in
6    * compliance with the License. You may obtain a copy of the License at
7    * http://www.mozilla.org/MPL/
8    *
9    * Software distributed under the License is distributed on an "AS IS"
10   * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11   * License for the specific language governing rights and limitations
12   * under the License.
13   */
14  
15  package com.finalist.mmbase.wizard;
16  
17  import org.xml.sax.EntityResolver;
18  import org.xml.sax.InputSource;
19  
20  import java.io.FileReader;
21  
22  /***
23   * The com.finalist.mmbase.wizard.MMBaseDTDResolver checks if the
24   * requested dtd is known and returns a reference.
25   *
26   * @author Kors van Beem
27   * @version $Revision: 1.3 $, $Date: 2004/10/23 08:54:39 $
28   *
29   */
30  public class MMBaseDTDResolver implements EntityResolver {
31  
32     /***
33      *
34      * @param publicId The description of the dtd.
35      * @param systemId The reference to a dtd on a site.
36      * @return The correct inputsource
37      */
38     public InputSource resolveEntity (String publicId, String systemId) {
39        InputSource returnSource = null;
40        try {
41           if (systemId.equalsIgnoreCase("http://www.mmbase.org/dtd/application_1_0.dtd")) {
42              returnSource = new InputSource(this.getClass().getResourceAsStream("/dtd/application_1_0.dtd"));
43           }
44           if (systemId.equalsIgnoreCase("http://www.mmbase.org/dtd/application_1_1.dtd")) {
45              returnSource = new InputSource(this.getClass().getResourceAsStream("/dtd/application_1_1.dtd"));
46           }
47           if (systemId.equalsIgnoreCase("http://www.mmbase.org/dtd/wizard-schema_1_0.dtd")) {
48              returnSource = new InputSource(this.getClass().getResourceAsStream("/dtd/wizard-schema_1_0.dtd"));
49           }
50        }
51        catch (Exception e) {
52           e.printStackTrace();
53        }
54        return returnSource;
55     }
56  }