public static String transformXmlContent(CmsObject cms, String xsltFile, String xmlContent)
    throws CmsException, CmsXmlException {

        // JAXP reads data
        Source xmlSource = new StreamSource(new StringReader(xmlContent));
        String xsltString = new String(cms.readFile(xsltFile).getContents());
        Source xsltSource = new StreamSource(new StringReader(xsltString));
        String result = null;

        try {
            TransformerFactory transFact = TransformerFactory.newInstance();
            Transformer trans = transFact.newTransformer(xsltSource);

            StringWriter writer = new StringWriter();
            trans.transform(xmlSource, new StreamResult(writer));
            result = writer.toString();
        } catch (Exception exc) {
            throw new CmsXmlException(Messages.get().container(Messages.ERR_CSV_XML_TRANSFORMATION_FAILED_0));
        }

        // cut of the prefacing declaration '<?xml version="1.0" encoding="UTF-8"?>'
        if (result.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")) {
            return result.substring(38);
        } else {
            return result;
        }
    }
public static String transformXmlContent ( CmsObject cms , String xsltFile , String xmlContent ) throws CmsException , CmsXmlException { Source xmlSource = new StreamSource ( new StringReader ( xmlContent ) ) ; String xsltString = new String ( cms . readFile ( xsltFile ) . getContents ( ) ) ; Source xsltSource = new StreamSource ( new StringReader ( xsltString ) ) ; String result = null ; try { TransformerFactory transFact = TransformerFactory . newInstance ( ) ; Transformer trans = transFact . newTransformer ( xsltSource ) ; StringWriter writer = new StringWriter ( ) ; trans . transform ( xmlSource , new StreamResult ( writer ) ) ; result = writer . toString ( ) ; } catch ( Exception exc ) { throw new CmsXmlException ( Messages . get ( ) . container ( Messages . ERR_CSV_XML_TRANSFORMATION_FAILED_0 ) ) ; } if ( result . startsWith ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ) ) { return result . substring ( 38 ) ; } else { return result ; } }
Applies a XSLT Transformation to the content.<p>

The method does not use DOM4J, because iso-8859-1 code ist not transformed correctly.

@param cms the cms object
@param xsltFile the XSLT transformation file
@param xmlContent the XML content to transform

@return the transformed xml

@throws CmsXmlException if something goes wrong
@throws CmsException if something goes wrong