RE: [xsl] Data from DB in xsl

Subject: RE: [xsl] Data from DB in xsl
From: Jarno.Elovirta@xxxxxxxxx
Date: Thu, 29 Aug 2002 07:17:36 +0300
Hi,

> on writing the code you gave me, i get the error below:
> 
> "Unexpected character in query string. contains($sText,-->\<--n\n)"
> 
> here is my code:
> 
> <xsl:template name="paragrapher">
> 	<xsl:param name="sText"/>
> 	<xsl:if test="contains($sText,\n\n)">
> 		<p>
> 			<xsl:value-of 
> select="substring-before($sText,\n\n)"/>
> 		</p>
> 	</xsl:if>
> </xsl:template>

Yes, well, that was pseudo-code - XPath doesn't use \n to denote a LINE FEED character. And you missed the else clause, too.

<xsl:template name="paragrapher">
  <xsl:param name="sText"/>
  <xsl:choose>  
    <xsl:when test="contains($sText, '&#xA;&#xA;')">
      <p>
        <xsl:value-of select="substring-before($sText, '&#xA;&#xA;')"/>
      </p>
	<xsl:call-template name="paragrapher">
        <xsl:with-param name="sText" select="substring-after($sText, '&#xA;&#xA;')" />
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <p>
        <xsl:value-of select="$sText"/>
      </p>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Jarno

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


Current Thread