RE: [xsl] Parameter in "xsl:include"

Subject: RE: [xsl] Parameter in "xsl:include"
From: Joshua.Kuswadi@xxxxxxxxxxxxxxxxxxxx
Date: Thu, 29 Mar 2001 13:41:10 +1000
Hi all,

I'm still new to XSL, so if this has already been asked on the list I sincerely apologise. (I've been reading through this list for only three months, and I've checked out Dave Pawson's immense FAQ site, but haven't yet found an answer.)

Similar to Martin's question a month back, I want to use an external parameter/variable in an <xsl:include>. The difference is that each time the stylesheet is used, the parameter _may_ be different. ie I'd like it this to be a runtime thing. Ideally I'd like to separate the data from the presentation to the extent that I can call a 'wrapper' stylesheet with a parameter to include the appropriate stylesheet depending upon the output I desire.

I've just set up my XSL files for different output types in different directories.
eg.	html/
	wml/
and was planning on having a 'wrapper' stylesheet like that mentioned by Norm Walsh (http://www.dpawson.co.uk/xsl/N5982.html) :
<xsl:stylesheet>
	<xsl:param name="OutputType">HTML</xsl:param>
	<xsl:include href="$OutputType/stylesheet.xsl"/>
</xsl:stylesheet>

The difference is that I wanted to have a permanent 'wrapper' stylesheet, that could accommodate either situation. 

>From what I've read, it isn't possible to use parameters in includes, though it can be done with entities. However, is it possible to generate entities at runtime?

If I'm mistaken in any, possibly many, ways, please let me know. If anyone has had to solve this problem already, again I'd love to hear it. Lastly, if this isn't possible at run-time using XSL, what are your comments/ideas about generating the 'wrapper' stylesheet at run time?

Thanks in advance,

Joshua



> -----Original Message-----
> From: Michael Kay [mailto:mhkay@xxxxxxxxxxxx]
> Sent: Friday,9 February 2001 5:46
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Parameter in "xsl:include"
> 
> 
> This sounds like a case for using XML entities to me:
> 
> <xsl:include href="&common;/template1.xsl"/>
> 
> Alternatively depending on your processor you could set up a 
> URIResolver to
> resolve the URL externally.
> 
> Mike Kay
> 
> > -----Original Message-----
> > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of
> > Martin Renner
> > Sent: 08 February 2001 16:13
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Re: [xsl] Parameter in "xsl:include"
> >
> >
> > Hi.
> >
> > > No. (FAQ). xsl:include is a compile-time facility, not
> > run-time. Explain
> > > your problem, and someone will tell you the right way of 
> solving it.
> >
> > Cool service :-)
> >
> > I have several XSL files which have some parts in common. So
> > I would like to put
> > those common parts (three different "xsl:template match"
> > blocks) in three different
> > files which can be included as needed.
> >
> > The XSL files, which will include the common files, are
> > structered within subdirectories.
> >
> > To make the use of the includes less error-prone, all
> > include-statements should look
> > the same (so someone can use copy&paste).
> >
> > e.g. something like
> >
> > file1:      include "$common/template1.xsl"
> > sub1/file2: include "$common/template1.xsl"
> >
> > instead of
> >
> > file1:      include "../common/template1.xsl"
> > sub1/file2: include "../../common/template1.xsl"
> >
> > The parameter "$common" is already set to the correct
> > directory. It's just that I
> > cannot use it in xsl:include.
> >
> >
> > Martin

------------------------------------------------------------------------------
This message and any attachment is confidential and may be privileged or otherwise protected from disclosure.  If you have received it by mistake please let us know by reply and then delete it from your system; you should not copy the message or disclose its contents to anyone.





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread