private static Templates initTemplates ( ) { try { URL xsltURL = ThemeUtil . class . getResource ( RESOURCE_NAME ) ; if ( xsltURL != null ) { Source xsltSource = new StreamSource ( xsltURL . openStream ( ) , xsltURL . toExternalForm ( ) ) ; TransformerFactory factory = new net . sf . saxon . TransformerFactoryImpl ( ) ; Templates templates = factory . newTemplates ( xsltSource ) ; LOG . debug ( "Generated XSLT templates for: " + RESOURCE_NAME ) ; return templates ; } else { // Server-side XSLT enabled but theme resource not on classpath. throw new IllegalStateException ( RESOURCE_NAME + " not on classpath" ) ; } } catch ( IOException | TransformerConfigurationException ex ) { throw new SystemException ( "Could not create transformer for " + RESOURCE_NAME , ex ) ; } }
Statically initialize the XSLT templates that are cached for all future transforms .