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 21st, 2008, 09:51 AM
Registered User
 
Join Date: Aug 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default select nodeset

here is an input

Code:
<parent>
    <c1>value1</c1>
    <c2>value2</c2>
    <c3>value3</c3>
    <c1>value4</c1>
</parent>
I want to select specified nodeset, the following is the result that I expected

Code:
<parent>
    <c1>Value1</c1>
    <c1>Value4</c1>
</parent>
I tried to do this
Code:
<xsl:variable name="myNodeset" select="/parent/c1/*"/>
but it doesn't work

I workaround by using for-each iterate node <c1> and copy them

 
Old August 21st, 2008, 09:54 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Looks like you've answered your own question.

/- Sam Judson : Wrox Technical Editor -/
 
Old August 21st, 2008, 09:05 PM
Registered User
 
Join Date: Aug 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

is that the best way? i'm not sure if there is other solution to solve it

 
Old August 22nd, 2008, 02:51 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well you haven't actually shown us what you have written, so its hard to say really.

I would do it as follows, starting with an identity template, and then add separate templates to control the things you don't want to copy:

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="parent">
  <xsl:copy>
     <xsl:apply-templates select="c1"/>
  </xsl:copy>
</xsl:template>


/- Sam Judson : Wrox Technical Editor -/
 
Old August 22nd, 2008, 10:52 AM
Registered User
 
Join Date: Aug 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks Sam,

your solution is look good to me, because I accually use <xsl:for-each> to iterate thru the nodeset






Similar Threads
Thread Thread Starter Forum Replies Last Post
convert nodeset to a single node newbies1234 XSLT 2 August 18th, 2008 10:01 AM
Reversing nodeset sudhish.sikhamani XSLT 3 June 19th, 2008 11:43 AM
with-param nodeset RoeZ XSLT 6 November 1st, 2007 06:53 PM
comparing nodeset stolte XSLT 7 May 30th, 2007 03:58 PM
Nodeset as Parameter... venutm XSLT 6 February 24th, 2006 03:07 PM





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