app/src/main/java/org/andstatus/app/util/Xslt.java
/**
     * Transform XML input files using supplied XSL stylesheet and return as String
     * @param resXml XML file to transform. This file is localized! It should be put into "raw-<language>" folder 
     * @param resXsl XSL stylesheet. In the "raw" folder. May be single for all languages...
     * @return empty in case of error
     */
Transform XML input files using supplied XSL stylesheet and return as String
@param resXml XML file to transform. This file is localized. It should be put into "raw-" folder
@param resXsl XSL stylesheet. In the "raw" folder. May be single for all languages
@return empty in case of error
Transform XML input files using supplied XSL stylesheet and return as String @param resXml XML file to transform . This file is localized . It should be put into " raw - " folder @param resXsl XSL stylesheet . In the " raw " folder . May be single for all languages @return empty in case of error
public static String toHtmlString(Context context, int resXml, int resXsl) {
        String output = "";
        try {
            Source xmlSource = new StreamSource(context.getResources().openRawResource(resXml));
            Source xsltSource = new StreamSource(context.getResources().openRawResource(resXsl));
            TransformerFactory transformerFactory = TransformerFactory.newInstance();
            transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
            Transformer transformer = transformerFactory.newTransformer(xsltSource);
            StringWriter stringWriter = new StringWriter();
            StreamResult result = new StreamResult(stringWriter);
            transformer.transform(xmlSource, result);
            output = result.getWriter().toString();
        } catch (TransformerFactoryConfigurationError | TransformerException e) {
            MyLog.w(TAG, "Failed to transform XML to HTML", e);
        }
        return output;
    }
public static String toHtmlString ( Context context , int resXml , int resXsl ) { String output = "" ; try { Source xmlSource = new StreamSource ( context . getResources ( ) . openRawResource ( resXml ) ) ; Source xsltSource = new StreamSource ( context . getResources ( ) . openRawResource ( resXsl ) ) ; TransformerFactory transformerFactory = TransformerFactory . newInstance ( ) ; transformerFactory . setFeature ( XMLConstants . FEATURE_SECURE_PROCESSING , true ) ; Transformer transformer = transformerFactory . newTransformer ( xsltSource ) ; StringWriter stringWriter = new StringWriter ( ) ; StreamResult result = new StreamResult ( stringWriter ) ; transformer . transform ( xmlSource , result ) ; output = result . getWriter ( ) . toString ( ) ; } catch ( TransformerFactoryConfigurationError | TransformerException e ) { MyLog . w ( TAG , "Failed to transform XML to HTML" , e ) ; } return output ; }
Transform XML input files using supplied XSL stylesheet and return as String
 @param resXml XML file to transform.
Transform XML input files using supplied XSL stylesheet and return as String @param resXml XML file to transform .
// Based on http://stackoverflow.com/questions/6215001/convert-xml-file-using-xslt-in-android // This file is localized! 