|
[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: importing/including a stylesheet with a dynamic na
Subject: Re: importing/including a stylesheet with a dynamic name (can't)
From: Chris Gow <cgow@xxxxxxxxxxxxxxxxxx>
Date: Tue, 30 Jan 2001 11:38:06 -0500
|
Dunno if this is an option, but cocoon lets you change the stylesheet to be
used.
Chris
At 07:59 AM 1/30/01 -0800, you wrote:
Hi.
This list, and the various related sites are a wonderful reference,
and I am enjoying coming up to speed on XSL/XML, using Xalan and Tomcat to
invoke it.
It seems that there is no way to dynamically import or include another
stylesheet, unless one writes the calling stylesheet at runtime.
In the system I am working with I don't have any control over writing
the stylesheet at runtime, it is delivered statically, and transformation
occurs only once, so I can't write a sheet dynamically with the
different file references everytime a transform is requested.
More concretely, I am trying to create a sheet that uses a default
stylesheet for a portion of an HTML document, but I want that
portion to be able to be replaced by a user simply specifying
an alternate stylesheet source in the source XML of the translation.
In the sheet below, I want to replace defaultbody.xsl with a
user's defined user.xsl that redefines the headersection and
bodysection templates. (Perhaps I am still thinking like a C++ programmer
too much)
XML fragment could have:
<styleSheet>c:/tmp/frobnatz.xsl</styleSheet>
or it could have
<styleSheet/>
XSL fragment:
<!-- if the stylesheet element of the input XML is null, use this
default -->
<xsl:include href="defaultbody.xsl"/>
<!-- o.w. CANT DO THIS, but I want to -->
<xsl:include href="$UserXSLDoc"/>
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Blah blah</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<xsl:call-template name="headersection"/>
<xsl:apply-templates select="bodysection"/>
</BODY>
</HTML>
</xsl:template>
Note that this cannot work for several reasons:
<xsl:choose>
<!-- no stylesheet specified, use ours -->
<xsl:when test="/foo/bar/styleSheet=''">
<!-- emit the formatted rows of worklist info -->
<xsl:apply-templates select="workList/workListItem"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="XSLURL">
<xsl:value-of select="foo/bar/styleSheet"/>
</xsl:variable>
Use the sheet at <xsl:value-of select="$XSLURL"/>
<xsl:value-of select="document($XSLURL)"/>
</xsl:otherwise>
</xsl:choose>
Regards and thanks:
Joe Longo
Software Generalist
Nevada City, California
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
===============================================================================
"It is inhumane, in my opinion, to force people who have a genuine
medical need for coffee to wait in line behind people who apparently
view it as some kind of recreational activity."
-- Dave Barry
-------------------------------------------------------------------------------
Chris Gow Digital Fairway Corporation
Software Engineer 180 Attwell Drive Suite 360
cgow@xxxxxxxxxxxxxxxxxx Etobicoke, ON M9W 6A9
http://www.digitalfairway.com 416.628.7534
===============================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
| RSS 2.0 |
|
| Atom 0.3 |
|
|