Skip to main content
Solved

XmlTemplater using Sub Templates with Expressions ?

  • February 21, 2017
  • 7 replies
  • 80 views

lifalin2016
Contributor
Forum|alt.badge.img+29

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.

Best answer by jdh

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>
View original
Did this help you find an answer to your question?

7 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • Best Answer
  • February 21, 2017

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>

david_r
Evangelist
  • February 21, 2017

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.


patrick_koning
Contributor
Forum|alt.badge.img+1

test.fmw

 

Hi @lifalin2016,

I included a very small working sample.

I hope this wil help.

Created with FME 2016.1


takashi
Contributor
  • February 22, 2017

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


lifalin2016
Contributor
Forum|alt.badge.img+29
  • Author
  • Contributor
  • February 22, 2017
takashi wrote:

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

 


lifalin2016
Contributor
Forum|alt.badge.img+29
  • Author
  • Contributor
  • February 22, 2017
jdh wrote:

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

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • February 22, 2017
lifalin2016 wrote:
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.

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings