I try to use condition
<c:when test="${game.duration!='0:00'}">
...show rows
...
The duration here is String, and condition should be true when the String does not match 0:00. This isn't working however! When I put
<c:when test="${game.duration=='0:00'}">
... show rows
Rows are hidden, even if the duration value would be etc. 5:45. Is condition actually regular expression? How to fix this?
Related
I'm trying to compare two values
<#if user.cellPhone != changedUser.cellPhon>
<br><span class="changes">*${changedUser.cellPhone}</span></#if>
I'm getting an error
freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:==> changeUser
Tip:
If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
Add null check to condition changedUser??:
<#if changedUser?? && user.cellPhone != changedUser.cellPhon>
I am parsing string to number for comparison with zero(0). But getting weird result.
<fmt:parseNumber type ="number" var="parsedNumber" value="${noInStringFormate}"/>
<c:if test="${parsedNumber gt 0}">
Perform some action
</c:if>
Ex. for String "10.20" its parsed to Number 10.20.
But for String "0.23" its parsed to Number 0(zero) instead of 0.23
Even I tried by setting integerOnly="false" though its false by default. But its didn't work.
any idea on this?
Thanks for help.
I have the following XPATH that selects elements containing certain strings ("video" or "color" or "black and white"). The issue I am having is that one of the elements that is selected contains a string "video reprints" and although it's correct, I do not want this particular element selected. I thought I could specify NOT in the XPATH as in the following...
//div/A[contains(., 'video') or contains(., 'color') or contains(., 'black and white') and (not (contains(., 'reprint')))]
Any thoughts on how I can remove any selection that contains the string "reprints" from the selections above?
This is a precedence issue. Just wrap all the or-ed conditions into parentheses:
[( ... or ... or ...) and (not(...))]
Really it's just because of the way you have your parentheses, so this will work:
//div/A[(contains(., 'video') or contains(., 'color') or contains(., 'black and white')) and not(contains(., 'reprints'))]
How can I find elements that has at least one attribute?
Example:
<tr>...</tr>
<tr style="">...</tr>
<tr width="">...</tr>
I want all tr elements but ...
I tried following xpath but it doesn't work.
//table//tr[contains(attributes::*,'')]
Thanks
This should do it:
//table/tr[#*]
The reason why yours doesn't work is because contains() will always return true when the second parameter is ''. When an expression returns a node set within square brackets, it is considered true if it's non-empty, false if it's empty. So [#*] will return the set of all attributes and will be interpreted as true if there are any present.
I have the following Xml structure; Payment/Line which has amongst its element a IsFeePayment and a IsServiceProduct elements of type bool.
<Payment>
<Line>
<IsFeePayment>true</IsFeePayment>
<ISServiceProduct>true</IsServiceProduct>
</Line>
</Payment>
i want an xpath statement that returns 'true' when both of these are are they are, true.
if either one is false, i want the xpath statement to return 'false'
THe xpath below is almost there, it returns the line when both are true.
/[local-name()='Payment']/[local-name()='Line'][*[local-name()='IsFeePayment'][text()='true'] and *[local-name()='IsServiceProduct'][text()='true']]
how do i just get a simple bool out instead of the whole element?
You can simplify the xpath to
boolean(//Payment/Line[IsFeePayment='true' and IsServiceProduct='true'])
simply adding a boolean() around the xpath expression i already had fixes the problem blush
so ...
boolean(/[local-name()='Payment']/[local-name()='Line'][*[local-name()='IsFeePayment'][text()='true'] and *[local-name()='IsServiceProduct'][text()='true']])