XSL Templates
stub:document
The stub:document marks the HTML document to be created.
Example
<stub:document xmlns:stub="http://stubbles.org/stub">
<html>
<body>
<stub:maincontent part="content" path=""/>
</body>
</html>
</stub:document>
This template is only required in skin stylesheets.
stub:maincontent
The stub:maincontent template is used to include a specific part of the current document.
| Attribute | Usage |
| path | Path to the maincontent documents starting from project root. |
| prefix | Prefix of the maincontent documents. Default is main_ . |
| suffix | Suffix of the maincontent documents. Default is .xml . |
| part | Part of the maincontent document to include. Default is content. |
Example
<stub:document xmlns:stub="http://stubbles.org/stub">
<html>
<body>
<stub:maincontent part="content" path=""/>
</body>
</html>
</stub:document>
If main_home.xml is the current document its part content is included. This template is only required in skin stylesheets.
stub:comment
This creates a typical HTML comment. By default all comments in templates are thrown away during transformation - so this is a possibility to get comments through transformation.
Example
<stub:comment> This is a comment </stub:comment>
stub:script
As mentioned at stub:comment, all comments are thrown away during transformation. To get a typically inline Javascript through the transformation process you have to use stub:script. This creates a comment around the Javascript code.
Example
<stub:script>
function helloWorld() {
alert("Hello world!");
}
</stub:script>
stub:error
stub:link
Use stub:link for creating links to other pages of the project. The only required attribute is the page attribute. You don't have to give a path or session ID, this things are added automatically. Next to this, all known attributes beside href can be used.
<stub:link page="DslHome" target="_blank" onclick="openPopup(this.href); return false;">Go to Homepage</stub:link>
Parameters
In order to have additional parameters on the link use the stub:argument template:
<stub:link page="DslHome"> <stub:argument name="id">303</stub:argument> Go to DSL home page </stub:link>
Bot link cloaking
Sometimes it is necessary to have another URL for bots which visit the site in order to spider it for seach engines. To use another URL then the given one, you can use the bot attribute:
<stub:link page="download" bot="http://downloads.example.net/important.pdf"> <stub:argument name="id">303</stub:argument> Important PDF file </stub:link>
This will force the usage of the bot URL in case the visiting user agent is recognized as a search bot. Currently this recognition includes the Googlebot, Msnbot and Slurp (Yahoo!).
stub:include
The stub:include template is used to include a specific part of a document. You have to specify the part which has to be included. Optionally you can specify a href attribute. If you do so, part is included from the document found by href, if you don't, part is included from the current document.
| Attribute | Usage |
| part | Part which have to be included. |
| href | Path to the document which contains the specified part. This is optional. If you don't specify href, the current document is referenced. |
Example
<!-- the part 'hint' of the current document is included: --> <stub:include part="hint"/> <!-- the part 'hint' of the document 'general_hints.xml' is included: --> <stub:include href="general_hints.xml" part="hint"/>
stub:image
Use stub:image to include an image. You can specify all attributes known by the (X)HTML standard. The attributes width and height must not ne set, they are added automatically by the template.
Example
<stub:image src="images/stubbles.gif" alt="Stubbles Logo"/>
stub:langselect
With the stub:langselect template you can output text in different languages depending on which language is currently selected. To specify a language depended text, you can use the stub:lang tag within stub:langselect. stub:lang requires a name attribute. Next to a specific language there should always be a name="default" as a fallback for an language not included by stub:lang.
Example
<stub:langselect> <stub:lang name="default">This is a default text.</stub:lang> <stub:lang name="en_US">This is a "american english" text.</stub:lang> <stub:lang name="en_UK">This is a "british english" text.</stub:lang> <stub:lang name="de_DE">Das ist ein deutscher Text.</stub:lang> </stub:langselect>
stub:date
The stub:date template helps displaying dates. With a given timestamp you can do the following: <stub:date format="Y-m-d" timestamp="1216222717"/> will result in 2008-07-16. The timestamp attribute is optional, if omitted the current time will be used. The allowed formats are the format options for the PHP method date().
stub:localeDate
The stub:localeDate template helps displaying dates. With a given timestamp you can do the following: <stub:localeDate format="%d %b %Y" timestamp="1216222717"/> will result in 16 Jul 2008. The timestamp attribute is optional, if omitted the current time will be used. The allowed formats are the format options for the PHP method strftime().
Closing Example of how this all works together
skin.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<stub:document xmlns:stub="http://stubbles.net/stub">
<html>
<body>
<stub:maincontent part="content" path=""/>
</body>
</html>
</stub:document>
main_example.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<parts
xmlns:stub="http://stubbles.net/stub"
exclude-result-prefixes="stub">
<part name="content">
<stub:link page="testlinkPage">This is a stubbles link</stub:link>
<stub:include part="frank"/>
<stub:include href="parts.xml" part="schst"/>
<!-- This comment is thrown away during transformation process -->
<stub:comment>This is a comment</stub:comment>
<stub:script>
<![CDATA[
function helloWorld() {
alert("Hello world!");
}
]]>
</stub:script>
<stub:image src="stubbles.png" alt="Stubbles Logo" height="1000" width="1000"/> <!-- width and height will be replaced -->
<stub:langselect>
<stub:lang name="default">This is a default text.</stub:lang>
<stub:lang name="en_US">This is a "american english" text.</stub:lang>
<stub:lang name="en_UK">This is a "british english" text.</stub:lang>
<stub:lang name="de_DE">Das ist ein deutscher Text.</stub:lang>
</stub:langselect>
</part>
<part name="frank">
Frank Kleine
</part>
</parts>
HTML Output
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<html>
<body>
<a href="txt/pages/testlinkPage">This is a stubbles link</a>
Frank Kleine
Stephan Schmidt
<!--This is a comment-->
<script type="text/javascript">
<!--
function helloWorld() {
alert("Hello world!");
}
//-->
</script>
<img src="stubbles.png" alt="Stubbles Logo" height="113" width="132"/>
This is a default text.
</body>
</html>
