xsl-list
[Top] [All Lists]

[xsl] Question on search and replace in XSL

2012-04-04 16:18:14
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(_at_)KRAMERLEVIN(_dot_)com
<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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


<Prev in Thread] Current Thread [Next in Thread>