Release 1.0 - ...
Smartsite eXtensible Markup Language (SXML) consists of Macro and Viper syntax, normally mixed with elements in other XML namespaces.
Macros are handled by an XML parser. Therefore, macros should be wellformed XML nodes and the complete document for rendering information should be a well-formed XML document.
Vipers can be seen as so-called content-neutral functions that can be called within macro and XHTML syntax. They can be mixed with macro syntax and can even be used within SXML and HTML attributes.
To avoid collisions between the tags of the mark-up languages, SXML is declared within its own namespace, http://smartsite.nl/namespaces/sxml/1.0, normally prefixed with 'se'.
Smartsite SXML |
Copy Code
|
<se:type [arg1="..."] />
|
Every macro can have
parameters, which can be noted as attributes of the macro-tag or as a child XML block:
Smartsite SXML |
Copy Code
|
<se:type>
<se:parameters>
<se:parameter name="paramname1">
...
</se:parameter>
<se:parameter name="paramname2">
...
</se:parameter>
</se:parameters>
</se:type>
|
Macros can be nested within other macros. In fact, the whole
rendertemplate is an Xml document with nested macros. Because this whole document should be valid Xml document, which can be evaluated by the Xml parser, a root-element must exist. This root-element:
- has to be an SXML Macro element
- has to declare the se namespace with a reference to http://smartsite.nl/namespaces/sxml/1.0
A commonly used root-element is the XHtmlpage macro:
Smartsite SXML |
Copy Code
|
<se:htmlpage doctype="XHTML10TRANSITIONAL"
xmlns:se="http://smartsite.nl/namespaces/sxml/1.0">
<html>
<head>
<title><se:itemdata field="title"></title>
</head>
<body>
<h1><se:itemdata /></h1>
</body>
</html>
</se:htmlpage>
|
As stated, the full document parsed should be well-formed Xml. Therefore, for example, the angle bracket symbol (<) cannot be used everywhere.
Smartsite SXML |
Copy Code
|
<se:text condition="2 > 1">aha, 2 is greater then 1!</se:text>
|
Smartsite provides operator aliases for cases where the expression evaluator is handling the incoming string.
Smartsite SXML |
Copy Code
|
<se:text condition="2 GT 1">aha, 2 is greater then 1!</se:text>
|
If the expression evaluator is not involved in handling the value, for example, in individual parameters of a macro, the developer should be aware to use the proper handling of these characters. Some alternatives are
- Using the proper encoding
- Using SXML Viper syntax to display the character
- Using CDATA blocks
Smartsite SXML |
Copy Code
|
<se:sqlquery>
<se:parameters>
<se:parameter name="sql">
select * from vwusers where nr < 1000000
</se:parameter>
</se:parameters>
</se:sqlquery>
<se:sqlquery>
<se:parameters>
<se:parameter name="sql">
select * from users where length {char.lt()} 0
</se:parameter>
</se:parameters>
</se:sqlquery>
<se:sqlquery>
<se:parameters>
<se:parameter name="sql"><![CDATA[
select * from servercache where length < 3600
]]></se:parameter>
</se:parameters>
</se:sqlquery>
|
Getting itemdata
The Itemdata macro is used to get itemdata. The field parameter refers to the contenttypes logical field name
Smartsite SXML |
Copy Code
|
<se:itemdata field="title" />
<se:itemdata field="keywords" />
|
If the data of another item is preferred, the item parameter can be involved:
Smartsite SXML |
Copy Code
|
<se:itemdata field="title" item="2" />
|
The result of the macro an be formatted using the resultformat parameter:
Smartsite SXML |
Copy Code
|
<se:itemdata field="title" item="2">
<se:parameters>
<se:parameter name="resultformat">
<h1>{this.result()}</h1>
</se:parameter>
</se:parameters>
</se:itemdata>
|
Creating Lists:
When you like to create a list of data, several macros can be used. The simplest macro for creating lists is the XLinks macro. This macro uses the hierarchy of the stored information within the CMS. Without any parameters it generates a list of all children of a folder, as long the folder is not empty. Otherwise, nothing is returned:
Smartsite SXML |
Copy Code
|
<se:xlinks />
|
If the children of a specific folder should be displayed, the
Parent parameter can be used.
Smartsite SXML |
Copy Code
|
<se:xlinks parent="2" />
|
By default, the list is displayed as an unordered list. Using the rich formatting layer of Smartsite iXperion, you can modify the mark-up used for the list completely More complex lists can be created with the
SQLQuery macro. This macro results list based on a query. By default the query is performed on the Smartsite iXPerion database, but when alternative connections to external databases are defined in the
Smartsite.Data.config, content from external databases can be displayed as well. Note: To avoid sql injection attacks and ensure optimal performance, queries should
parametrized:
Smartsite SXML |
Copy Code
|
<se:sqlquery>
<se:parameters>
<se:parameter name="sql">
SELECT c.Nr, c.Title
FROM vwContent c
JOIN Contenttypes ct
ON c.Contenttype=ct.Nr
WHERE ct.Code=?:ctname
</se:parameter>
<se:parameter name="params">
<se:collection>
<se:member name="ctname">WP</se:member>
</se:collection>
</se:parameter>
<se:parameter name="rowformat">
<li>{this.field(nr)} - {this.field(title)}</li>
</se:parameter>
<se:parameter name="resultformat">
<ul>
{this.result()}
</ul>
</se:parameter>
</se:parameters>
</se:sqlquery>
|
Navigation
Macros like Parents, Siblings and Sitemap are macros which can be used for navigation purposes. These macros use the hierarchy of the information stored in the CMS. The Parents macro, for example, displays an hierarchic path to the root of the site.
Smartsite SXML |
Copy Code
|
<se:parents />
|
Branching and Flow
To create logic in your SXML Document, branching and flow macros like If, Switch, For, While and DoWhile can be used.
Smartsite SXML |
Copy Code
|
<se:if expression="request.query(x)=='1'">
<se:then>
Querystring parameter 'x' is '1'
</se:then>
<se:else>
Querystring parameter 'x' is not '1'
</se:else>
</se:if>
|