Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get corrent rtf formating in xslt

Status
Not open for further replies.

MeonR

Programmer
Aug 16, 2002
97
US
Hello All:

I am using this xslt file to create an .rtf file. This works
with one problem the resulting .rtf file has some formatting
problems, i.e. the two colums of text are out of alignment, looking something like this:
Jan:0.115
Feb:1.003
Mar: 0.0016 //This is the problem
Apr:1.012

Any ideas on how to fix this?
Thanks In Advance
MeonR
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="<xsl:preserve-space elements="months"/>
<xsl:strip-space elements="seasonal"/>
<xsl:eek:utput method="text"/>
<xsl:template match="/">

<xsl:text>{\rtf1</xsl:text>
<xsl:text>Season Index</xsl:text>
<xsl:for-each select="SeasonIndex/SIDX">
<xsl:text>\par\b </xsl:text>
<xsl:value-of select="months"/><xsl:text>:</xsl:text>
<xsl:value-of select="seasonal"/>
<xsl:text>\b0\i </xsl:text>
<xsl:text>\i0\par </xsl:text>
</xsl:for-each>

<xsl:text>}</xsl:text>

</xsl:template>

</xsl:stylesheet>


"The beatings will continue until morale improves
 
The issue may not be resolved without making assumption on the xml file to transform. If it is unbreakable-space which is blocking the way, you can replace it by soft space or empty space before rtf formatting. Like this.
[tt]
<xsl:text>\par\b </xsl:text>
<xsl:call-template name="replace_sab">
<xsl:with-param name="s" select="months" />
<xsl:with-param name="a" select="'&#160;'" />
<xsl:with-param name="b"><xsl:text></xsl:text></xsl:with-param>
</xsl:call-template>
<xsl:text>:</xsl:text>
<xsl:call-template name="replace_sab">
<xsl:with-param name="s" select="seasonal" />
<xsl:with-param name="a" select="'&#160;'" />
<xsl:with-param name="b"><xsl:text></xsl:text></xsl:with-param>
</xsl:call-template>
<xsl:text>\b0\i </xsl:text>
<xsl:text>\i0\par </xsl:text>
[/tt]
At the place of the corresponding original script block.

And then paste a named template "replace_sab" that I used and posted to a previous thread.
 
Hello tsuji

Thanks for you help. I will be trying it.

MeonR




"The beatings will continue until morale improves
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top