Skip to main content

Posts

Showing posts from July, 2012

XSLT : Fun with xslt and xpath with fop

So I wanted a generic, all things to all men style sheet transformation on my service call to generate a PDF report for any xml message. I had to do this using XSLT 1.0 booo hiss. This really make things harder. So here is what I learned: So the first thing I needed was a JAXB transform from incoming object to xml.         JAXBContext context = JAXBContext.newInstance(xmlObject.getClass());         Marshaller marshaller = context.createMarshaller();         StringWriter sw = new StringWriter();         marshaller.marshal(xmlObject, sw);         IOUtils.closeQuietly(sw);         return sw.toString(); The next thing was passing parameters (a report title)             Transformer transformer = tFactory.newTransformer(xsltSrc);             transformer.setParameter("ReportTitle", "Report Title"); <xsl:param name="ReportTitle" select="'None'"/ > < xsl:value-of select="$ReportTitle"/> Makin