[xsl] RE: A simple solution (Was: Re: One for tomorrow :-) )

Subject: [xsl] RE: A simple solution (Was: Re: One for tomorrow :-) )
From: "Daniel Newman" <daniel.newman@xxxxxxxxxxx>
Date: Wed, 4 Jul 2001 10:09:53 +0100
OK, thanks very much (so far) for this "simple solution". I've got the name
concatenation happening fine, but have reached a bit of a problem with
getting the next node that follows the last node with a comma in it (as was
suggested I wanted!).

The trouble is, I'm producing an HTML table, and the address [NameAddress3]
is in another row, so not sure how I need to go about getting it?

This is what I have so far:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:cs="http://www.computershare.com/scripcomms/v1.0"; >
<xsl:include href="CommonFunctions.xsl" />
<xsl:output method="html" indent="yes" />

<!-- setting color values here, so can change easily -->
<xsl:variable name="LightRow" select="'#FFCC66'" />
<xsl:variable name="DarkRow" select="'#FFEBBF'" />

<xsl:template match="cs:ScripCommsMessage" >
	<xsl:apply-templates select="cs:SearchForHolderResponse" />

<xsl:template match="cs:SearchForHolderResponse" >
	<table cellpadding="2" cellspacing="0">
		<xsl:for-each select="cs:Items/cs:Item">
			<xsl:call-template name="GetTableData" />

<xsl:template name="GetTableData">
      <xsl:call-template name="GenerateRowColor">
	  <xsl:with-param name="Index" select="position()" />
      <td width="4%" valign="top">
		<font face="Arial, Helvetica, sans-serif" size="2"><xsl:value-of
select="position()" /></font>
      <td colspan="2" valign="top">
		<font face="Arial, Helvetica, sans-serif" size="2">
		<a href="/xml_interface/HolderInfo.asp?id={cs:HIN}" class="HolderSearch">
			<xsl:for-each select="cs:NameAddress1">
			<xsl:value-of select="."/>
					<xsl:value-of select="."/>
        	<xsl:value-of select="following-sibling::" /> <---- need to insert
NameAddress3 (or the next node in the 					operation above) in here?
      <td width="16%" nowrap="true" valign="top">
		<font face="Arial, Helvetica, sans-serif" size="2"><xsl:value-of
select="cs:HIN" /></font>


-----Original Message-----
From: Dimitre Novatchev [mailto:dnovatchev@xxxxxxxxx]
Sent: 03 July 2001 20:17
To: daniel.newman@xxxxxxxxxxx
Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: A simple solution (Was: Re: One for tomorrow :-) )

Daniel Newman wrote:

> My XML (I know you've all already got it :), is:
> <Item id="2">
> 	<HIN>G0200328400</HIN>
> 	<PostCode>EC2A 1BR</PostCode>
> 	<NameAddress1>SMITH &amp; WILLIAMSON NOMINEES</NameAddress1>
> 	<NameAddress2>LIMITED &lt;CH&gt;,</NameAddress2>
> 	<NameAddress3>10 ACACIA AVENUE</NameAddress3>
> 	<NameAddress4>HUTTINGDON HILL</NameAddress4>
> 	<NameAddress5>LONDON</NameAddress5>
> 	<NameAddress6/>
> 	<NameAddress7/>
> </Item>
> And my problem is, that I want to display NameAddress1, and also need to
> concat all following Nodes that end in a comma. So I need to do a:

Hi Daniel,

Actually, it is quite simple -- do note the XPath expression for all
Nodes" (in this case following-sibling::*) the text of which ends in a
comma -- this
uses a combnation of the substring() and string-length() functions.

<xsl:stylesheet version="1.0"
  <xsl:template match="/">
    <xsl:for-each select="/Item/NameAddress1">
      <xsl:value-of select="."/>
         <xsl:value-of select="."/>

Hope this helped.

Dimitre Novatchev.

Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail

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

Current Thread