code: public static String renderWithTransformToHTML(final Request request, final WComponent component, final boolean includePageShell) {
  
  		// Setup a context (if needed)
  		boolean needsContext = UIContextHolder.getCurrent() == null;
  		if (needsContext) {
  			UIContextHolder.pushContext(new UIContextImpl());
  		}
  
  		try {
  
  			// Link Interceptors
  			InterceptorComponent templateRender = new TemplateRenderInterceptor();
  			InterceptorComponent transformXML = new TransformXMLInterceptor();
  			templateRender.setBackingComponent(transformXML);
  			if (includePageShell) {
  				transformXML.setBackingComponent(new PageShellInterceptor());
  			}
  
  			// Attach Component and Mock Response
  			InterceptorComponent chain = templateRender;
  			chain.attachUI(component);
  			chain.attachResponse(new MockResponse());
  
  			// Render chain
  			StringWriter buffer = new StringWriter();
  			chain.preparePaint(request);
  			try (PrintWriter writer = new PrintWriter(buffer)) {
  				chain.paint(new WebXmlRenderContext(writer));
  			}
  			return buffer.toString();
  		} finally {
  			if (needsContext) {
  				UIContextHolder.popContext();
  			}
  		}
  	}
docs: Renders and transforms the given WComponent to a HTML String outside of the context of a Servlet.
  
  @param request the request being responded to
  @param component the root WComponent to render
  @param includePageShell true if include page shell
  @return the rendered output as a String.