• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML to MSWord or RTF via XSL

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you got answer to this question, then please reply back, how did you do that.
Thanks
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"CitySlicker"
your name doesn't agree with the javaranch guidelines.
please take a moment and re-register after reviewing the
guidelines at http://www.javaranch.com/name.jsp
thanks for your cooperation.
- satya
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 http://www.manning.com/ducharme/source.html (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
XML:
<article>
<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>
</article>
XSL:
<!-- xq387.xsl: converts xq388.xml into xq389.rtf (sample.rtf) -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="article">{\rtf1 <xsl:apply-templates/> }
</xsl:template>
<xsl:template match="title">
\par {\b <xsl:apply-templates/>}
</xsl:template>
<xsl:template match="p">
\par <xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

For automatic conversion, XML software recommends two programs:
XTAL's http://www.zeigermann.de/xtal.html
rdc2rtf http://www.sema.be/mtc/products/rdc2rtf/index.html
- I did not try them myself, though.

[This message has been edited by Mapraputa Is (edited August 13, 2001).]
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
http://msdn.microsoft.com/library/?url=/library/en-us/dnrtfspec/html/rtfspec.asp?frame=true
Alas, the CitySlicker alias has been retired in favor of my new one. Thanks for pointing out my error!
 
reply
    Bookmark Topic Watch Topic
  • New Topic