Difference between revisions of "Rendering canSAS1D in Web Browsers"

From canSAS
(Created page with " == Using a stylesheet with 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. In order ...")
 
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  
== Using a stylesheet with XML files ==
+
== 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.
+
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.
 
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.
Line 24: Line 24:
 
== Browser Compatibility ==
 
== Browser Compatibility ==
  
However, not all browsers will behave well as it is often seen to be a security risk having a local file referencing a remote one. Hence in some cases you must store the XSL file locally and change the URL in the header appropriately.
+
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 and how they behave
+
Below is a list of various browsers/OS combinations and how they behave. The list is not comprehensive.
  
 
=== Windows 7 ===
 
=== Windows 7 ===
Line 33: Line 33:
 
** Works with local and remote stylesheets
 
** Works with local and remote stylesheets
 
* IE 9
 
* IE 9
** Works with local stylesheets only after allowing "Access data sources across domains" in the security settings
+
** 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
 
* Firefox 10
 
** Works with local stylesheets only
 
** Works with local stylesheets only
Line 51: Line 51:
 
* Firefox 6
 
* Firefox 6
 
** Works with local stylesheets only
 
** 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

Latest revision as of 09:44, 18 March 2012

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