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

RE: Concatenation of Element Values

Subject: RE: Concatenation of Element Values
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 22 Jun 2007 09:42:20 +0100
RE:  Concatenation of Element Values
<xsl:template match="ADDRESS">
  <xsl:for-each select="ADDRESSFIELD/ID">
    <xsl:value-of select="../*[name()=concat('addressField', current())"/>
    <xsl:if test="position()!=last()">;</xsl:if>
  </xsl:for-each>
</xsl:template>

(I'm assuming here that addressField2, etc, are siblings of ADDRESS, but you
didn't make this clear).

Incidentally, coding data into element names like this feels like bad XML
design. <addressField id="2"> would be much cleaner than <addressField2>.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Mariecon Saberon [mailto:yc0n2x@xxxxxxxxx] 
> Sent: 22 June 2007 05:08
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Concatenation of Element Values
> 
> hi list,
> 
> i'm a newbie on XSL and i'm really overwhelmed by the 
> information i've  seen on the internet that i'm already 
> confused as to how i'm going to  come up with the rights 
> codes for my program. here's my problem..
> 
> i have an xml that's like this:
> <ADDRESS>
>     <ADDRESSFIELD>
>             <ID>2</ID>
>     <ADDRESSFIELD>
>     <ADDRESSFIELD>
>             <ID>5</ID>
>     <ADDRESSFIELD>
>     <ADDRESSFIELD>
>             <ID>9</ID>
>     <ADDRESSFIELD>
> <ADDRESS>
> 
> then i also have some post parameters:
> <addressField2>some Street address</addressField2> 
> <addressField5>some Town address</addressField5> 
> <addressField9>some City address</addressField9>
> 
> and this is the value i need to get:
> <addressField2>;<addressField5>;<addressField9>
> ex. some Street address; some Town address; some City address
> 
> so far, this is what i have:
> <xsl:template match="ADDRESS">
>     <xsl:for-each select="ADD">
>         <xsl:call-template name="getAdd">
>             <xsl:with-param name="addField">
>                 in_add<xsl:value-of select="ID"/>
>             </xsl:with-param>
>         </xsl:call-template>
>     </xsl:for-each>
> </xsl:template>
> 
> <xsl:template name="getAdd">
>     <xsl:param name="addField"/>
> 
>     <!-- this is where i'm lost. i'm lost on how im gonna get 
> the  address field values and concatenate them -->
>  
> </xsl:template>
> 
> 
> 
> hope someone can shed some light on my blurry mind. 
> any help is
>  greatly greatly appreciated.  thanks!
> 
> -ycon
> 
> 
>  
> ______________________________________________________________
> ______________________
> Never miss an email again!
> Yahoo! Toolbar alerts you the instant new Mail arrives.
> http://tools.search.yahoo.com/toolbar/features/mail/

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.