RE: [xsl] generating dynamic XSL to apply to a single XML document

Subject: RE: [xsl] generating dynamic XSL to apply to a single XML document
From: "Steven Bethard" <bediviere@xxxxxxxxxxx>
Date: Wed, 10 Sep 2003 10:04:11 -0600
Ok, so I discovered that I should be able to avoid the temporary
stylesheet by embedding my stylesheet in my XML.  Unfortunately, I can't
seem to get this to work with the data import.  Here's my example:

---- data.xml ----
<?xml version="1.0" encoding="UTF-8"?>

---- formatted-data.xml ----
<?xml version="1.0"?>
<!DOCTYPE page [
<!ENTITY data SYSTEM "data.xml">
<?xml-stylesheet type="text/xsl" href="#stylesheet"?>
		<xsl:stylesheet version="1.0"
			<xsl:template match="xsl:stylesheet" />
			<xsl:template match="foo">
				<xsl:apply-templates />

			<xsl:template match="baz">
				<h1>BAZ <xsl:value-of select="." /></h1>


The file data.xml is the original data file that I need to format in
several ways.  The file formatted-data.xml would be generated
dynamically by the CGI script.  When I display this in Internet
Explorer, I get a single big heading with "BAZ", and the text "aaa bbb"
below it.  I can't guess why the "baz" template would only match one
thing, or why when it matches that one thing there is no content in the
"." node.

Can anyone tell me why this doesn't work?  (And hopefully how to make it
work...) :)


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Steven
Sent: Wednesday, September 10, 2003 2:00 AM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] generating dynamic XSL to apply to a single XML document

I have a single XML document that contains the data.  There are several
different views of this data that I need to display, and exactly what
goes into a view will be determined by some selections in an HTML form.
So my plan had been to incorporate a CGI script that would take the form
parameters, generate the appropriate XSL stylesheet, and format the XML
document using this stylesheet.

The only way I know to apply a different XSL stylesheet to the same XML
document is something like:
<?xml version="1.0"?>
<!DOCTYPE page [
<!ENTITY data SYSTEM "data.xml">
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
which (I believe) would mean I would have to save a file called
"style.xsl", and then have the CGI script return the above as xml data.

I'd rather not create a bunch of temporary files (for the "style.xsl"
files) if I can avoid it. Is there a better way to do this?


 XSL-List info and archive:

 XSL-List info and archive:

Current Thread