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 July 29th, 2009, 05:43 AM
Authorized User
 
Join Date: Jan 2009
Posts: 36
Thanks: 3
Thanked 0 Times in 0 Posts
Default compare 2 nodesets

Hi,

I have got the following in xml document
<Input>
<Data>
<group/>
<name>EXTENSION_ONE</name>
</Data>
<Data>
<group>GROUP_TWO</group>
<name>EXTENSION_TWO</name>
</Data>
<Data>
<group/>
<name>EXTENSION_THREE</name>
</Data>
</Input>

and the following as a variable in the xsl
<xsl:variable name="dataNames">
<data name="EXTENSION_ONE" group=""/>
<data name="EXTENSION_TWO" group="GROUP_TWO"/>

</xsl:variable>

i would like to get the following output
<Input>
<Data>
<group/>
<name>EXTENSION_ONE</name>
</Data>
<Data>
<group>GROUP_TWO</group>
<name>EXTENSION_TWO</name>
</Data>
</Input>


what i'm trying to do is iterate through the Data in the xml and for each input/Data match the name and group against the name and group in variable dataNames
any ideas on how to do this ?


Last edited by nguna; July 29th, 2009 at 06:03 AM..
 
Old July 29th, 2009, 06:05 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Try this:

Code:
<xsl:for-each select="/Input/Data">
  <xsl:if test="$dataNames/data[@name=current()/name and @group=current()/group">
     <xsl:copy-of select="."/>
  </xsl:if>
</xsl:for-each>
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old July 29th, 2009, 06:45 AM
Authorized User
 
Join Date: Jan 2009
Posts: 36
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Thanks for your help micheal





Similar Threads
Thread Thread Starter Forum Replies Last Post
compare a cell with nothing popaerou Excel VBA 2 October 26th, 2008 12:35 PM
How to compare the value elayaraja.s XSLT 3 July 28th, 2008 07:48 AM
compare Neha XSLT 6 July 24th, 2008 08:11 AM
compare nmnm XSLT 3 April 24th, 2007 08:13 AM
compare these date fields and compare and get the susanring Oracle 1 July 24th, 2006 04:58 PM





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