Created
March 11, 2012 03:18
-
-
Save bauhouse/2014856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<data> | |
<useragent-details mobile="no" chromeframe="no" robot="no"> | |
<browser version="5.2" handle="safari">Safari</browser> | |
<operating-system handle="mac-os-x-lion" platform="Apple">Mac OS X Lion</operating-system> | |
<ip-address>127.0.0.1</ip-address> | |
</useragent-details> | |
<device-categorizr>desktop</device-categorizr> | |
</data> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
<xsl:output method="xml" | |
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" | |
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" | |
omit-xml-declaration="yes" | |
encoding="UTF-8" | |
indent="yes" /> | |
<xsl:variable name="device-categorizr" select="/data/device-categorizr" /> | |
<xsl:template match="/"> | |
<html> | |
<head> | |
<title>Device Categorizr</title> | |
</head> | |
<body> | |
<xsl:apply-templates select="data" /> | |
</body> | |
</html> | |
</xsl:template> | |
<xsl:template match="data"> | |
<h1>Device and User Agent Details</h1> | |
<xsl:call-template name="device-categorizr" /> | |
<xsl:apply-templates select="useragent-details" /> | |
</xsl:template> | |
<xsl:template name="device-categorizr"> | |
<h2>Device Categorizr</h2> | |
<xsl:choose> | |
<xsl:when test="device-categorizr='desktop'"> | |
<p>Desktop</p> | |
</xsl:when> | |
<xsl:when test="device-categorizr='tv' or device-categorizr='tablet'"> | |
<p>TV or Tablet</p> | |
</xsl:when> | |
<xsl:otherwise> | |
<p>Other</p> | |
</xsl:otherwise> | |
</xsl:choose> | |
<p>The value of <code>$device-categorizr</code> is <code><xsl:value-of select="$device-categorizr" /></code></p> | |
</xsl:template> | |
<xsl:template match="useragent-details"> | |
<h2>User Agent Details</h2> | |
<h3>General</h3> | |
<ul> | |
<li>Mobile: <xsl:value-of select="@mobile" /></li> | |
<li>Chrome Frame: <xsl:value-of select="@chromeframe" /></li> | |
<li>Robot: <xsl:value-of select="@robot" /></li> | |
</ul> | |
<h3>Browser</h3> | |
<ul> | |
<li>Browser: <xsl:value-of select="browser" /></li> | |
<li>Version: <xsl:value-of select="browser/@version" /></li> | |
</ul> | |
<h3>Operating System</h3> | |
<ul> | |
<li>OS: <xsl:value-of select="operating-system" /></li> | |
<li>Platform: <xsl:value-of select="operating-system/@platform" /></li> | |
</ul> | |
<h3>IP Address</h3> | |
<ul> | |
<li>IP: <xsl:value-of select="ip-address" /></li> | |
</ul> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment