Search

To further prove that XSLT is capable of being easier to learn, XSLT has a feature that allows what the spec calls, Literal Result Element as Stylesheet. What does this mean? Instead of writing the common XSLT structure we all know and come to eventually love, you can instead write inline XSLT within your HTML. This method is more akin to how other template systems work.

Check it out:

<html xsl:version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/TR/xhtml1/strict">

    <head>
        <title><xsl:value-of select="$page-title"/></title>
    </head>

    <body>
        <h1><xsl:value-of select="concat('Welcome to ', $website-name)"/></h1>
        <ul>
            <xsl:for-each select="data/articles/entry">
                <div class="entry">
                    <h2><xsl:value-of select="title"/></h2>
                    <xsl:copy-of select="body/*"/>
                </div>
            </xsl:for-each>
        </ul>
    </body>
</html>

The simplified stylesheet format does have its shortcomings and for regular users, it can be quite limiting. It does not allow:

  1. stylesheet imports
  2. the use of apply-templates
  3. control over the output format – it’s strictly (X)HTML (i.e. no indentation)

However, this method is a wonderful launch pad for XSLT newbies as they can concentrate their efforts in learning XPath (the interaction between XML and a template) and get their hands dirty with the basic set of XSLT instructions

Allen, the symphony HQ marketing chief should give you a bonus (aka treat yourself ;-)

This format also does not allow for the usage of parameters.

Although this format is extremely easy to learn, I would strongly recommend XSLT newbies to use the common XSLT structure. You will need the extra flexibility when building a more complex website. Also, it will possibly take extra time to switch from the simple format to the common XSLT structure, which is easy to learn. And much more lovable (order your t-shirt here).

Well maybe we should make 2 forums one for newbies with general use questions; users.
And one for developers? Most opensource project make this distinction.

That is awesome! I wish I knew that before. It would have made learning a lot easier.

Nice tip.

But you don’t need to prove to me how easy is to learn. I think its learning curve is excellent, and I pick up new stuff each day.

Beginning XSLT by Tennison is also a great kick off for beginners.

Wow, I didn’t know this could be done. It’s a lot less scary for newcomers, since the focus is on keeping the HTML as the root elements, rather than chopping the HTML up into various XSLT templates.

But I agree with Carsten and Nick above that although it’s easy on the eye, it’s limitations are dangerous — a newcomer my think this is all XSLT can do, and write Symphony off on the grounds of a poor templating system. We should be advocating best practice from the off.

We’ve known about this for a long time and the reason why we didn’t use this method in the default theme is precisely the issues/limitations mentioned.

What I really want to highlight is that the simplified method still stands well against other templating systems. Now, add the option to go full-blown XSLT and you realise how powerful the language really is.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details