Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created June 6, 2012 14:18
Show Gist options
  • Save netsi1964/2882142 to your computer and use it in GitHub Desktop.
Save netsi1964/2882142 to your computer and use it in GitHub Desktop.
VARIOUS VIA XSLT SNIPPETS
<?xml version="1.0" encoding="utf-8"?>
<!-- https://gist.github.com/raw/2882142/02058e354cc9eb8d283b57147d6c1b6aadac7fb7/variousVIASnippets.xslt -->
<!-- VARIOUS VIA XSLT SNIPPETS -->
<!-- Sten Hougaard, [email protected] - 2012-06-06 -->
<!-- On module snippets -->
<xsl:key name="QueryString" match="//RequestContent/QueryString/Entry" use="@Name"/>
<xsl:key name="request" match="//RequestContent/ServerVariables/Entry" use="@Name"/>
<!-- On page snippets -->
<xsl:key name="field" match="/Page/Document/DocumentEdition/Fields/Field" use="@Name"/>
<xsl:key name="QueryString" match="/Page/RequestContent/QueryString/Entry" use="@Name"/>
<xsl:key name="request" match="/PageRequestContent/ServerVariables/Entry" use="@Name"/>
<!-- easy access to document fields, querystring and request values -->
<xsl:key name="field" match="/ModuleElement/Document/DocumentEdition/Fields/Field" use="@Name"/>
<xsl:key name="QueryString" match="/ModuleElement/RequestContent/QueryString/Entry" use="@Name"/>
<xsl:key name="request" match="/ModuleElement/RequestContent/ServerVariables/Entry" use="@Name"/>
<xsl:variable name="UserName"/ModuleElement/RequestContent/CurrentUser/UserName" />
<!-- USE -->
<xsl:value-of select="key('request','PATH_INFO')" />
<xsl:value-of select="key('QueryString','id')" />
<textarea rows="10" cols="80">
<xsl:copy-of select="."/>
</textarea>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ'" />
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyzæøå'" />
<textarea name="debug" class="debug" cols="30" rows="10">
<xsl:text disable-output-escaping="yes"><![CDATA[<?xml version="1.0" encoding="utf-8"?>]]></xsl:text>
<xsl:copy-of select="." />
</textarea>
<!--
Prevent empty or self closing content
*[not(normalize-space() = '')]
Examples:
-->
<xsl:copy-of select="*[not(normalize-space() = '')]" />
<xsl:value-of select="*[not(normalize-space() = '')]" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment