Вопрос

In XPath 1.0, is there a way to test the existence of the evaluated expression and modify the result on its behalf?

I am trying to implement this pseudo-code:

if ID is empty
     then 0 + 1
     else ID + 1

Actual code, so far:

xdMath:Eval(xdMath:Max(
    xdXDocument:GetDOM("FetchID")/dfs:myFields/dfs:dataField‌​s/d:SharePointListItem_RW/d:ID),
    'concat("(ID = ", (d:ID or 0) + 1,")")'
)

This expression doesn't work when there is no item in the list, hence max(d:ID) is empty.

Это было полезно?

Решение

There's usually an ugly workaround, something like

concat("0", ID) + 1
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top