3 import java.io.IOException;
5 import com.icl.saxon.PreparedStyleSheet;
6 import org.xml.sax.InputSource;
7 import org.xml.sax.SAXException;
8 import com.icl.saxon.trax.Transformer;
10 import java.util.Hashtable;
15 * Copyright: Copyright (c) 2001
22 public class XslStyleCache {
24 private static Hashtable cache;
25 private static XslStyleCache single = new XslStyleCache();
29 * XSLStyleCache constructor comment.
31 private XslStyleCache() {
32 cache = new Hashtable();
36 * singleton constructor
38 private static synchronized XslStyleCache getInstance() {
46 public static void clear() {
51 * This method was created in VisualAge.
53 * @param key java.lang.String
55 public static PreparedStyleSheet getPreparedStyleSheet( String key )
58 PreparedStyleSheet styleSheet = (PreparedStyleSheet)single.cache.get( key );
60 if ( styleSheet == null ) {
61 styleSheet = new PreparedStyleSheet();
62 styleSheet.prepare( InputSourceResolver.resolve( key ) );
63 single.cache.put( key, styleSheet );
65 } catch ( IOException ex ) {
66 throw new SAXException( "tunneld IOExcpetion:" + ex.getMessage() );
73 * This method was created in VisualAge.
75 * @param key java.lang.String
77 public static Transformer getTransformer( String key ){
79 PreparedStyleSheet styleSheet = (PreparedStyleSheet)single.cache.get( key );
81 if ( styleSheet == null ) {
82 styleSheet = new PreparedStyleSheet();
83 styleSheet.prepare( InputSourceResolver.resolve( key ) );
84 single.cache.put( key, styleSheet );
86 } catch ( IOException ex ) {
87 //throw new SAXException( "tunneld IOExcpetion:" + ex.getMessage() );
88 } catch (SAXException ex) {}
90 return styleSheet.newTransformer();