Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created September 18, 2012 06:33
Show Gist options
  • Save netsi1964/3741577 to your computer and use it in GitHub Desktop.
Save netsi1964/3741577 to your computer and use it in GitHub Desktop.
Various XSLT stuff
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts"
exclude-result-prefixes="xsl msxsl user"
>
<msxsl:script language="C#" implements-prefix="user">
<msxsl:assembly name="System.Web" />
<msxsl:using namespace="System.Web" />
<![CDATA[
public void RedirectTo(string Location){
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", Location);
Response.End();
}]]>
</msxsl:script>
<xsl:template match="/">
<!-- Make a redirect using C# -->
<xsl:value-of select="user:RedirectTo('/')" />
<!--
Prevent empty or self closing content
*[not(normalize-space() = '')]
Examples:
-->
<xsl:copy-of select="*[not(normalize-space() = '')]" />
<xsl:value-of select="*[not(normalize-space() = '')]" />
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment