Subject: [xsl] importing/including a stylesheet with a dynamic name (can't) From: "Joe Longo" <joe@xxxxxxxxxxx> Date: Tue, 30 Jan 2001 07:59:41 -0800 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSLT and Unicode characte, Dave Gomboc | Thread | Re: [xsl] importing/including a sty, Chris Gow |
[xsl] XSLT and Unicode character fu, Eric Vermetten | Date | Re: [xsl] importing/including a sty, Chris Gow |
Month |