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 November 30th, 2009, 06:27 PM
Authorized User
 
Join Date: Jul 2009
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
Default copy with conditions

hi,

I have a sample XML like this :

<BAGR>
<Lap>CHP</Lap>
<Ord>
<Nbr>123455655544</Nbr>
<Ind>1</Ind>
<Prod>
<Snd>1</Snd>
<Rnd>1</Rnd>
<PCA>1231312331287</PCA>

</Prod>
<Prod>
<Snd>1</Snd>
<Rnd>0</Rnd>
<PCA>9231312331287</PCA>

</Prod>
<Prod>
<Snd>1</Snd>
<Rnd>0</Rnd>
<PCA>7231312331287</PCA>

</Prod>
<Prod>
<Snd>1</Snd>
<Rnd>1</Rnd>
<PCA>231312331287</PCA>

</Prod>
</Ord>
</BAGR>

i need the o/p as

<BAGR>
<Lap>CHP</Lap>
<Ord>
<Nbr>123455655544</Nbr>
<Ind>1</Ind>
<Prod>
<Snd>1</Snd>
<Rnd>1</Rnd>
<PCA>1231312331287</PCA>

</Prod>

</Prod>
<Prod>
<Snd>1</Snd>
<Rnd>1</Rnd>
<PCA>231312331287</PCA>

</Prod>
</Ord>
</BAGR>

i need to filter based on <Snd/> and <Rnd/> i.e o/p only if Snd=1 and Rnd=1

Can this be done with xsl:copy-of in one shot in version xslt v1.0

Thanks a lot in advance
 
Old November 30th, 2009, 07:04 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Looks like

Code:
<xsl:copy-of select="Prod[Snd=1 and Rnd=1]"/>
(This seems too easy, am I missing something?)
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
scubin (December 3rd, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing whitespaces with certain conditions trishla XSLT 16 October 4th, 2007 05:35 PM
Multiple conditions austinf XSLT 1 May 5th, 2006 02:55 AM
Multiple conditions austinf XSLT 1 May 5th, 2006 02:38 AM
Query for two conditions needed doosti SQL Language 2 November 9th, 2004 06:24 AM
Conditions in looping sridevi XSLT 0 July 31st, 2004 06:11 AM





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