Opinion Needed:  Templating Engines vs XML / XSL Output

Posted on 2007-07-26
Last Modified: 2008-02-01

     I'm interested in getting some suggestions.  Right now I'm developing an architecture which does the presentation layer using templeting.  Now, my question / advice needed:  Right now I'm doing XML / XSL translation.  Part of the reason is I like the speed of using PHP's built in DOM framework, plus the output doesn't have to be HTML, I can output to whatever format I want.   However, I'm thinking of using Smarty due to its ease of use and mostly because my architecture is for the Web.  The only thing stopping me is I've heard (never fully investigated) Smarty is slow.

     My questions:  Do I stay w/ XML / XSL, move onto Smarty, or try another templeting engine.  Please give some opinons, I would really appreciate.
Question by:paulj1999
    LVL 7

    Expert Comment



    If you ask me: things that make page slow are frames and too many (and) big pictures...

    So if you use a CSS powered template wisely it should be pretty fast.

    But as always - you will need to try it and see it for yourself.

    LVL 9

    Accepted Solution

    Stay with XSL/XML+CSS.  Smarty has similar-ish syntax to PHP, so there's no need to introduce the Smarty interpreter when you can do the same thing with proper design and native PHP.  Really, the same argument can be made for most, if not all, Web-based templating engines.

    I say XSL because you can use different transforms for different media; you don't have that flexibility with the others.  While basic Web surfing might be the bulk of your userbase, you might find yourself needing to implement for the mobile-browser market, or implementing RSS/Atom newsfeeds, or providing lightweight or alternate formats for accessibility utilities like screen readers.

    Really, if you don't need that degree of flexibility, then use good design principles and native PHP.  You gain nothing from a dumbed-down syntax that requires an interpreter to be compiled at run-time per page rendering.
    LVL 2

    Expert Comment

    XML+XSL will run only on browsers that support them. Nowadays browsers support them but if you plan to output for palmtops, mobiles etc my vote is towards templates.

    Another advantage of templates is that they give you the freedom to create code for forming the layout. Plain XML only outputs information and sometimes this is not enough.
    LVL 4

    Expert Comment

    I would implement a solution like this article talks about.  Most template engines add a lot of overhead for little benefit.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now