xsl-list
[Top] [All Lists]

Re: many node values into one??

2005-06-08 16:22:39
Hi, Wendi,

That question has many possible answers, depending on the XML source, what
you really want, and which version of XSLT you use.

The best thing to do is show us a small but complete snippet of your XML
source, your best XSL attempt, and your desired output (be it XML, HTML,
text, or whatever).

However, here's a shot at a generic answer:

Assuming you have a structure like this:

<x>
  <y>Banana</y>
  <y>Strawberry</y>
</x>

you can join them thus (in XSLT 1.0 or XSLT 2.0):

<xsl:template match="x">
  <out>
    <xsl:for-each select="y">
      <xsl:value-of select="."/>
    </xsl:for-each>
  </out>
</xsl:template>

or thus (in XSLT 2.0):

<xsl:template match="x">
  <out><xsl:value-of select="y" separator=""/></out>
</xsl:template>

If you have a structure like this:

<x>
  <y>Banana</y>
  <z>Strawberry</z>
</x>

you can join them thus (in XSLT 1.0 or XSLT 2.0):

<xsl:template match="x">
  <out><xsl:value-of select="y"/><xsl:value-of select="z"/></out>
</xsl:template>

or thus (in XSLT 2.0):

<xsl:template match="x">
  <out><xsl:value-of select="y|z" separator=""/></out>
</xsl:template>

I tested all of those and got <out>BananaStrawberry</out> as the result each
time.

Note that there are other ways to do it, some of which may be better
(depending on what you are actually trying to do).

HTH

Jay Bryant
Bryant Communication Services

----- Original Message ----- 
From: "Wendi Turner" <wenditurner(_at_)earthlink(_dot_)net>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>; 
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Cc: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Wednesday, June 08, 2005 5:31 PM
Subject: [xsl] many node values into one??


how can i get to node values to translate into one node value?

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>