Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 16th, 2008, 01:05 PM
Registered User
 
Join Date: Aug 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default convert nodeset to a single node

I'm a new in xslt. My problem is, I cannot find the way to convert the nodeset to a single node. Let's see the following input and expected result

[u]input</u>
Code:
<mynode>
    <token>A</token>
    <token>B</token>
    <token>C</token>
</mynode>
[u]expected result</u>
Code:
<newnode>A B C</newnode>
can anyone helps?

 
Old August 17th, 2008, 03:08 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

With XSLT 2.0 this is simply

<xsl:template match="mynode">
  <newnode>
    <xsl:value-of select="token"/>
  </newnode>
</xsl:template>

With 1.0 it's

<xsl:template match="mynode">
  <newnode>
    <xsl:for-each select="token">
      <xsl:value-of select="."/>
      <xsl:if test="position()!=last()">
        <xsl:text> </xsl:text>
      </
    </
  </
</

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old August 18th, 2008, 10:01 AM
Registered User
 
Join Date: Aug 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks Michael,






Similar Threads
Thread Thread Starter Forum Replies Last Post
Reversing nodeset sudhish.sikhamani XSLT 3 June 19th, 2008 11:43 AM
Convert attribute to node-set using xalan Coolcampers XSLT 1 May 3rd, 2008 06:06 AM
Nodeset as Parameter... venutm XSLT 6 February 24th, 2006 03:07 PM
select single node bcadmin BOOK: XSLT Programmer's Reference, 2nd Edition 1 November 10th, 2004 12:15 PM
ASP.Net Single Single-on with Oracle Application S guhanath Oracle 0 October 6th, 2004 05:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.