[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Help comparing an attribute to a Node-Set

Subject: Re: Help comparing an attribute to a Node-Set
From: Dimtre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sun, 19 Sep 2004 09:01:18 +1000
guid comparing
This is a FAQ. 

   $value != $nodeSet 

returns true if there's at least one node in $nodeSet whose value is
not equal to $value.

Even if there is some node in $nodeSet whose value is equal to $value,
there would be typically many other nodes with different values, so
the comparison above would be true.

This is not what you want (and in fact Michael Kay warns strongly
against using the != operator in his book).

Therefore, use:

     not( $value = $nodeSet )

This returns true if there isn't any node in $nodeSet whose value is
equal to $value.


Cheers,

Dimitre Novatchev


On Sat, 18 Sep 2004 12:42:20 -0700 (PDT), Charlie Consumer
<faceless1976@xxxxxxxxx> wrote:
> Hi,
> 
> I have a question about comparing a single attribute
> to a set of nodes.  I'm trying to remove any XML
> elements where their @GUID attribute is equal to one
> of the GUIDs (guid0 or guid1) in another document.
> The comparison I'm doing right now always returns true
> which causes all the the nodes to be added.  I want to
> only add the elements in the source XML whose GUID's
> are not in the other document either guid0 or guid1.
> Without posting the entire document here is my some
> excerts I'm using right now:
> 
> <xsl:template match="Rule">
>  <xsl:if test="@GUID!=member/@guid0 and
> @GUID!=member/@guid1">
>  <xsl:element name="{name(.)}" >
>      <xsl:copy-of select="@*"/>
>      <xsl:apply-templates/>
>    </xsl:element>
>  </xsl:if>
> </xsl:template>
> 
> The source to the XSL is:
> 
> <Rule GUID="zzzzzzzzzz" Enabled="true"
> Action="Allow"/>
> <Rule GUID="yyyyyyyyyy" Enabled="true" Action="Deny"/>
> <Rule GUID="wwwwwwwwww" Enabled="true"
> Action="Allow"/>
> 
> The other document XML is:
> 
> <member guid0="aaaaaaaaaa" guid1="yyyyyyyyyy"/>
> <member guid0="zzzzzzzzzz" guid1="xxxxxxxxxx"/>
> <member guid0="bbbbbbbbbb" guid1="cccccccccc"/>
> 
> The expected result would be:
> 
> <Rule GUID="wwwwwwwwww" Enabled="true"
> Action="Allow"/>
> 
> Any ideas what I'm doing wrong?
> 
> Thanks
> Charlie
> 
> __________________________________
> Do you Yahoo!?
> Read only the mail you want - Yahoo! Mail SpamGuard.
> http://promotions.yahoo.com/new_mail

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.