Subject: Re: [xsl] Question on search and replace in XSL From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx> Date: Thu, 5 Apr 2012 07:44:36 +0200 |
It seems to me that APNameSplit was originally written for arguments "text" that might contain more than one semicolon - note the recursive invocation after splitting off the first part. I've removed everything that does not agree with the new spec of "<one>;<<two>". <tr> <td valign="top" width="180">Adverse Party:</td> <xsl:apply-templates select="APName" /> </tr> <xsl:template name="APNameSplit"> <xsl:param name="text" select="string('')"/> <xsl:choose> <xsl:when test="contains($text,$find)"> <td valign="top" style="font-weight:normal"> <xsl:value-of select="substring-before($text,';')"/> </td> <td valign="top" style="font-weight:normal"> <xsl:value-of select="substring-after($text,';')"/> </td> </xsl:when> <xsl:otherwise> <td colspan="2" valign="top" style="font-weight:normal"> <xsl:value-of select="$text"/> </td> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="APName"> <xsl:call-template name="APNameSplit"> <xsl:with-param name="text" select="."/> </xsl:call-template> </xsl:template> -W On 04/04/2012, Peterson, Melanie S. <MPeterson@xxxxxxxxxxxxxxx> wrote: > Hi - I have an XSL template that's used to format an email message and I > need to change the formatting. I did the original formatting, but I haven't > touched it in at least 2 years and I'm way beyond rusty with XSL. I'm > hoping someone can give me a hand. Here's the issue: > > I currently get data from our database with two fields separated by > semi-colons. The semi-colons are currently replaced in the template by a > <br/>, so the two fields appear one on top of the other. What I need to do > is change this so that they appear next to each other in a tabular format. > So now the email looks like this, assuming two records one with two fields > xxx and yyy and the second with two fields zzz and www: > > xxx > yyy > > > zzz > www > > What I want is: > > xxx yyy > zzz www > > Here's my current code: > > .... > <tr> > <td valign="top" width="180">Adverse Party:</td> > <td valign="top" style="font-weight:normal"> > <xsl:apply-templates select="APName" /> > </td> > </tr> > .... > > > <xsl:template name="APNameSplit"> > <xsl:param name="text" select="string('')"/> > <xsl:param name="find" select="string(';')"/> > <xsl:choose> > <xsl:when test="$find = ''"> > <xsl:value-of select="$text"/> > </xsl:when> > <xsl:when test="contains($text,$find)"> > <xsl:value-of select="substring-before($text,$find)"/> > <br/> > <xsl:call-template name="APNameSplit"> > <xsl:with-param name="text" select="substring-after($text,$find)"/> > <xsl:with-param name="find" select="$find"/> > </xsl:call-template> > </xsl:when> > <xsl:otherwise> > <xsl:value-of select="$text"/> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > > <xsl:template match="APName"> > <xsl:call-template name="APNameSplit"> > <xsl:with-param name="text" select="."/> > <xsl:with-param name="find" select="string(';')"/> > </xsl:call-template> > </xsl:template> > > Can anyone give me a hand on how to begin? > > Thanks! > > Melanie Peterson > Project Coordinator/Systems Developer > Kramer Levin Naftalis & Frankel LLP > 1177 Ave. of the Americas > New York, NY 10036 > 212-715-7738 > > > Melanie S. Peterson > > > > Melanie S. Peterson > > Project Coordinator/Systems Developer > Kramer Levin Naftalis & Frankel LLP > 1177 Avenue of the Americas > New York, New York 10036 > Tel: 212-715-7738 > Fax: 212-715-8000 > Email: MPeterson@xxxxxxxxxxxxxxx > <http://www.kramerlevin.com/> > > > This communication (including any attachments) is intended solely for the > recipient(s) named above and may contain information that is confidential, > privileged or legally protected. Any unauthorized use or dissemination of > this communication is strictly prohibited. If you have received this > communication in error, please immediately notify the sender by return > e-mail message and delete all copies of the original communication. Thank > you for your cooperation.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Question on search and re, G. Ken Holman | Thread | [xsl] upgrading Stylesheets, Szabo, Patrick \(LNG |
Re: [xsl] Question on search and re, G. Ken Holman | Date | [xsl] for-each-group group-by, Craig Sampson |
Month |