Question

XQuery in XMLTemplater throwing error

  • 21 March 2018
  • 1 reply
  • 5 views

Badge +10

This is the template expression I'm using in XMLTemplater based on what I've learned from other questions/answers on this forum (like this one):

The problem is that it throws error 'invalid expression: syntax error, unexpected ExprSingle (missing comma "," between expressions?) near line 14, column 18 of the query' and I don't know why.

It works if I omit the <gmd:desc> block though.

What am I doing wrong?


1 reply

Userlevel 2
Badge +17

Hi @dms2, a return statement only can return a single XML element, a single value, or a single sequence. It seems that you need to return two XML elements (gmd:name and gnd:desc) with the return statement at the 10th line, but it isn't correct syntax so causes the error.

A workaround is to return the gmd:item element that contains the two elements, like this.

# Hope this won't contain any typo ;-)

</gmd:lang>
{
    let $obj := fn:tokenize(fme:get-attribute('objectInfo'), ',')
    return
    <gmd:item>
      <gmd:name>
        <gco:CharacterString>{$obj[1]}</gco:CharacterString>
      </gmd:name>
      <gmd:desc>
        <gco:CharacterString>{$obj[2]}</gco:CharacterString>
      </gmd:desc>
    </gmd:item>
}
</gmd:MD_Metadata>

Reply