And I would like the "note" to show up in the XML only when there are some values in OpeningTime
I know I should follow if then else logic, but so far I'm only getting XMLTemplater errors.
(FME Desktop 2018)
Thanks,
Linda
Best answer by takashi
Hi @llindish, the syntax error seems to be caused by wrong usage of "fme:has-attribute" and "fme-get-attribute" functions.
If you want to create the "OperatingTime" element only if the "opening_time" attribute exists and the "closing_time" is not empty, this expression could work for you.
<OperatingTimeList> <OpeningTime>{fme:get-attribute("opening_time")}</OpeningTime> <ClosingTime>{fme:get-attribute("closing_time")}</ClosingTime> { if (fme:has-attribute("opening_time") and not(fme:get-attribute("closing_time") eq "")) then <OperatingTime dayOfweek="" note="we are open" /> else () } </OperatingTimeList>
not(fme:get-attribute("closing_time") eq "")
is equivalent to
fme:get-attribute("closing_time") ne ""
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.
Hi @llindish, the syntax error seems to be caused by wrong usage of "fme:has-attribute" and "fme-get-attribute" functions.
If you want to create the "OperatingTime" element only if the "opening_time" attribute exists and the "closing_time" is not empty, this expression could work for you.
<OperatingTimeList> <OpeningTime>{fme:get-attribute("opening_time")}</OpeningTime> <ClosingTime>{fme:get-attribute("closing_time")}</ClosingTime> { if (fme:has-attribute("opening_time") and not(fme:get-attribute("closing_time") eq "")) then <OperatingTime dayOfweek="" note="we are open" /> else () } </OperatingTimeList>
Hi @llindish, the syntax error seems to be caused by wrong usage of "fme:has-attribute" and "fme-get-attribute" functions.
If you want to create the "OperatingTime" element only if the "opening_time" attribute exists and the "closing_time" is not empty, this expression could work for you.
<OperatingTimeList> <OpeningTime>{fme:get-attribute("opening_time")}</OpeningTime> <ClosingTime>{fme:get-attribute("closing_time")}</ClosingTime> { if (fme:has-attribute("opening_time") and not(fme:get-attribute("closing_time") eq "")) then <OperatingTime dayOfweek="" note="we are open" /> else () } </OperatingTimeList>