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 December 28th, 2006, 12:16 PM
Registered User
 
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help getting the difference of two attribute lists

Hi,
I have two lists of attributes ($attr1, $attr2). I want to make a list ($attr3) that will be everything found in $attr1 and NOT in $attr2.
example:

doc1.xml:
Code:
<attr1 a=5 b=6 c=7/>
<attr2 c=7 b=6/>
Running this code:
Code:
<xsl:variable name="attr1" select="attr1\@*"/>
<xsl:variable name="attr2" select="attr2\@*"/>
Returns this:

$attr1[0] = 'a' 5
$attr1[1] = 'b' 6
$attr1[2] = 'c' 7

$attr2[0] = 'c' 7 // Notice that its not ordered
$attr2[1] = 'b' 6

What I would like to get in attr3 is this:

$attr3[0] = 'a' 5 <- in attr1 and NOT in attr2

I looked around, and found some formula, that didnt work $attr1[count(.|$attr2)=count($attr2)]..

Code:
<xsl:variable name="attr3" select="$attr1[count(.|$attr2)=count($attr2)]"/>

attr3 came out empty..

If you have anything that might help me, please let me know, iam quite lost..

Thanks,
Shlomi





Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace an attribute with another attribute georgemeng XSLT 8 June 10th, 2008 11:04 AM
Lists rickyoung Pro Visual Basic 2005 0 November 24th, 2006 09:04 AM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM
Lists Martyn Forum and Wrox.com Feedback 9 June 6th, 2003 11:03 AM
Email Lists Jeff Mason Forum and Wrox.com Feedback 43 June 5th, 2003 11:39 AM





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