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


Hello Norm,

the problem: I can't see any <address/> in your XML-file, so no element 
is matching "address//*" and so the template "supsubstring" is never called.

You say, your template "supsubstring" works? This applies, that your 
mail-client transforms &lt ; back to < - is it so? Otherwise it should 
not work.

What's when in one element there is a &lt ;sup&gt ; and &lt ;sub&gt;? 
Maybe you need a more recursive approach.

Regards,

Joerg

normbishop1@netscape.net wrote:
> 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>


 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]