transformer

GZip HttpResponse using XSL Transformer - Java

I have the following code below in my Servlet, but when IE hits the page, it returns a blank html page. If I use the response.getOutputStream() directly in the StreamResult constructor, the page loads fine. What am I missing? response is an instance of HttpServletResponse and xsl is an instance of Transformer from XSLTC TransformerFac...

java append to file

I googled for this for a while but can't seem to find it and it should be easy. I want to append a CR to then end of an XML file that I am creating with a Transformer. Is there a way to do this> I tried the following but this resulted in a blank file? Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.set...

How Do You Prevent A javax Transformer From Escaping Whitespace?

I'm using the javax.xml.transform.Transformer class to perform some XSLT translations, like so: TransformerFactory factory = TransformerFactory.newInstance(); StreamSource source = new StreamSource(TRANSFORMER_PATH); Transformer transformer = factory.newTransformer(source); StringWriter extractionWriter = new StringWriter(); String xml ...

How to force javax xslt transformer to encode national characters using utf-8 and not html entities?

I'm working on filter that should transform an output with some stylesheet. Important sections of code looks like this: PrintWriter out = response.getWriter(); ... StringReader sr = new StringReader(content); Source xmlSource = new StreamSource(sr, requestSystemId); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transforme...

Saxon 9.2 / Java / XSLT: setting transformer parameters using setParameters()

Hi all, I have the following XSLT 2.0 template: <xsl:template name="t1"> <xsl:variable name="totalpos" as="xsd:double" select="$currentTotal"/> .. I am struggling to programmatticaly provide currentTotal as a parameter to the transformer, like this: transformer.setParameter("currentTotal", new Double("100")) .. but without any posi...

How to prevent xml transformer to transform empty tags into single tag

Hi, I'm using javax.xml.transform.Transformer class to transform the DOM source into XML string. I have some empty elements in DOM tree, and these become one tag which I don't want. How do I prevent <sampletag></sampletag> from becoming <sampletag/>? ...

javax.xml.transform.Transformer encoding entity numbers

Hello, I have a problem using a transformer to generate an XML document. The incoming org.w3c.dom.Document has the entity codes correct: &#174; However, once the Document is transformed the ampersand is encoded: &amp;#174; I was expecting ampersands followed by a # to have been respected, but I guess perhaps this is correct behav...

How can you use sort descriptors and predicates with core data transformable fields?

I have an application which I wrote which used to work perfectly fine. There is new requirement that all data needs to be encrypted now, so I implemented encryption by making all my core data fields type transformable and writing custom transformers for each data type which encrypts/decrypts each element of data as it is written/read fro...