[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

searching and replacing

Subject: searching and replacing
From: normbishop1@xxxxxxxxxxxx
Date: Fri, 31 May 2002 02:19:18 -0400
searching and replacing substrings
Hi,

I have written a template to search for any string containing <sub> or <sup> and to do subscript and superscript accordingly.  The template works fine (I think)...

Then I have written these lines ... to search through the document for the sub/sup to do the appropriate..  But, this is not doing the expected... 
<xsl:template match="address//*">
    <xsl:call-template name="supsubstring">
                   <xsl:with-param name="Text" select="."/>
    </xsl:call-template>    
</xsl:template>

Need your help!

Thanking you in advance
Norm


<!-- XML file -->
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type='text/xsl' href='test.xsl'?>
<document id="test">
  <chapter>
        <name>Testing sup/sub</name>    
        <name>test superscript <sup>L</sup> ***</name>
        <name>testing agian <sup>L</sup>AFTER ***</name>
        <line1>
            <line2>
                    <line3>
                           testing lines subscript <sub></sub> ***        
                    </line3>
            </line2>
        </line1>
        <name>last one <sub>L</sub>AFTER***</name>
</chapter>
</document>


<!-- XSL file -->
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:fo="http://www.w3.org/1999/XSL/Format"" xml:space="preserve">
             
            <!-- SUBSCRITPT -->
 <xsl:template name="supsubstring">
             <xsl:param name="Text"/>
            <xsl:choose>
                    <xsl:when test="contains($Text, '<sub>')">
                          <xsl:value-of select="substring-before($Text,  '<sub>')" />
                           <xsl:variable name="stringaftersub" select="substring-after($Text, '<sub>')" />
                           <sub>
                                <xsl:value-of select="substring-before($stringaftersub,  '</sub>')" />
                            </sub>
                            <xsl:value-of select="substring-after($stringaftersub, '</sub>')" />
                    </xsl:when>
                    
                    <!-- SUPERSCRIPT -->
                    <xsl:when test="contains($Text, '<sup>')">
                          <xsl:value-of select="substring-before($Text,  '<sup>')" />
                           <xsl:variable name="stringaftersup" select="substring-after($Text, '<sup>')" />
                           <sup>
                                <xsl:value-of select="substring-before($stringaftersup,  '</sup>')" />
                           </sup>
                         <xsl:value-of select="substring-after($stringaftersup, '</sup>')" />
                    </xsl:when>
                     <xsl:otherwise><xsl:value-of select="$Text" /></xsl:otherwise>    
            </xsl:choose>
        </xsl:template>
    
<xsl:template match="address//*">
    <xsl:call-template name="supsubstring">
                   <xsl:with-param name="Text" select="."/>
    </xsl:call-template>    
</xsl:template> 

</xsl:stylesheet>



 



__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.