In one of the TIBCO Designer .process files I found an expression like this: $SomeValue/text()=0.
What does it mean?
That $SomeValue is null or blank, or what?
Its evaluating the value to a Boolean.. meaning if text() is zero, then the field for which it is mapped becomes true. Generally () are not seen in the xpath values, would be great if you could post the exact statement.
Related
I'm new to Mathematica and I am struggling with the following problem:
If I evaluate the expression N[CDF[NormalDistribution[m,s],x]] for m=12, s=25 and x=10, i get 0.468119 (=the value I would expect), however, if I evaluate the expression CDF[NormalDistribution[m,s],x] for the same x,m,s, i get 0.324195.
I checked the documentation for Mathematica and I cannot spot the difference except that N[..] returns the numerical value of the expression inside the brackets.
Any ideas? Perhaps its soo simple but i don't see it..
Thank you
I have a boolean expression: equals(myStringValue, targetStringValue)
I have an array expression which might or might not be valid, depending on the boolean condition myArrayExpression.
I want to write:
if(
equals(myStringValue, targetStringValue),
myArrayExpression,
?????
)
where ????? is an expression that returns an empty array.
Naturally, this is an XY-problem.
I definitely want to know how to do this directly, because understanding how this language works well is important to me. But if you want to know about the XY problem, it's over here: Azure ADF GetMetadata childItems if folder might not exist
Defining an array variable, with no default value, and then referencing that does work.
But seems very sad - now we've got an extra variable floating around for no reason :(
You can use if (x, Y, skip(createArray(''), 1))
I was wondering what is the difference between the IF statement vs the IIF() function in Tableau. And then I found this page, which explained the syntax difference.
Difference between iif and if
But someone (over a seminar) also told me that IIF() has better performance. Is that true?
Statement vs. Function
The key difference between IF and IIF is that the former is
a statement
IF test THEN value END
IF test THEN value ELSE else END
And the latter is a function
IIF(test, then, else, [unknown])
Another difference, as has been alluded to in the cited link
in the opening question, is that the latter also supports the
notion of a seperate handing for the "unknown" case.
Here is the documentation from Tableau
IIF(test, then, else, [unknown])
. . .
A boolean comparison may also yield the value UNKNOWN (neither TRUE
nor FALSE), usually due to the presence of Null values in test. The
final argument to IIF is returned in the event of an UNKNOWN result
for the comparison. If this argument is left out, Null is returned.
In the IF statement, the handling of the unknown case is lumped into the ELSE block. From the same document
from Tableau cited above
The IF THEN ELSE function evaluates a sequence of test conditions and
returns the value for the first condition that is true. If no condition is true, the ELSE value is returned.
About the Claim About Performance Difference
As for the claim about the performance difference between the two constructs,
I investigated on the claim:
I have conducted quite some search, and I could not found evidence support that claim, either officially by Tableau or by another users.
I conducted a small (anecdotal) experiment and I could not observe any performance
difference (my test involved a dataset of 300MB from a CSV file and has
3.6M rows in it, both methods performed about as fast as each other).
The Tableau employee that told me about the claim seemed to have back-peddled after
I asked her the same question again for confirmation.
So I would classify the claim to be unsubstantiated.
Here is the difference:
IF(Condition, "truevalue", IIF(Condition,"truevalue","falsevalue")) - This statement if it see null value will return "falsevalue".
IIF(Condition, "truevalue", IIF(Condition,"truevalue","falsevalue"), "no value") - This function will see null value and return "no value".
I have an XPATH expression of the following sort that's expected to return a boolean value:
xs:boolean(expression1 or expression2 or expression3)
If expression1 returns true, would the other expressions be evaluated?
In any case could any one point me to examples of how complex logical expressions are written efficiently in XPATH?
BTW: I am running the XPATH on MarkLogic.
In XPath 1.0 it's defined that the expressions are evaluated in order, left to right, until one of them returns true.
But the presence of xs:boolean (which is redundant) in your expression suggests you are using XPath 2.0, and XPath 2.0 processors are allowed to evaluate the subexpressions in any order. This is to allow database-style optimization: one of the subexpressions might be much faster to execute (or more likely to return true) than the others, perhaps because of database indexes, so an optimizer will evaluate that one first. But any decent optimizer will stop evaluation after the first expression that evaluates to "true".
I can't tell you specifically what MarkLogic does.
For anyone else trying this, the "or" operator in XPath must be lower-case.
In light of Michael Kay's comments on optimization, I can't say for sure whether MarkLogic chooses expression to evaluate first or goes left to right, but you can see how a particular XPath is evaluated. In Query Console (usually localhost:8000/qconsole), type in an expression, click the Profile tab, and Run.
//foo[xs:boolean(1 = 1 or 2 = 3)]
The profile tab shows that "1 = 1" is evaluated and "2 = 3" is not.
With XPath, I know that you can use the union operator in the following way:
//*[#id="Catalog"]/thead | //*[#id="Catalog"]/tbody
This seems to be a little awkward to me though. Is there a way to do something similar to one of these instead?
//*[#id="Catalog"]/(thead|tbody)
//*[#id="Catalog"]/(thead or tbody)
//*[#id="Catalog"]/*[nodename="thead" or nodename="tbody"]
That seems a lot more readable and intuitive to me...
While the expression:
//*[#id="Catalog"]/*[name()="thead" or name()="tbody"]
is correct
This expression is more efficient:
//*[#id="Catalog"]/*[self::thead or self::tbody]
There is yet a third way to check if the name of an element is one of a specified sequence of strings:
//*[#id="Catalog"]/*[contains('|thead|tbody|',concat('|',name(),'|'))]
Using this last technique can be especially practical in case the number of possible names is very long (of unlimited and unknown length). The pipe-delimited string of possible names can even be passed as an external parameter to the transformation, which greatly increases its generality, re-usability and "DRY"-ness.
You are looking for the name() function:
//*[#id="Catalog"]/*[name()="thead" or name()="tbody"]
Note that with XPath 2.0 your attempt //*[#id="Catalog"]/(thead|tbody) is correct. That approach does not work however with XPath 1.0.
Yes you can use:
//*[#id="Catalog"]/[nodename='thead' or nodename='tbody']
EDIT:
Just re-read your original post and realised what you were asking. The above syntax wouldn't be correct for this situation. Not sure how to get the name of the node to use but nodename isn't right...