The W3C describes how you can embed a stylesheet within an XML file and then refer to it, allowing the document to transform itself. Unfortunately IE and Firefox don't seem to support this, but I did find a description of how to embed data within a stylesheet, giving similar effect. This doesn't solve my current problem (more about that below), but it does make it much easier to show examples of stylesheets. In particular, here is the authorities stylesheet described earlier with an embedded SRU searchRetrieve response (looks best in Firefox).
The reason I was trying this was to see if embedding the stylesheet in the SRU response would speed up the displays. For the VIAF prototype we're working on I was trying to get a Google suggest-type service to show potential headings as the user typed in a query, and to do it using SRU (Google sends the source for JavaScript arrays down and runs 'eval' on it to get objects.) Two things seem to be slowing this down. The first is that the SRU responses (with full records) are huge (~150K), slowing both transmission and processing. Ralph LeVan says that by using different schema we could get around that. The other problem is that by the time associated style sheets are pulled in, too many HTTP interactions take place. Maybe different settings on my browser cache would help, but it would be nice to avoid those calls altogether.
Haven't solved this yet, although if you look at the example's source I have managed to embed the CSS stylesheet within the XSLT.
--Th
As far as the W3C recommendation for embedding a stylesheet, you might try changing the MIME type on the xml-stylesheet directive to text/xsl for IE. IE understands two MIME types for xml-stylesheet directives: text/css and text/xsl. The section in the W3C recommendation shows the MIME type as text/xml, but the text in that section does not issue a recommendation as to what MIME type should be used, hence browser dependent. IE choose to use the MIME type that is used for standalone XSLT documents. Not an unreasonable choice.
It still might not work IE, but give that go.
Posted by: Andrew Houghton | August 09, 2005 at 20:10
I'm pretty sure I did try that, since text/xml didn't get me anywhere, but couldn't get it to work.
--Th
Posted by: Thom | August 10, 2005 at 08:27
It provides support of stylesheet embedding for ALL browsers (including IE, FF supports it already).
You may want to use the technique described in this posting:Posted by: HermannSW | February 27, 2010 at 20:09