01: /*
02: * Copyright 2006 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: *
13: * @created Jul 27, 2005
14: * @author James Dixon
15: */
16:
17: package org.pentaho.repository;
18:
19: import java.io.FileInputStream;
20: import java.io.FileNotFoundException;
21: import java.io.IOException;
22:
23: import org.pentaho.core.system.PentahoSystem;
24: import org.xml.sax.EntityResolver;
25: import org.xml.sax.InputSource;
26: import org.xml.sax.SAXException;
27:
28: public class PentahoEntityResolver implements EntityResolver {
29:
30: /*
31: * (non-Javadoc)
32: *
33: * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
34: * java.lang.String)
35: */
36: public InputSource resolveEntity(String publicId, String systemId)
37: throws SAXException, IOException {
38:
39: int idx = systemId.lastIndexOf('/');
40: String dtdName = systemId.substring(idx + 1);
41: String fullPath = PentahoSystem.getApplicationContext()
42: .getSolutionPath("system/dtd/" + dtdName); //$NON-NLS-1$
43:
44: try {
45: FileInputStream xslIS = new FileInputStream(fullPath);
46: InputSource source = new InputSource(xslIS);
47: return source;
48: } catch (FileNotFoundException e) {
49:
50: }
51: return null;
52: }
53:
54: }
|