Example usage for javax.xml.transform.stream StreamSource toString

List of usage examples for javax.xml.transform.stream StreamSource toString

Introduction

In this page you can find the example usage for javax.xml.transform.stream StreamSource toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.kuali.rice.ken.util.Util.java

/**
 * transformContent - transforms xml content in notification to a string
 * using the xsl in the datastore for a given documentType
 * @param notification//  w  w w  . j a v a  2s .  co  m
 * @return
 */
public static String transformContent(NotificationBo notification) {
    NotificationContentTypeBo contentType = notification.getContentType();
    String xsl = contentType.getXsl();

    LOG.debug("xsl: " + xsl);

    XslSourceResolver xslresolver = new XslSourceResolver();
    //StreamSource xslsource = xslresolver.resolveXslFromFile(xslpath);
    StreamSource xslsource = xslresolver.resolveXslFromString(xsl);
    String content = notification.getContent();
    LOG.debug("xslsource:" + xslsource.toString());

    String contenthtml = new String();
    try {
        ContentTransformer transformer = new ContentTransformer(xslsource);
        contenthtml = transformer.transform(content);
        LOG.debug("html: " + contenthtml);
    } catch (IOException ex) {
        LOG.error("IOException transforming document", ex);
    } catch (Exception ex) {
        LOG.error("Exception transforming document", ex);
    }
    return contenthtml;
}