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

strange problem with string-replace

Subject: strange problem with string-replace
From: Frederic Schwebel <schwebel@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Feb 2000 10:22:45 +0100 (MET)
string replace line feed
Hi,

I'm trying to change MathML into ASCII Braille with XSLT. In Braille, a
mathematical expression has no space and no Line Feed. So I put the string
in a param name and use the "string-replace" template gracefully sent to
me by the Guru David Carlisle. And I get a really strange and annoying
result : when I aks "string-replace" to remove all x or y or &#236; or any
other printable character, it works perfectly. But when I wand to remove
all &#13; (line feed) or &#32; (space) I have a
java.lang.StackOverFlowError, both with xt and saxon (win32 executables) 
!!! My stylesheet is small, and I have 64 Mb RAM, so stack shouldn't be a
problem... And even if it was, why would there be a problem only with
spaces and line feeds ? Do these chars have a special characteristic I
don't know ?

My stylesheet and a MathML example are attached.

Thanks a lot, because I really wonder what's wrong...
Frederic
<?xml version='1.0' encoding="ISO-8859-1" ?>

<!DOCTYPE xsl:stylesheet [

  <!ENTITY bra1  "&#226;">

  <!ENTITY bra2  "&#234;">

  <!ENTITY bra3  "&#238;">

  <!ENTITY bra4  "&#244;">

  <!ENTITY bra5  "&#251;">

  <!ENTITY bra6  "&#235;">

  <!ENTITY bra7  "&#239;">

  <!ENTITY bra8  "&#252;">

  <!ENTITY bra9  "&#230;">

  <!ENTITY bra0  "&#191;">

  <!ENTITY racine  "&#64;">

  <!ENTITY fin  "&#59;">

  <!ENTITY return "&#13;">

]>





<xsl:stylesheet version="1.0"

xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output method="text" encoding="ISO-8859-1" indent="no"/>



<xsl:variable name="from">&return;</xsl:variable> 



<!-- *******************************************

     Procedure qui enleve les espaces et les line feed

     ******************************************* -->

<xsl:template name="string-replace" >

  <xsl:param name="string"/>

  <xsl:choose>

    <xsl:when test="contains($string,$from)">

      <xsl:value-of select="substring-before($string,$from)"/>

      <xsl:call-template name="string-replace">

        <xsl:with-param name="string" select="substring-after($string,$from)"/>

      </xsl:call-template>

    </xsl:when>

    <xsl:otherwise>

      <xsl:value-of select="$string"/>

    </xsl:otherwise>

  </xsl:choose>

</xsl:template>



<!-- *******************************************

     On commence au tag Math et on ignore le reste

     ******************************************* -->

<xsl:template match="*|@*">

               <xsl:apply-templates/>

</xsl:template>



<xsl:template match="math">

    <xsl:param name="equation">

	<xsl:text>'</xsl:text>

            <xsl:apply-templates/>

    </xsl:param>

    <xsl:call-template name="string-replace">

       <xsl:with-param name="string" select="$equation"/>

    </xsl:call-template>

    <xsl:value-of select="$equation"/>

</xsl:template>



<xsl:template match="mi|mtext|ms">

	<xsl:value-of select="normalize-space(.)"/>

</xsl:template>

<xsl:template match="mrow|none|mspace|semantics">

	<xsl:apply-templates/>

</xsl:template>



<!-- *******************************************

       Traduction des chiffres et des signes

     ******************************************* -->

<xsl:template match="mn">

        <xsl:value-of select="translate(.,'1234567890','&bra1;&bra2;&bra3;&bra4;&bra5;&bra6;&bra7;&bra8;&bra9;&bra0;')" />

</xsl:template>

<xsl:template match="mo">

        <xsl:value-of select="translate(.,'+-/*','!-/(')" />

</xsl:template>



<!-- *******************************************

         Racines

     ******************************************* -->

<xsl:template match="msqrt"> 

	<xsl:text>&racine;</xsl:text>

	<xsl:apply-templates/>

	<xsl:text>&fin;</xsl:text>

</xsl:template> 



<!-- *******************************************

         Fractions

     ******************************************* -->

<xsl:template match="mfrac">

        <xsl:apply-templates select="child::*[1]"/>/

	<xsl:apply-templates select="child::*[2]"/>

</xsl:template>



<!-- *******************************************

         Exposants et indices

     ******************************************* -->

<xsl:template match="msup">

        <xsl:apply-templates select="child::*[1]"/>^

	<xsl:apply-templates select="child::*[2]"/>&fin;

</xsl:template>

</xsl:stylesheet>

<math>

   <mrow>

      <msqrt>

         <mrow>

            <mfrac>

               <mrow>

                  <msup>

                     <mi>x</mi>

                     <mn>2</mn>

                  </msup>

                  <mo>+</mo><mn>3</mn>

               </mrow>

               <mrow>

                  <mn>4</mn><mi>x</mi>

               </mrow>

            </mfrac>

            

         </mrow>

      </msqrt>

      

   </mrow>

</math>



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.