Re: [xsl] Concat state-city together

Subject: Re: [xsl] Concat state-city together
From: "Alexander Gutman" <gutman@xxxxxxxxxxxxxxx>
Date: Sun, 29 Jul 2001 12:44:52 +0700

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="/*">
      <xsl:apply-templates select="row[cell[@column='2']]"/>

  <xsl:template match="row">
      <xsl:variable name="state-row" 
        <xsl:when test="$state-row"><xsl:value-of 
      <!---->-<xsl:value-of select="cell"/>

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:

Current Thread