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

A simple solution (Was: Re: One for tomorrow :-) )

Subject: A simple solution (Was: Re: One for tomorrow :-) )
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Tue, 3 Jul 2001 12:17:19 -0700 (PDT)
xsl get tomorrow date java
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 "following
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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:for-each select="/Item/NameAddress1">
      <xsl:value-of select="."/>
      <xsl:for-each
select="following-sibling::*[substring(.,string-length(.))=',']">
         <xsl:value-of select="."/>
      </xsl:for-each>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

Hope this helped.

Cheers,
Dimitre Novatchev.




__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

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


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.