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

Re: Question on search and replace in XSL

Subject: Re: Question on search and replace in XSL
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 04 Apr 2012 17:26:11 -0400
Re:  Question on search and replace in XSL
Are you stuck with XSLT 1.0 or is XSLT 2.0 available to you?

Your current code is already creating two columns ... do you want the new code to create three columns or an embedded table of two columns in the second column of your old code?

Is the current APName something like the following?

<APName>field 1; field 2</APName>

If so, then how do you want the final output with "Adverse Party:" included?

. . . . . . . . Ken

At 2012-04-04 21:17 +0000, Peterson, Melanie S. 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?


--
Public XSLT, XSL-FO, UBL and code list classes in Europe -- May 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

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.