Rendering canSAS1D in Web Browsers: Difference between revisions
Line 2: | Line 2: | ||
== Using a stylesheet with CanSAS 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. |
Revision as of 15:57, 14 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, 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.
Below is a list of various browsers 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
- Firefox
- Not tested but assume the same behaviour as other platforms
- Opera Mobile/Mini
- Not tested