Answers for "Dashboarding: Creating HTML tables and formatting it with XMLTemplater and XQuery" https://knowledge.safe.com/questions/63652/dashboarding-creating-html-tables-and-formatting-i.html The latest answers for the question "Dashboarding: Creating HTML tables and formatting it with XMLTemplater and XQuery" Answer by mattfossey https://knowledge.safe.com/answers/104771/view.html

i have an issue that seems really similar to the above, but I just can't get it to work and was hoping someone may be able to help? My goal is to populate a HTML table with the values, but colour the background colour depending on the value of PRIORITY_CODE (ie A1-A5).

I've used the XML Templater, the ROOT template looking like...

and the SUB looks like this...

Now the ROOT seems to go through but it gets caught up on the SUB first curly bracket, which is trying to provide the PRIORITY_CODE by which to set the class colour.

Would anyone by kind enough to offer some suggestions, as I am stuck?

Thanks heaps

Matt

Thu, 19 Dec 2019 05:08:53 GMT mattfossey
Answer by takashi https://knowledge.亚搏在线safe.com/answers/63658/view.html

Hi @francois_binnem, it's true that there are many cases where an HTML document cannot be parsed with XML tools since the HTML specifications are lenient than pure XML, but in my understanding, most HTML elements can also be written with syntax strictly conformed to XML specifications. In this case, for example, you can create an HTML <table> element from the list attribute (_list{}.Name, _list{}.Value) using an XMLTemplater with this expression.

<table> <thead> <th>Name</th> <th>Value</th> </thead> <tbody>{ let $values := fme:get-list-attribute("_list{}.Value") for $name at $i in fme:get-list-attribute("_list{}.Name") return <tr> <td>{$name}</td> <td>{fn:format-number(xs:double($values[$i]), "0.00")}</td> </tr> }</tbody> </table> 

In addition, if you use a sub expression in the XMLTemplater, it would not be essential to create the list attribute

ROOT Expression:

<table> <thead> <th>Name</th> <th>Value</th> </thead> <tbody>{fme:process-features("SUB")}</tbody> </table> 

SUB Expression:

<tr> <td>{fme:get-attribute("Name")}</td> <td>{fn:format-number(xs:double(fme:get-attribute("Value")), "0.00")}</td> </tr> 

In both cases, you can add other HTML element before and after the table element, in the template expression or a subsequent transformer such as StringConcatenator.

Honestly I'm unclear what issues are there. Am I missing something?

Thu, 08 Feb 2018 14:32:58 GMT takashi
Answer by redgeographics https://knowledge.safe.com/answers/63655/view.html

Thanks for sharing! I've ran into some of the same issues with the XMLTemplater not handling HTML nicely.

Thu, 08 Feb 2018 13:41:56 GMT redgeographics