DeveloperWeb

  Dashboard > GX DeveloperWeb > Home > XSL XSLT examples
XSL XSLT examples Log In | Sign Up   View a printable version of the current page.

Added by martinvm , last edited by Martin van Mierloo on Jul 01, 2008  (view change)
Labels: 
(None)

Using XSL for user profiles

Show all fields + values from the user session
<xsl:for-each select="/root/system/user/child::*">
	<strong><xsl:value-of select="name()"/></strong> - <xsl:value-of select="."/><br/>
  <xsl:text disable-output-escaping="yes"><![CDATA[
]]></xsl:text>
</xsl:for-each>
Show the username from the session
<xsl:value-of select="/root/system/user/firstname" />
Show the entire user name:
<xsl:value-of select="/root/system/user/firstname" />&#xa0;<xsl:value-of select="/root/system/user/prefix" />&#xa0;<xsl:value-of select="/root/system/user/lastname" />
Check if a user has logged in

type: condition

count(/root/system/user) &gt; 0
Check if a user has not logged in

type: condition

count(/root/system/user) = 0
Check if a webuser is part of a certain webuser group:
count(/root/system/usergroup[groupname = 'webgroep1']) &gt; 0
Check if this is the first visit of a visitor
/root/system/user/nr_visits=0
Check if the visitor has visited the site before
/root/system/user/nr_visits>0
Check if the user is younger than 50
substring(/root/system/user/birthdate,1,4) &gt;  (substring(/root/system/date,1,4)-50)

Using XSL in forms

Show all form values on the page
<xsl:for-each select="/root/system/flow/formelement/formpart">
  <strong><xsl:value-of select="@description" /></strong>: <xsl:value-of select="userentry" />
  <xsl:if test="not(/root/system/requestparameters/parameter/name[text()='textversion'])"><br /></xsl:if>
  <xsl:text disable-output-escaping="yes"><![CDATA[
]]></xsl:text>
</xsl:for-each>
Show all form values in for example an email handler:
<xsl:for-each select="/handler/flow/formelement/formpart">
  <xsl:value-of select="@description" />: <xsl:value-of select="userentry" />
  <xsl:text disable-output-escaping="yes">  
</xsl:text>
</xsl:for-each>
Check if the form session exists:
count(/root/system/requestparameters/parameter[name = 'ff']) = 0 or count(/root/system/flow) &gt; 0

or

count(/root/system/flow/formelement/formpart[@xsltag = 'vraag1']) = 0 or count(/root/system/flow) &gt; 0
Check a form value based on an xsltag:

On the page:

/root/system/flow/formelement/formpart[@xsltag = 'vraag1']/userentry='Antwoord1'

In handlers

/handler/flow/formelement/formpart[@xsltag = 'vraag1']/userentry='Antwoord1'
Show the contents of a form field based on an XSL tag
<xsl:value-of select="//flow/formelement/formpart[@xsltag = 'wm-google-query']/userentry"/>
Check on form errors:
count(/handler/flow/formelement/error[@code='not_found']) &gt; 0

Miscellaneous expressions

Show a request (query string) parameter:
<xsl:value-of select="/root/system/requestparameters/parameter[name='newscategory']/value"/>
To create an A HREF tag with XSL:
<xsl:element name="a">
	<xsl:attribute name="href">
		/artikel/<xsl:value-of select="@id" />
	</xsl:attribute>
	<xsl:value-of select="titel" />
</xsl:element>
XSL characters
  • space:
    &#xa0;
  • larger than '>' :
    &gt;
  • small than '<' :
    &lt;
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators