• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML to MSWord or RTF via XSL

 
CitySlicker
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
Tanya Rawat
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you got answer to this question, then please reply back, how did you do that.
Thanks
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • 0
  • Mark post as helpful
  • send pies
  • 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).]
 
a glover
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic