Solved

XmlTemplater using Sub Templates with Expressions ?

  • 21 February 2017
  • 7 replies
  • 19 views

Userlevel 1
Badge +22

Hi,

I'm having my first go with the XmlTemplater, and of course it's given me problems :-)

I want to add three tags conditionally in a SubTemplate, but it errs with this message:

XMLTemplater(XMLTemplaterFactory): The following error occurred near line 2, column 8 of the query: XMLTemplater(XMLTemplaterFactory): invalid expression: syntax error, unexpected ExprSingle (missing comma "," between expressions?) XMLTemplater(XMLTemplaterFactory): An error occurred while parsing the 'SYMBOL' sub-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

The unconditionally expression "<!-- not implemented yet -->" works fine, but three tags fails on (apparently) the second opening tag.

And what's with the "missing comma" ??

Can anyone point me in the direction of a not-simple example of how to use the Sub Template expression in XmlTemplater ?

Cheers.

icon

Best answer by jdh 21 February 2017, 17:34

View original

7 replies

Badge +22

If you have two unrelated xml fragments you need to separate them with a comma.

 

 

For example a subtemplate of

 

<a>

<b></b>

<b></b>

 

</a>

 

 

will have no issue, but

 

<a></a>

 

<b></b>

 

will fail.

 

 

it needs to be

 

<a></a>,

 

<b></b>
Userlevel 4

I seem to remember that the XMLTemplater didn't like XML-style comments, so you might want to try without them to see if that helps.

test.fmw

 

Hi @lifalin2016,

I included a very small working sample.

I hope this wil help.

Created with FME 2016.1

Userlevel 2
Badge +17

I think this article in Knowledge Base would be a good starting point.

XML Writing with XMLTemplater, esp. Exercise 1.b Basic XML Writing - multi-record

Userlevel 1
Badge +22

I think this article in Knowledge Base would be a good starting point.

XML Writing with XMLTemplater, esp. Exercise 1.b Basic XML Writing - multi-record

Hi Takashi,

 

 

I did read that, but it unfortunately doesn't address my problem.

 

 

Cheers

 

Userlevel 1
Badge +22

If you have two unrelated xml fragments you need to separate them with a comma.

 

 

For example a subtemplate of

 

<a>

<b></b>

<b></b>

 

</a>

 

 

will have no issue, but

 

<a></a>

 

<b></b>

 

will fail.

 

 

it needs to be

 

<a></a>,

 

<b></b>
Hi jdh,

 

 

You're correct, although it makes no sense to me to add commas. Yesterday I tried to add commas out of sheer desparation, and much to my surprise, it worked.

 

 

I would have assumed, that an XML "expression" would be some valid XML snippet (with embedded commands). Commas between tags are not valid XML, so it baffles me why it's implemented as such.

 

 

Thanks again.

 

 

Cheers

 

Badge +22
Hi jdh,

 

 

You're correct, although it makes no sense to me to add commas. Yesterday I tried to add commas out of sheer desparation, and much to my surprise, it worked.

 

 

I would have assumed, that an XML "expression" would be some valid XML snippet (with embedded commands). Commas between tags are not valid XML, so it baffles me why it's implemented as such.

 

 

Thanks again.

 

 

Cheers

 

I went through that aggravation back in 2012. Once I figured out what did and did not need commas, it was fairly straightforward. I don't even really notice it these days.

 

 

Reply