pjfarley3 Posted May 20, 2006 Share Posted May 20, 2006 Hi all,XML/XSL newbie here. I have a need to be able to put BOTH XSL and XML that uses the XSL into a single stream sent by a server to a client browser (IE6 only for now). The XSL cannot reside on the server.Is it possible to send XML without having the XSL reside on the server, i.e. not using "href" in the XSL line inside the XML?I tried doing the following, but it doesn't work. THe top-level element, "cdcat", is just displayed in the default XML format in the browser.Data and stylesheet copied from the W3Schools tutorials. <xml id="cdcat"><?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited with XML Spy v2006 (http://www.altova.com) --><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/><xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">Title</th> <th align="left">Artist</th> </tr> <xsl:for-each select="catalog/cd"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:for-each> </table> </body> </html></xsl:template></xsl:stylesheet><!-- Edited with XML Spy v2006 (http://www.altova.com) --><CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>CBS Records</COMPANY> <PRICE>9.90</PRICE> <YEAR>1988</YEAR> </CD></CATALOG></xml> Link to comment Share on other sites More sharing options...
boen_robot Posted May 20, 2006 Share Posted May 20, 2006 The file must always be on the server of course. How could it be processeed if it's not on the server? I think what you meant was "without explicit reference in the XML"?Well, if there isn't going to be a processing instruction with the href attribute, then there must be some third language (on a third file) to connect the two files. It could be a server side script (as in the "XSLT on the server" examples) or if it must be on the client side- with JavaScript.It can't be done by simply combining the files into one, unless perhaps there is some server side script that would know which is which and apply the stylesheet as if it was a separate file. But there's no point in that. If you're going to keep the things in one file, it's better to have plain XHTML instead. Link to comment Share on other sites More sharing options...
pjfarley3 Posted May 21, 2006 Author Share Posted May 21, 2006 The file must always be on the server of course. How could it be processeed if it's not on the server? I think what you meant was "without explicit reference in the XML"?Yes, that is what I meant -- no explicit reference to the server in the XML.Well, if there isn't going to be a processing instruction with the href attribute, then there must be some third language (on a third file) to connect the two files. It could be a server side script (as in the "XSLT on the server" examples) or if it must be on the client side- with JavaScript.I was hoping there could be a "local" substitute for the "href", possibly in an IE6 "data islands" setup, along the lines of:<?xml-stylesheet type="text/xsl" href=#cdxsl?>where "cdxsl" is the "id" of a preceding "data island": <xml id="cdxsl">...xsl here...</xml>. I tried exactly this in IE6, and it does not work.It can't be done by simply combining the files into one, unless perhaps there is some server side script that would know which is which and apply the stylesheet as if it was a separate file. But there's no point in that. If you're going to keep the things in one file, it's better to have plain XHTML instead.<{POST_SNAPBACK}> Thanks for the advice. I guess I have to go with the client-side javascript solution, and supply the XSL as embedded text in the javascript.Peter Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now