|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Grouping without Duplicates IssuesMichael Kay mike at saxonica.comMon Jan 28 22:30:39 PST 2008
> where distinct-values(contains($para,'hey') or > contains($note,'hey')) I've tried to explain this to you before (several times) but the message clearly hasn't sunk in, so let's try again. distinct-values() is a function. It expects to get a sequence of atomic values as its input (supplied in the parameter), and it returns a sequence of atomic values as its output (supplied as the result). The result of the function depends only on the value supplied as its argument. If you write an expression as the argument of a function, the expression is evaluated to produce a value, and that value is passed to the function. In this case the expression that you have passed is contains($para,'hey') or contains($note,'hey') The result of contains() is always a single boolean value, the value true or false. The result of combining two boolean values using "and" or "or" is always a single boolean value. So the argument you are passing to distinct-values() is either the value true, or the value false. In XDM a single atomic value (in this case a boolean value) is the same as a sequence containing that one value. distinct-values() looks at the input sequence and eliminates duplicates, returning those items from the input sequence that aren't duplicated. If the input sequence is a singleton then it can't contain any duplicates, so distinct-values() returns the singleton sequence unchanged. Now, writing a function that does nothing might do no harm. But at the very least, it suggests that you're confused about the logic. Your first step should be to get rid of it. Then try to work out the right way of doing what you thought this function might be doing. I've spent five or ten minutes writing this response in the hope that you will learn from it and not make the same mistake again, which will save everyone time in the future. If you come back with another query showing the same error in a week's time, I shall give up. Michael Kay http://www.saxonica.com/
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






