Skip to main content

Hi list.

When setting expressions in XMLTemplater for ROOT and various sub templates, one uses fme functions like "fme:has-attribute" and fme:get-attribute".

But is it possible to use string functions as well, e.g. to test the first character in a string retrieved by "fme:get-attribute" ? I can't seem to find any documentation about this with Safe.

I've found some string functions documented at Microsoft, e.g. https://docs.microsoft.com/en-us/sql/xquery/functions-on-string-values-substring?view=sql-server-ver15

Here a namespace of "fn" is used, but will that work in FME ?

And how do I wrap multiple function within each other ?

Is it { f1( f2() ) } or is it { f1( { f2() } ) } ?

Any insights will be appriciated.

Cheers.

You can test whether a retrieved value starts with a certain character/string and then return different outcomes dependent on whether this is true or false, e.g.

<data>
{
let $value :={
    fme:get-attribute("test")
    }
return if (fn:starts-with($value,"t"))
then $value
else "somethingelse"
</data>

 


Is it { f1( f2() ) } or is it { f1( { f2() } ) } ?

Both are possible. Curly brackets are required to distinguish XQuery expression from literal value, but can be omitted in other cases.

Additionally, "fn:" (the namespace prefix for XQuery built-in functions) can also be omitted.

Try these three expressions, for example.

<data>{ replace({ substring('query', 3) }, 'e', 't') }</data>
<data>{ replace(substring('query', 3), 'e', 't') }</data>
<data>replace(substring('query', 3), 'e', 't')</data>

Reply