2

Can someone help me out for the following solution:

<xsl:variable name="filterByNameA" select="*/person[firstName=$fname] "/>

I want to do this if possible

 <xsl:variable name="filterByNameA" select="*/person[firstName=$fname] and */person[secondName=$fname]"/>

In other words, I need to have two conditions in one variable in order to get me all of the person elements that have the same firstName and secondName.

1
  • 1
    You know, showing code that doesn't work isn't the best way of explaining your requirements. How are we supposed to know what you thought the code would do, given that this is different from what it actually does? Commented Dec 10, 2013 at 23:15

1 Answer 1

4

Put the two tests inside the same predicate:

<xsl:variable name="filterByNameA" select="*/person[firstName=$fname and secondName=$fname]"/>

Or equivalently, use two predicates:

<xsl:variable name="filterByNameA" select="*/person[firstName=$fname][secondName=$fname]"/>

When you have consecutive predicates like that, each one filters the list that resulted from the one before, so they are effectively anded together

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.