Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6079029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:54:01+00:00 2026-05-23T10:54:01+00:00

Is there an exclusive OR ‘XOR’ in XPath1.0 ?

  • 0

Is there an exclusive OR ‘XOR’ in XPath1.0 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:54:02+00:00Added an answer on May 23, 2026 at 10:54 am

    Use this XPath 1.0 expression:

    x and not(y)   or   y and not(x)
    

    Always try to avoid the != operator, because it has an unexpected meaning/behavior when one or both of its arguments are node-sets.

    In XSLT 2.0 or XQuery 1.0 one can write this as a function and then use just the function in any XPath expression. Below is an XSLT 2.0 function definition for xor and a small example of using this function:

    <xsl:stylesheet version="2.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:f="my:f">
     <xsl:output method="text"/>
    
     <xsl:template match="/">
      <xsl:sequence select=
      "for $x in (true(), false()),
           $y in (true(), false())
         return
           ('xor(', $x, ',', $y,') = ', f:xor($x, $y), '&#xA;')
      "/>
     </xsl:template>
    
     <xsl:function name="f:xor">
      <xsl:param name="pX" as="xs:boolean"/>
      <xsl:param name="pY" as="xs:boolean"/>
    
      <xsl:sequence select=
       "$pX and not($pY)   or   $pY and not($pX)"/>
     </xsl:function>
    </xsl:stylesheet>
    

    when this transformation is applied on any XML document (not used), the wanted, correct result is produced:

     xor( true , true ) =  false
     xor( true , false ) =  true 
     xor( false , true ) =  true 
     xor( false , false ) =  false 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to enable exclusive checkouts on clear case? I want that
Is there currently a feature that allows a exclusive checkout in SVN? Is there
Is there a Delphi implementation of an MREW (multiple read, exclusive write) lock, that
I'm looking for a way to make an exclusive checkout from SVN. Is there
Apparently there is no boolean version of the bitwise exclusive-or operator (^^^) ... what
There is a conversion process that is needed when migrating Visual Studio 2005 web
There are two weird operators in C#: the true operator the false operator If
There are two popular closure styles in javascript. The first I call anonymous constructor
There is previous little on the google on this subject other than people asking
There seem to be many ways to define singletons in Python. Is there a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.