public void setStylesheet(DocumentImpl doc, String stylesheet) { if (stylesheet == null) { templates = null; return; } long start = System.currentTimeMillis(); xslHandler = null; try {  if (stylesheet.indexOf(":") > -1) { StreamSource source = new StreamSource(stylesheet); templates = factory.newTemplates(source); } else try {   if (stylesheet.indexOf('/') < 0 && doc != null) stylesheet = doc.getCollection().getName() + '/' + stylesheet;   DocumentImpl xsl = (DocumentImpl) broker.getDocument(stylesheet); if (xsl == null) { LOG.debug("stylesheet not found"); return; } if (xsl.getCollection() != null) factory.setURIResolver( new InternalURIResolver( xsl.getCollection().getName()));   ContentHandler oldHandler = contentHandler; LexicalHandler oldLexical = lexicalHandler; SAXSource source = new SAXSource(this, new InputSource(stylesheet));  templates = factory.newTemplates(source);  contentHandler = oldHandler; lexicalHandler = oldLexical; factory.setURIResolver(null); } catch (PermissionDeniedException e) { LOG.debug("permission denied", e); return; }  LOG.debug( "compiling stylesheet took " + (System.currentTimeMillis() - start)); xslHandler = ((SAXTransformerFactory) factory).newTransformerHandler( templates); } catch (TransformerConfigurationException e) { LOG.debug("error compiling stylesheet", e); return; }
public void setStylesheet(String stylesheet) { setStylesheet(null, stylesheet);
	public void setStylesheet(DocumentImpl doc, String stylesheet) {		if (stylesheet == null) {			templates = null;			return;		}		long start = System.currentTimeMillis();		xslHandler = null;		try {			// does stylesheet point to an external resource?			if (stylesheet.indexOf(":") > -1) {				StreamSource source = new StreamSource(stylesheet);				templates = factory.newTemplates(source);			} else				try {					// if stylesheet is relative, add path to the					// current collection					if (stylesheet.indexOf('/') < 0 && doc != null)						stylesheet =							doc.getCollection().getName() + '/' + stylesheet;					// load stylesheet from eXist					DocumentImpl xsl =						(DocumentImpl) broker.getDocument(stylesheet);					if (xsl == null) {						LOG.debug("stylesheet not found");						return;					}					if (xsl.getCollection() != null)						factory.setURIResolver(							new InternalURIResolver(								xsl.getCollection().getName()));					// save handlers					ContentHandler oldHandler = contentHandler;					LexicalHandler oldLexical = lexicalHandler;					SAXSource source =						new SAXSource(this, new InputSource(stylesheet));					// compile stylesheet					templates = factory.newTemplates(source);					// restore handlers					contentHandler = oldHandler;					lexicalHandler = oldLexical;					factory.setURIResolver(null);				} catch (PermissionDeniedException e) {					LOG.debug("permission denied", e);					return;				}			LOG.debug(				"compiling stylesheet took "					+ (System.currentTimeMillis() - start));			xslHandler =				((SAXTransformerFactory) factory).newTransformerHandler(					templates);		} catch (TransformerConfigurationException e) {			LOG.debug("error compiling stylesheet", e);			return;		}	}