This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: XML to Word Document


The HTML -> Word route works quite well, especially if you create a CSS stylesheet to tweak the finer points of paragraph, list item, etc. layout.  We use XSL in the manner to create manuals for our methodologies -- cruddy RTF to cruddy XML to clean XML to (relatively) clean HTML.  After we generate the HTML file, it's inserted into a dummy Word document so that the table of contents will come out right.

The worst part of the process is the RTF to XML part, but for this limited domain (converting RTF generated programmatically to XML) we're OK.

I believe that the stylesheet can include the IE-specifc styles related to printing as well, so you can force page breaks on certain elements.

Finally, you can even use the Microsoft HTML Help Workshop to compile HTML into Microsoft's CHM format, a compressed HTML + index format used in MS programs for Help.  It's trivial to create the HHC file required by the Workshop as long as part of the HTML generation process.

Ken

I've appended the guts of the HHC generation stylesheet in case anyone's interested:
[The document's root is element is "manual" with "activities" and one or more "chapter" elements within that.]
....

<xsl:template match="/" >
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft HTML Help Workshop 4.1" />
<xsl:comment>Site Generator 1.0</xsl:comment>
</HEAD>
<BODY>
<OBJECT type="text/site properties"></OBJECT>
<UL>
<xsl:apply-templates />
</UL>
</BODY>
</HTML>
</xsl:template>

<xsl:template match="manual">
<xsl:apply-templates select="activities"/>
<xsl:apply-templates select="//chapter" />
</xsl:template>

<xsl:template match="activities">
<xsl:apply-templates select="activity" /></xsl:template>

<xsl:template match="activity">
<LI><OBJECT type="text/sitemap">
<xsl:element name="param">
	<xsl:attribute name="name">Name</xsl:attribute>
	<xsl:attribute name="value"><xsl:value-of select="@wbs-name" /></xsl:attribute>
</xsl:element>
<param name="Local" value="{@wbs-target}.html" />	</OBJECT></LI>
<xsl:if test="./activity">
	<UL>
		<xsl:apply-templates select="./*" />
	</UL>
</xsl:if>
</xsl:template>
<xsl:template match="chapter[starts-with(string(@fullname),'Chapter 1')]">
	</xsl:template>
<xsl:template match="chapter">
<LI><OBJECT type="text/sitemap">
<xsl:element name="param">
	<xsl:attribute name="name">Name</xsl:attribute>
	<xsl:attribute name="value"><xsl:value-of select="@fullname" /></xsl:attribute>
</xsl:element>
<param name="Local" value="{@fullname}.html" />	</OBJECT></LI>
<xsl:if test="./activity">
	<UL>
		<xsl:apply-templates select="./*" />
	</UL>
</xsl:if>
</xsl:template>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]