I have a XML that contains img tag
<xml>
<img src="/path/to/file.jpg" orginalwidth="150" />
</xml>
I want to have:
<img src="/paht/to/file.jpg" size=SIZE />
Where SIZE is minimum of orginalsize and 100px
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
This transformation:
when performed on the provided XML document:
produces the wanted result:
when applied on the following XML document:
the result is again the wanted and correct one:
Explanation:
In XPath 1.0 any boolean value, when used as a number is converted from
true()to1and fromfalse()to0.Therefore, the expression:
evaluates to
.if.is less or equal$pmaxSizeand to$pmaxSizeotherwize..is the value of the current node interpreted as number.