RE: How to tell users their browser won't work to this XML/XSLT page.

<[email protected]>
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Message-ID <[email protected]>
Hi,

> I have web pags that depend on XML transformations by XSLT.  
> When a viewer
> with a non-transforming browser tries to view the page, he 
> gets gibberish.
> If he's an expert, he could "Show source" and see comments 
> telling him what
> the problem is.  Unfortunately, most folks with ancient 
> browsers don't know
> how to do this.
> 
> Is there a way to set up the pages to produce an HTML view IF 
> the browser
> doesn't support XML/XSLT?

If it suits your system, you could use a splash page that directs the user to the correct page with something in the lines of

<?xml-stylesheet type="text/xsl" href="tester.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="refresh" content="0;url=noxslt.html" />
    <title>Splash page</title>
  </head>
  <body>
    <p>
      <a href="noxslt.html">Go to main page</a>
    </p>
  </body>
</html>

with tester.xsl being

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:h="http://www.w3.org/1999/xhtml"
                xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="h:meta">
  <meta http-equiv="refresh" content="0;url=xslt.xml" />
</xsl:template>
<xsl:template match="h:a">
 <a href="xslt.xml">
   <xsl:apply-templates/>
 </a>
</xsl:template>
<xsl:template match="@* | node()">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
  </xsl:copy>
</xsl:template>
</xsl:stylesheet>

However, you need to send the document with an XML MIME-type, and some browsers will then reject it. You may get around this by using a combination of the above and Javascript, but it'll probably get messy as different browsers have a different API for XSLT processing.

Cheers,

Jarno
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.