Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2010, 02:10 AM
Registered User
 
Join Date: Mar 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default superscript conversion in XSL doesnt work.

Hi,

I have a xml with para and superscript. i need to parse it with XSL and add formatting with RTF tag and display it in rich text box (VB.net, Winform).
When I do it I am not getting superscrip correctly processed. I need to remove unwanted space also from text. Am I doing some thing wrong? Can any one please help?

<xsl:stylesheet xmlns:..Transform" version="2.0">
<xsl:output media-type="text" indent="no" method="text" />
<xsl:template match="/">
<xsl:text>{\rtf1\... </xsl:text>
<xsl:text>\viewkind4\uc1\pard\qc\b\f0\fs28 </xsl:text>
<xsl:apply-templates select="sample/HeaderBox/subsection/para" />
<xsl:text> \par</xsl:text>
<xsl:for-each select="sample/subsection">
<xsl:apply-templates select="para" /><xsl:text> \par </xsl:text>
</xsl:for-each>
</xsl:template>

<xsl:template match="para">
<xsl:value-of select="normalize-space(.)"/>
<xsl:apply-templates select="Superscript" />
</xsl:template>

<xsl:template match="Superscript">
<xsl:text> \super\noextrasprl </xsl:text><xsl:value-of select="."/><xsl:text> \nosupersub </xsl:text>
</xsl:template>
</xsl:stylesheet>


XMl:
<sample>
<HeaderBox> <subsection> <para>Sample title</para> </subsection>
</HeaderBox>
<subsection>
<para> Sample Para <Superscript>10</Superscript> ended here. </para>
</subsection>
<subsection>
<para> second Sample Para ended here. <Superscript>1-2</Superscript> </para>
</subsection>
</sample>

But when I convert, instead of expected output " Sample \super 10 \nosuper ended here"

Output is coming like :" Sample 10 ended here \super 10 \nosuper ".

The superscript should parse along with that position. But its getting arsed seperately. Any friends, please help on this?
 
Old March 29th, 2010, 02:38 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Try the below:
Code:
<xsl:template match="/">
<xsl:text>{\rtf1\... </xsl:text>
<xsl:text>\viewkind4\uc1\pard\qc\b\f0\fs28 </xsl:text>
<xsl:apply-templates select="sample/HeaderBox/subsection/para" />
<xsl:text> \par</xsl:text>
<xsl:apply-templates select="sample/subsection/para"/>
</xsl:template>
<xsl:template match="sample/subsection/para">
<xsl:apply-templates/><xsl:text> \par </xsl:text>
</xsl:template>

<xsl:template match="para">
<xsl:value-of select="normalize-space(.)"/>
<xsl:apply-templates select="Superscript" />
</xsl:template>
<xsl:template match="Superscript">
<xsl:text> \super\noextrasprl </xsl:text><xsl:value-of select="."/><xsl:text> \nosupersub </xsl:text> 
</xsl:template>
__________________
Rummy





Similar Threads
Thread Thread Starter Forum Replies Last Post
c:out doesnt work tllcll JSP Basics 1 November 1st, 2007 03:15 AM
xsl:key doesnt work cristtiah XSLT 11 May 24th, 2006 09:57 AM
Button doesnt work help john111 Java GUI 4 March 21st, 2006 05:22 PM
ContainsValue doesnt work demitry Generics 1 November 21st, 2005 05:29 PM
WHY DOESNT THIS WORK vb certified Pro VB.NET 2002/2003 5 August 1st, 2005 11:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.