I have a xml given below:
<root title="الصفحة الرئيسة">
<item title="الصفحة الرئيسة" itemuri="tcm:8-29-4" ShowInNav="True" type="sg" pageuri="tcm:8-10592-64" sLink="/ara/index.aspx">
<item title="من نحن" itemuri="tcm:8-779-4" ShowInNav="True" type="sg" pageuri="tcm:8-9934-64" navorder="00500" sLink="/ara/about/index.aspx">
</item>
<item title="برامجنا" itemuri="tcm:8-817-4" ShowInNav="True" type="sg" pageuri="tcm:8-10112-64" navorder="00100" sLink="/ara/courses/language-study-abroad.aspx">
</item>
<item title="مدارسنا" itemuri="tcm:8-824-4" ShowInNav="True" type="sg" pageuri="tcm:8-10162-64" navorder="00300" sLink="/ara/schools/english-language.aspx">
</item>
</item>
</root>
Now I want to the value of maximum navorder, so that I can use that value further in "if" condition.
Have a look at this. Then use it in your xpath
Or something similar :)
NOTE This requires the use of EXSLT.
NOTE 2: No it doesn't. Just copy and paste the code.
the following is a solution using XPath 1.0:
The expression
filters all item nodes so that there is no preceding or following node that has a higher navorder value on the same level.
I found this forum post as one potential solution.
Of course, if you have access to XPath 2.0, there's a more direct solution:
fn:max(arg, arg, …)
Couple of ways: with xpath 2 you can use the max() function, but if you're in xslt 1 you'll have to use sort in a for-each and then put the item at position 1 in your variable.
Below is the XSLT 1.0 code of two possible solutions.
A third solution is to use EXSLT.
A fourth solution is to use the
maximum
template of FXSL.When the above transformatio is applied on the original XML document:
the wanted result is produced: