I'm curious as to whether anyone has used XSL to format a plaintext output. We started using XSL because it appeared to be a versatile technology, but we are quickly realizing it is only good for our HTML output. We need HTML, plaintext, and PDF. PDF generation via XSL is much too slow. And I'm not sure if it would work for plaintext. What we need is formatting (for e-mail bodies) which may include rows and columns that need to be aligned properly. There is no right or left padding in XSL.
We've already compromised our framework and taken the PDF-generation away from the XSL transformation. Must we do it again for plaintext? The value that XSL brings to the table is seeming less and less...
-
Formatting Text Output with XML (5 messages)
- Posted by: Jim Hall
- Posted on: June 13 2002 09:16 EDT
Threaded Messages (5)
- Formatting Text Output with XML by Raj Rajen on June 13 2002 12:51 EDT
- Formatting Text Output with XML by Kenny MacLeod on June 15 2002 17:25 EDT
- Formatting Text Output with XML by Tracy Hartley on June 17 2002 05:33 EDT
- Formatting Text Output with XML by Dave Costakos on June 18 2002 14:52 EDT
- Formatting Text Output with XML by Dave Costakos on June 18 2002 03:06 EDT
- Formatting Text Output with XML by Dave Costakos on June 18 2002 14:52 EDT
-
Formatting Text Output with XML[ Go to top ]
- Posted by: Raj Rajen
- Posted on: June 13 2002 12:51 EDT
- in response to Jim Hall
Jakarta Velocity might be of help to you as far formatting text output goes. -
Formatting Text Output with XML[ Go to top ]
- Posted by: Kenny MacLeod
- Posted on: June 15 2002 17:25 EDT
- in response to Jim Hall
XSL has little value unless you're doing XML-to-XML transformation, IMO.
Like the previous poster, I'd suggest a template engine. I'd suggest Freemarker rather than Velocity, however. Velocity's one of the rare examples of the jakarta project having a decidedly inferior product.
-
Formatting Text Output with XML[ Go to top ]
- Posted by: Tracy Hartley
- Posted on: June 17 2002 05:33 EDT
- in response to Jim Hall
Have you tried Apache FOP for the PDF? I am using this to produce PDF reports from database data. It has several other outputs included text.
See http://xml.apache.org/fop/index.html -
Formatting Text Output with XML[ Go to top ]
- Posted by: Dave Costakos
- Posted on: June 18 2002 14:52 EDT
- in response to Tracy Hartley
I believe I've found a formula that works (at least with the JDK 1.4 included XSL stuff).
Try this:
XML file:
<?xml version="1.0" ?>
<nodes>
<node1>Node One</node1>
<node2>Node Two</node2>
<node3>Node Three</node3>
</nodes>
XSL file:
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="https://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:variable name="pad" select="' '" />
<xsl:variable name="pad-length" select="string-length($pad)" />
<xsl:value-of select="substring($pad,1,$pad-length - string-length(//node1))"/><xsl:value-of select="//node1" />
<xsl:value-of select="substring($pad,1,$pad-length - string-length(//node2))"/><xsl:value-of select="//node2" />
<xsl:value-of select="substring($pad,1,$pad-length - string-length(//node3))"/><xsl:value-of select="//node3" />
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
My output was (with 20 space pad):
Node One Node Two Node Three -
Formatting Text Output with XML[ Go to top ]
- Posted by: Dave Costakos
- Posted on: June 18 2002 15:06 EDT
- in response to Dave Costakos
FYI:
My above message has some truncated whitespace. If you want, post a message w/ your email and I'll send you the actual files.
Dave.