public Transformer getTransformer ( HttpServletRequest req , ServletTask servletTask , ScreenModel screen ) throws ServletException , IOException { String stylesheet = null ; if ( stylesheet == null ) stylesheet = req . getParameter ( DBParams . TEMPLATE ) ; if ( stylesheet == null ) if ( screen != null ) if ( screen . getScreenFieldView ( ) != null ) stylesheet = screen . getScreenFieldView ( ) . getStylesheetPath ( ) ; if ( stylesheet == null ) stylesheet = req . getParameter ( "stylesheet" ) ; if ( stylesheet == null ) stylesheet = "org/jbundle/res/docs/styles/xsl/flat/base/menus" ; try { if ( hmTransformers . get ( stylesheet ) != null ) return hmTransformers . get ( stylesheet ) ; String stylesheetFixed = BaseServlet . fixStylesheetPath ( stylesheet , screen , true ) ; InputStream stylesheetStream = this . getFileStream ( servletTask , stylesheetFixed , null ) ; if ( stylesheetStream == null ) { stylesheetFixed = BaseServlet . fixStylesheetPath ( stylesheet , screen , false ) ; // Try it without browser mod stylesheetStream = this . getFileStream ( servletTask , stylesheetFixed , null ) ; } if ( stylesheetStream == null ) Utility . getLogger ( ) . warning ( "XmlFile not found " + stylesheetFixed ) ; // TODO - Display an error here StreamSource stylesheetSource = new StreamSource ( stylesheetStream ) ; if ( tFact == null ) tFact = TransformerFactory . newInstance ( ) ; URIResolver resolver = new MyURIResolver ( servletTask , stylesheetFixed ) ; tFact . setURIResolver ( resolver ) ; Transformer transformer = tFact . newTransformer ( stylesheetSource ) ; //transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //transformer.setOutputProperty(OutputKeys.METHOD, "xml"); hmTransformers . put ( stylesheet , transformer ) ; return transformer ; } catch ( TransformerConfigurationException ex ) { ex . printStackTrace ( ) ; } return null ; }
Get or Create a transformer for the specified stylesheet .