Template Engine

Seven Stars

Template Engine

Is there any support for a Template Engine to generate HTML documents/ tables from DB inputs? I saw there is a tmustache component but I have not been able to use it successfully.

 

What I want to do is read from DB and output as a HTML page... Any suggestions welcome. Thank you.


Accepted Solutions
Sixteen Stars

Re: Template Engine

You can make use of a bit of a hack, that I have used in the past. Create a webservice to return your data in XML. In the returned XML, ensure you have a stylesheet referenced. Create another service which will output an XSLT file (which is also standard XML). In your XML stylesheet, point it to your XSLT webservice URL. Maybe something like below...

<?xml-stylesheet type="text/xsl" href="http://my_esb_server:8040/services/myXSLT"?>

When the XML is loaded with your data it will try to use the XSLT stylesheet. When it follows the path it calls the webservice which returns the XSLT. This is then used to format your XML into HTML.

 

It sounds convoluted, but is a nice trick and not too hard to get right after a bit of playing around.


All Replies
Sixteen Stars

Re: Template Engine

You can make use of a bit of a hack, that I have used in the past. Create a webservice to return your data in XML. In the returned XML, ensure you have a stylesheet referenced. Create another service which will output an XSLT file (which is also standard XML). In your XML stylesheet, point it to your XSLT webservice URL. Maybe something like below...

<?xml-stylesheet type="text/xsl" href="http://my_esb_server:8040/services/myXSLT"?>

When the XML is loaded with your data it will try to use the XSLT stylesheet. When it follows the path it calls the webservice which returns the XSLT. This is then used to format your XML into HTML.

 

It sounds convoluted, but is a nice trick and not too hard to get right after a bit of playing around.

Seven Stars

Re: Template Engine

@rhall_2_0

This is interesting. I have never worked with XSLT to be honest. But, can XSLT provide ways to output a decent HTML page? Thanks.
Sixteen Stars

Re: Template Engine

Take a look online. I can't think of why XSLT wouldn't suit your needs of producing HTML tabulated data. You can make it as basic or complicated as you like. It does require a bit of learning, but it is quite logical. Take a look here for an example of XSLT converting to HTML in action....

https://www.w3schools.com/xml/xml_xslt.asp

Seven Stars

Re: Template Engine

Thank you. This looks promising.