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]
Other format: [Raw text]

Re: searching and replacing


  
Thank you all for your reply....

2. are trying to produce an exact copy of your input. That is,
<sub>foo</sub> in becomes <sub>foo</sub> out;
Not true.  I don't have <sub> as a node in the document.  What I have is & lt; sup & gt; (separated with a space to avoid the email system to convert it to <sub>).  The xslt is not treating that as a <sub> node.  This is why I did what I did.  I am sure there might be a better way to do it.  If so, pls point me to the write link?  Thank you 
4. think there are 'address' elements in your source tree, when there are
in fact none;
This was a typo.  I was testing something else and did a copy and past of a wrong one.  
<xsl:template match="document//*">
    <xsl:call-template name="supsubstring">
                   <xsl:with-param name="Text" select="."/>
    </xsl:call-template>    
</xsl:template>
is what I intended to send.  

I AM REATTACHING THE FILES WITH some changes.  ('& lt; sub & gt;'  space is intentional)

Thanks


<!-- 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 & lt; sup & gt; L & lt; /sup & gt; ***</name>  
        <name>testing agian & lt; sup & gt;L & lt;/sup & gt; AFTER ***</name>
        <line1>
            <line2>
                    <line3>
                           testing lines subscript & lt; sub & gt; & lt; /sub & gt; ***        
                    </line3>
            </line2>
        </line1>
        <name>last one & lt; sub & gt; L & lt; / sub & gt; 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"; >
             
            <!-- SUBSCRITPT -->
 <xsl:template name="supsubstring">
             <xsl:param name="Text"/>
            <xsl:choose>
                    <xsl:when test="contains($Text, '& lt; sub & gt;')">
                          <xsl:value-of select="substring-before($Text,  '& lt; sub & gt;')" />
                           <xsl:variable name="stringaftersub" select="substring-after($Text, '& lt; sub & gt;')" />
                           <sub>
                                <xsl:value-of select="substring-before($stringaftersub,  '& lt; /sub & gt;')" />
                            </sub>
                            <xsl:value-of select="substring-after($stringaftersub, '& lt; /sub & gt;')" />
                    </xsl:when>
                    
                    <!-- SUPERSCRIPT -->
                    <xsl:when test="contains($Text, '& lt; sup & gt;')">
                          <xsl:value-of select="substring-before($Text,  '& lt; sup & gt;')" />
                           <xsl:variable name="stringaftersup" select="substring-after($Text, '& lt; sup & gt;')" />
                           <sup>
                                <xsl:value-of select="substring-before($stringaftersup,  '& lt; /sup & gt;')" />
                           </sup>
                         <xsl:value-of select="substring-after($stringaftersup, '& lt; /sup & gt;')" />
                    </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


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