The RSTL is a library of REL tags providing standard functionality such as iterating collections, conditionals, imports, assignments, XML XSLT transformations, formatting dates, etc.
RSTL distributable is available on my Google Code page under REL Standard Tag Library. Always use the latest JAR.
This post describes each RSTL tag in the library explaining its functionality, attributes and providing examples. For understanding the way expressions are evaluated, please read my post about the Expression Language used by REL Standard Tag Library.
Example:
<c:out value="cp.componentId"/>
Example:
<c:remove var="cpList"/>
Attributes:
Example:
<c:set var="user-name" value="${user + 'Account'}"/>
Attributes:
Example:
<fmt:formatDate value="myDate" pattern="dd.MM.yyyy HH:mm"/>
Attributes:
Example:
Attributes:
Example:
RSTL distributable is available on my Google Code page under REL Standard Tag Library. Always use the latest JAR.
This post describes each RSTL tag in the library explaining its functionality, attributes and providing examples. For understanding the way expressions are evaluated, please read my post about the Expression Language used by REL Standard Tag Library.
<c:choose> / <c:when> / <c:otherwise>
Syntax:
<c:choose>
<c:when test="expr1">
Do something
</c:when>
<c:when test="expr2">
Do something else
</c:when>
<c:otherwise>
Do something otherwise
</c:otherwise>
</c:choose>
Attributes:
- test : conditional expression;
Description:
This is the classic switch (if/else) conditional tag construct. A <c:choose> tag contains some <c:when> tags and at most one <c:otherwise> tag.
This is the classic switch (if/else) conditional tag construct. A <c:choose> tag contains some <c:when> tags and at most one <c:otherwise> tag.
The test attribute expression is evaluated for each when tag, and for the first one that evaluates to true, its body is evaluated and included in the output. If none of the when tags evaluate to true, the otherwise tag body is evaluated and included in the output.
Example (simple if/else):
<c:choose>
<c:when test="userName == 'Mihai'">
Hello, Mihai!
</c:when>
<c:otherwise>
Hello, guest!
</c:otherwise>
</c:choose>
<c:forEach>
Syntax:
<c:forEach var="expr" items="expr">
Do something
</c:forEach>
Attributes:
- var : variable name or ${expression};
- items : variable or expression evaluating to array of Object or java.util.List;
Description:
The tag executes the tag body for each item in the collection referenced by the items attribute. The current item in the iteration is stored temporarily (only for the duration of the loop) in the TransformContext under the name given by attribute var.
The tag executes the tag body for each item in the collection referenced by the items attribute. The current item in the iteration is stored temporarily (only for the duration of the loop) in the TransformContext under the name given by attribute var.
Example:
Example:
Description:
The tag outputs the evaluated value of the attribute var.
<c:forEach var="cpMeta" items="pageMeta.componentPresentationMetas">
<c:out value="cpMeta.componentId"/>
</c:forEach>
</c:forEach>
<c:if>
Syntax:
<c:if test="expr">
Do something
</c:if>
Attributes:
- test : conditional expression;
Description:
The tag executes the tag body, if the attribute test evaluates to true.
The tag executes the tag body, if the attribute test evaluates to true.
Example:
<c:if test="userName == 'Mihai'">
Hello, Mihai!
</c:if>
</c:if>
<c:import>
Syntax:
<c:import var="expr" url="expr" componentTemplate="expr">
<c:param name="expr" value="expr"/>
</c:import>
</c:import>
Attributes:
- var : variable name or ${expression};
- url : tcmuri or string or ${expression};
- componentTemplate : tcmuri or integer or ${expression};
- name : string or ${expression};
- value : string or ${expression};
Description:
The tag accesses the resource identified by attribute url and retrieves a its content. If a var is specified, it stores this content in the TransformContext under that name. The url can be either a string identifying a relative or fully qualified URL, a tcmuri of a Page, or a tcmuri of a Component. If url identifies a Component, then the attribute componentTemplate is used to read the Component Presentation on that Component. If componentTemplate is not specified in this case, the Component Presentation with highest priority is retrieved.
If any c:param tags are specified, their name and value attributes are used in the invocation of the url as query string or rendering parameters.
The tag accesses the resource identified by attribute url and retrieves a its content. If a var is specified, it stores this content in the TransformContext under that name. The url can be either a string identifying a relative or fully qualified URL, a tcmuri of a Page, or a tcmuri of a Component. If url identifies a Component, then the attribute componentTemplate is used to read the Component Presentation on that Component. If componentTemplate is not specified in this case, the Component Presentation with highest priority is retrieved.
If any c:param tags are specified, their name and value attributes are used in the invocation of the url as query string or rendering parameters.
Example:
<c:import var="xml" url="tcm:1-23-64">
<c:param name="color" value="${myColor}"/>
</c:import>
<c:param name="color" value="${myColor}"/>
</c:import>
<c:out>
Syntax:
<c:out value="expr"/>
Attributes:
- value : variable or expression;
The tag outputs the evaluated value of the attribute var.
Example:
<c:out value="cp.componentId"/>
<c:remove>
Syntax:
<c:remove var="expr"/>
Attributes:
- var : variable name or ${expression};
Description:
The tag removes the variable named by attribute var from the TransformContext.
The tag removes the variable named by attribute var from the TransformContext.
Example:
<c:remove var="cpList"/>
<c:set>
Syntax:
<c:set var="expr" value="expr"/>
or
<c:set var="expr">
Do something
</c:set>
or
<c:set var="expr">
Do something
</c:set>
Attributes:
- var : variable name or ${expression};
- value : value to set or ${expression};
Description:
The tag sets a variable named by attribute var in the TransformContext. The stored value is the result of evaluating attribute value, if specified; otherwise, it is the value of the tag body.
The tag sets a variable named by attribute var in the TransformContext. The stored value is the result of evaluating attribute value, if specified; otherwise, it is the value of the tag body.
Example:
<c:set var="user-name" value="${user + 'Account'}"/>
<fmt:formatDate>
Syntax:
<fmt:formatDate var="expr" value="expr" pattern="expr"/>
Attributes:
- var : variable name or ${expression};
- value : expression evaluating to java.util.Date object;
- pattern : format pattern or ${expression};
Description:
The tag formats a java.util.Date specified by attribute value according to the pattern specified by attribute pattern. If an attribute var is specified, then the formatted date is stored as string entry in the TransformContext; otherwise, the formatted string is output.
The tag formats a java.util.Date specified by attribute value according to the pattern specified by attribute pattern. If an attribute var is specified, then the formatted date is stored as string entry in the TransformContext; otherwise, the formatted string is output.
Example:
<fmt:formatDate value="myDate" pattern="dd.MM.yyyy HH:mm"/>
<fmt:parseDate>
Syntax:
<fmt:parseDate var="expr" value="expr" pattern="expr"/>
Attributes:
- var : variable name or ${expression};
- value : String representing a date or ${expression};
- pattern : format pattern or ${expression};
Description:
The tag parses a String represetation of a date specified in attribute value, in the format described by attribute pattern, and stores a java.util.Date in TransformContext under variable name specified in attribute var.
The tag parses a String represetation of a date specified in attribute value, in the format described by attribute pattern, and stores a java.util.Date in TransformContext under variable name specified in attribute var.
Example:
<fmt:parseDate var="myDate" value="2013-07-23" pattern="yyyy-MM-dd"/>
Syntax:<x:transform>
<x:transform var="expr" doc="expr" xslt="expr">
<x:param var="expr" select="expr" />
</x:transform>
<x:param var="expr" select="expr" />
</x:transform>
Attributes:
- var : variable name or ${expression};
- doc : expression evaluating to either string representing XML, org.w3c.dom.Document object or javax.xml.transform.dom.DOMSource object;
- xslt : expression evaluating to either string representing XSLT or javax.xml.transform.Templates object;
- select : string or ${expression} evaluating to Object;
Description:
The tag transforms the XML referred by attribute doc with the XSLT referred by attribute xslt. If attribute var is specified, the result is stored in TransformContext under the given name; otherwise, the result is output.
If any x:param tags are specified, their attributes var and select are used as transformation parameters.
The tag transforms the XML referred by attribute doc with the XSLT referred by attribute xslt. If attribute var is specified, the result is stored in TransformContext under the given name; otherwise, the result is output.
If any x:param tags are specified, their attributes var and select are used as transformation parameters.
Example:
<x:transform doc="nav-xml" xslt="top-xslt">
<x:param var="color" select="${bg-color}"/>
</x:transform>
Comments
Link to the actual parser implementation code: https://code.google.com/p/yet-another-tridion-blog/source/browse/trunk/REL+Standard+Tag+Library/#REL%20Standard%20Tag%20Library%2Fsrc%2Fnet%2Fmitza%2Frel%2Fparser