Rendering canSAS1D in Web Browsers

From canSAS
Revision as of 14:44, 18 March 2012 by Jemian (talk | contribs) (→‎Android)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Using a stylesheet with CanSAS XML files

One of the benefits of XML is that with an appropriate stylesheet, web browsers should be able to render the page as HTML, and other XML-compliant applications can interpret what a file contains and do something sensible with it.

In order to use this feature, the XML file must have a stylesheet associated with it. This can either be local to the machine the XML file resides on, or accessed via a remote URL.

A default stylesheet is provided for the cansSAS1D format at: http://www.smallangles.net/cansas1d/1.0/cansasxml-html.xsl

In order to use this, there must be a line in the XML data file (usually the second line, after the xml declaration itself) as follows:

<?xml-stylesheet type="text/xsl" href="http://www.smallangles.net/cansas1d/1.0/cansasxml-html.xsl"?>

Thus the header will look something like:

<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.smallangles.net/cansas1d/1.0/cansasxml-html.xsl"?>
<SASroot version="1.0" 
   xmlns="cansas1d/1.0" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:schemaLocation="cansas1d/1.0  http://www.smallangles.net/cansas1d/1.0/cansas1d.xsd">
<SASentry> ...

Browser Compatibility

However, having a local file referencing a remote one is sometimes considered to be a security risk by certain browsers. Thus in some cases it may be necessary to store the XSL file locally and change the URL in the header appropriately.

Below is a list of various browsers/OS combinations and how they behave. The list is not comprehensive.

Windows 7

  • IE 8
    • Works with local and remote stylesheets
  • IE 9
    • Works with local stylesheets only after altering the browser security settings (Internet Options->Security->Custom Level, and then under "Miscellaneous" enable "Access data sources across domains")
  • Firefox 10
    • Works with local stylesheets only
  • Google Chrome
    • Does not work with remote or local stylesheets
  • Opera
    • Not tested
  • Safari
    • Not tested

Mac OS

  • Safari 5
    • Works with remote and local stylesheets with no changes
  • Google Chrome
    • Does not work with remote or local stylesheets
  • Firefox 6
    • Works with local stylesheets only
  • Opera
    • Not tested

Linux

  • Firefox
    • Not tested but assume the same behaviour as other platforms

iOS

  • Mobile Safari
    • Not tested
  • Opera Mobile/Mini
    • Not tested

Android

  • Dolphin & Dolphin HD
    • Not tested
  • Firefox
    • Not tested but assume the same behaviour as other platforms
  • Opera Mobile/Mini
    • Not tested