In order to clarify where the issue is, could you please post the template expression you defined and the error messages you got?
In order to clarify where the issue is, could you please post the template expression you defined and the error messages you got?
Hi @takashi, thanks for the quick response.
This is the expression:
<OperatingTimeList>
<OpeningTime>{fme:get-attribute("opening_time")}</OpeningTime>
<ClosingTime>{fme:get-attribute("closing_time")}</ClosingTime>
<OperatingTime dayOfweek="" note="">
{ if( fme:has-attribute{fme:get-attribute("opening_time")} and
not(fme:get-attribute{fme:get-attribute("closing_time")} eq "") )
then <OperatingTime dayOfweek="" note="we are open">
else ()
}
</OperatingTime>
</OperatingTimeList>
And the error messages:
XMLTemplater(XMLTemplaterFactory): The following error occurred near line 403, column 43 of the query:
XMLTemplater(XMLTemplaterFactory): invalid expression: syntax error, unexpected ExprSingle (missing comma "," between expressions?)
XMLTemplater(XMLTemplaterFactory): An error occurred while parsing the ROOT template
XMLTemplater(XMLTemplaterFactory): A fatal error has occurred. Check the logfile above for details
A fatal error has occurred. Check the logfile above for details,
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 ""
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 ""
Thank you, works perfectly now!