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

Re: many node values into one??

Subject: Re: many node values into one??
From: "Jay Bryant" <jay@xxxxxxxxxxxx>
Date: Wed, 8 Jun 2005 18:22:39 -0500
xslt node value
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@xxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>; <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Cc: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, June 08, 2005 5:31 PM
Subject:  many node values into one??


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

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.