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

Re: Concat state-city together

Subject: Re: Concat state-city together
From: Xiaocun Xu <xiaocunxu@xxxxxxxxx>
Date: Mon, 30 Jul 2001 06:28:17 -0700 (PDT)
concat rows to column
Thanks for the suggestion, it made a lot of sense and
worked great.

Much appreciated,
Xiaocun

--- Alexander Gutman <gutman@xxxxxxxxxxxxxxx> wrote:
> Helo.
> 
> One of possible solutions is presented below.
> If you want the output to be text rather than XML,
> use
> <xsl:output method="text"/> and modify the templates
> accordingly.
> 
>   <xsl:template match="/*">
>     <pairs>
>       <xsl:apply-templates
> select="row[cell[@column='2']]"/>
>     </pairs>
>   </xsl:template>
> 
>   <xsl:template match="row">
>     <pair>
>       <xsl:variable name="state-row" 
>
select="preceding-sibling::row[cell[@column='1']][1]"/>
>       <xsl:choose>
>         <xsl:when test="$state-row"><xsl:value-of 
> select="$state-row/cell"/></xsl:when>
>         <xsl:otherwise>Unknown</xsl:otherwise>
>       </xsl:choose>
>       <!---->-<xsl:value-of select="cell"/>
>     </pair>
>   </xsl:template>
> 
> Xiaocun Xu wrote:
> >   I am having problem figure this out, so any help
> is
> > appreciated.
> >   I have a source document, where a row contain
> either
> > state or city names.  State names are always
> located
> > at cell/@column=1 and city names are always
> > cell/@column=2.  I want to concat each of the city
> > names with the last state name in the previous
> rows.
> > Following is an example:
> > 
> > Source XML:
> > <row row="17">
> >       <cell column="1">Alabama</cell>
> > </row>
> > <row row="18">
> >       <cell column="2">Birmingham</cell>
> > </row>
> > <row row="19">
> >       <cell column="2">Hoover</cell>
> > </row>
> > <row row="20">
> >       <cell column="1">Arizona</cell>
> > </row>
> > <row row="21">
> >       <cell column="2">Phoenix</cell>
> > </row>
> > <row row="22">
> >       <cell column="2">Tucson</cell>
> > </row>
> > <!-- more states and cities follows -->
> > 
> > Target text:
> > Alabama-Birmingham
> > Alabama-Hoover
> > Arizona-Phoenix
> > Arizona-Tucson
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.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.