1 /*
2 * XMLCV - Gestion de CV sous forme XML
3 *
4 * Copyright (C) 2004-2005, Damien Raude-Morvan
5 *
6 * This file is part of XMLCV.
7 *
8 * XMLCV is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * XMLCV is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with XMLCV; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * Contacts :
23 * - Sébastien Mathy <smathy@tuxfamily.org>
24 * - Emmanuel Berre <eberre@tuxfamily.org>
25 * - Damien Raude-Morvan <drazzib@drazzib.com>
26 */
27 package org.xmlcv.util;
28
29 import java.io.File;
30
31 import javax.xml.transform.Source;
32 import javax.xml.transform.URIResolver;
33 import javax.xml.transform.stream.StreamSource;
34
35 /***
36 *
37 * @version $Revision: 114 $
38 * @author <a href="mailto:drazzib@drazzib.com">Damien Raude-Morvan </a>
39 */
40 public class JarResolver implements URIResolver {
41
42 public Source resolve(String href, String base) {
43 Source src = null;
44
45 // On récupère la dernière partie de l'URL
46 href = href.substring(href.lastIndexOf(File.separator) + 1); //$NON-NLS-1$
47
48 if ((href.endsWith(".xsl")) || (href.endsWith(".xml"))) { //$NON-NLS-1$ //$NON-NLS-2$
49 src = new StreamSource(
50 getClass()
51 .getResourceAsStream(
52 File.separator
53 + "xmlcv" + File.separator + "xsl" + File.separator + href)); //$NON-NLS-1$ //$NON-NLS-2$
54 } else if (href.endsWith(".css")) { //$NON-NLS-1$
55 src = new StreamSource(
56 getClass()
57 .getResourceAsStream(
58 File.separator
59 + "xmlcv" + File.separator + "css" + File.separator + href)); //$NON-NLS-1$ //$NON-NLS-2$
60 }
61
62 return src;
63 }
64
65 }