[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSLT and XML in the same document
On Tue, 29 May 2007 04:03:09 -0600, M. David Peterson <m.david@xxxxxxxxxxxxx> wrote: Ugg! There is oh so very much the browser can do with client-side XSLT that takes so much load off of the server.
One could easily look at this and suggest that the server should just do the redirects as sending messages to the client is an extra step that is unnecessary. Of course, if this was all the client-side XSLT solution did, you would most definitely be correct. However, when you add to the mix the ability to quickly and easily determine what content should be rendered on the client based on the response, you will (hopefully!) discover that *MUCH* power exists by passing nothing but simple XML messages around, and using these messages to then generate content on the client via XML and XSLT files that have long since been cached, accessing the proper data files via the document function for each specific page on any given site. Of course, in doing so you also gain the benefit of bypassing the SGML parser and moving directly to the XML parser, which then means you are using the XSLT processor to transform the content directly into a DOM object. As such, no more quirks mode, no more SGML parser, no more junk clogging the internet pipelines that doesn't need to be sent to the browser -- *again* -- just because its the way things have been done in the past. Heck, come to think of it, using client-side XSLT to both reduce processing as well as to reduce the amount of data being sent with each response could significantly reduce greenhouse gas emissions and save the planet as a result! ;-) :D <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="html"> <xsl:variable name="return-uri" select="/auth/return-location" /> <xsl:variable name="vendor" select="system-property('xsl:vendor')" /> <xsl:output doctype-system="-//W3C//DTD HTML 4.01//EN" doctype-public="http://www.w3.org/TR/html4/strict.dtd" cdata-section-elements="script" method="html" omit-xml-declaration="yes" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="auth"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>SonicRadar OpenID Redirection...</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <xsl:if test="@redirect-type = 'meta'"> <xsl:choose> <xsl:when test="@status = 'redirect'"> <xsl:apply-templates select="url" mode="meta-redirect" /> </xsl:when> <xsl:when test="@status = 'complete'"> <xsl:apply-templates select="message" mode="meta-redirect" /> </xsl:when> </xsl:choose> </xsl:if> <xsl:if test="not(@redirect-type = 'meta')"> <script type="text/javascript"> <![CDATA[ var fs = new RegExp("%2F", "g"); var colon = new RegExp("%3A;", "g"); var amp = new RegExp("&", "g"); function doRedirect(escapedURI){ window.location.replace(escapedURI.replace(fs, "/").replace(colon, ":").replace(amp, "&")); }; ]]> </script> </xsl:if> </head> <xsl:if test="not(@redirect-type = 'meta')"> <xsl:choose> <xsl:when test="@status = 'redirect'"> <xsl:apply-templates select="url" mode="replace" /> </xsl:when> <xsl:when test="@status = 'complete'"> <xsl:apply-templates select="message" mode="replace" /> </xsl:when> </xsl:choose> </xsl:if> </html> </xsl:template> <xsl:template match="url" mode="replace"> <body onload="doRedirect('{.}');"> <h3>Redirecting...</h3> </body> </xsl:template> <xsl:template match="url" mode="meta-redirect"> <meta http-equiv="Refresh" content="0;url={.}" /> </xsl:template> <xsl:template match="message" mode="replace"> <body onload="doRedirect('{concat($return-uri, substring-before(substring-after(., 'http%3A%2F%2F'), '%2F'))}');"> <h3>Redirecting...</h3> </body> </xsl:template> <xsl:template match="message" mode="meta-redirect"> <meta http-equiv="Refresh" content="0;url={concat($return-uri, substring-before(substring-after(., 'http%3A%2F%2F'), '%2F'))}" /> </xsl:template> </xsl:stylesheet> -- /M:D M. David Peterson http://mdavid.name | http://www.oreillynet.com/pub/au/2354 | http://dev.aol.com/blog/3155
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|