my dog learned polymorphism
The moose likes XML and Related Technologies and the fly likes XML to MSWord or RTF via XSL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML to MSWord or RTF via XSL" Watch "XML to MSWord or RTF via XSL" New topic

XML to MSWord or RTF via XSL


Joined: Feb 03, 2000
Posts: 16
Has anyone out there ever taken an XML document and transformed it into MSWord format or RTF via XSL; and if so, how do you do it?
It seems XSLT is really good at transforming XML into html, txt or XML (and PDF); however, it doesn't seem all that easy for the above formats. Thanks!
Tanya Rawat
Ranch Hand

Joined: Jul 23, 2001
Posts: 31
If you got answer to this question, then please reply back, how did you do that.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

your name doesn't agree with the javaranch guidelines.
please take a moment and re-register after reviewing the
guidelines at
thanks for your cooperation.
- satya

Take a Minute, Donate an Hour, Change a Life
Mapraputa Is
Leverager of our synergies

Joined: Aug 26, 2000
Posts: 10065
Bob DuCharme's "XSLT Quickly" has chapter 6.5 "Non-XML output" devoted to XML -> RTF conversion. Essentially, it is one small example. You can download the code from (xq387.xsl and xq388.xml), but since I already downloaded it, I decided to post it here. Hope I wont be sued for CopyRight violation
<title author="bd" ver="1.0">My Article</title>
<p>First paragraph. 3 < 4.</p>
<p>Second paragraph. AT&T is a big company.</p>
<!-- xq387.xsl: converts xq388.xml into xq389.rtf (sample.rtf) -->
<xsl:stylesheet xmlns:xsl=""
<xsl:output method="text"/>
<xsl:template match="article">{\rtf1 <xsl:apply-templates/> }
<xsl:template match="title">
\par {\b <xsl:apply-templates/>}
<xsl:template match="p">
\par <xsl:apply-templates/>

For automatic conversion, XML software recommends two programs:
- I did not try them myself, though.

[This message has been edited by Mapraputa Is (edited August 13, 2001).]

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
a glover

Joined: Aug 14, 2001
Posts: 12
Thank you very much, the example you posted is most informative. Now, it seems it is just a matter of mastering RTF. For those interested in RTF, there is a link:
Alas, the CitySlicker alias has been retired in favor of my new one. Thanks for pointing out my error!
I agree. Here's the link:
subject: XML to MSWord or RTF via XSL
It's not a secret anymore!