Hello, world!

I start with "hello, world" sample to demonstrate ease of XsltDb. Steps to output Hello, world are:

1. Download arhcive from Releases
2. Install module via Host / Module Definitions / Install New Module
3. Create a new page and add XsltDb module on it
4. Click Edit XSLT
5. Input

<b>Hello</b>, world!
6. Click "Update & Publish"

If you see

Hello, world!

you have successfully created your first XsltDb module.

Here you ask "where is xslt???"

XsltDb analyses what you write into the "XSL transform" window and if it does not see standard root element it writes it automatically. So the real XSLT you have just executed is:

<xsl:stylesheet version="2.0"
   exclude-result-prefixes="msxsl mdo"
  <xsl:output method="html" indent="no" omit-xml-declaration="yes"/>

  <xsl:template match="/root">

     <b>Hello</b>, world!


If you want to manually control the xsl:stylesheet element - include it into your xsl and XsltDb won't add it.
If you want to control your templates manually you have to specify xsl:template element. You are still allowed to omit xsl:stylesheet element in this case. But you need to manually specify xsl:output element if you need overwrire default settings.

So if you need multiple templates you can do the following:

<!-- This is "entry point" template -->
<xsl:template match="/">
  <xsl:call-template name="some-template">
    <xsl:with-param name="pname" select="1" />

<!-- This is additional template that you call manually -->
<xsl:template name="some-template">
   <!-- template code goes here -->

Next: Database Access sample.

Last edited Aug 16, 2010 at 1:16 PM by findy, version 7


No comments yet.