View Javadoc

1   /*   Copyright (C) 2004 Finalist IT Group
2    *
3    *   This file is part of JAG - the Java J2EE Application Generator
4    *
5    *   JAG is free software; you can redistribute it and/or modify
6    *   it under the terms of the GNU General Public License as published by
7    *   the Free Software Foundation; either version 2 of the License, or
8    *   (at your option) any later version.
9    *   JAG is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   *   GNU General Public License for more details.
13   *   You should have received a copy of the GNU General Public License
14   *   along with JAG; if not, write to the Free Software
15   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16   */
17  
18  package com.finalist.ant.tasks.docbook;
19  
20  import org.xml.sax.EntityResolver;
21  import org.xml.sax.InputSource;
22  
23  /***
24   * <code>DTDResolver.java</code>
25   *
26   * @author stefan
27   * @version $Revision: 1.1 $
28   */
29  
30  public class DTDResolver implements EntityResolver{
31  
32  	public InputSource resolveEntity(String publicId, String systemId) {
33  		InputSource returnSource;
34  		if( publicId.equalsIgnoreCase("-//OASIS//DTD DocBook XML V4.2//EN") ) {
35  			returnSource =	new InputSource( this.getClass().getResourceAsStream("/" + ParameterValues.DOCBOOK_DTD_4_2 + "/docbookx.dtd") );
36  			returnSource.setSystemId(this.getClass().getResource("/" + ParameterValues.DOCBOOK_DTD_4_2 + "/").toString());
37  		}else if( publicId.equalsIgnoreCase("-//OASIS//DTD DocBook XML V4.0//EN") ) {
38  			returnSource =	new InputSource( this.getClass().getResourceAsStream("/" + ParameterValues.DOCBOOK_DTD_4_0 + "/docbookx.dtd") );
39  			returnSource.setSystemId(this.getClass().getResource("/" + ParameterValues.DOCBOOK_DTD_4_0 + "/").toString());			
40  		}else if( publicId.equalsIgnoreCase("-//OASIS//DTD DocBook XML V4.1.2//EN") ) {
41  			returnSource =	new InputSource( this.getClass().getResourceAsStream("/" + ParameterValues.DOCBOOK_DTD_4_1_2 + "/docbookx.dtd") );
42  			returnSource.setSystemId(this.getClass().getResource("/" + ParameterValues.DOCBOOK_DTD_4_1_2 + "/").toString());			
43  		}else{
44  			//Can't handle this returning the orriginional
45  			returnSource = new InputSource(systemId);
46  			returnSource.setPublicId(publicId);
47  		}
48  		return returnSource;
49  	}
50  }
51  
52  /*
53   * $Log: DTDResolver.java,v $
54   * Revision 1.1  2004/03/12 22:16:00  ekkelenkamp
55   * no message
56   *
57   * Revision 1.1  2004/01/06 13:26:39  stefan
58   * Added local dtd support and local watermark image support, now it's independent from the Internet
59   *
60   *
61   */