[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

importing/including a stylesheet with a dynamic name (

Subject: importing/including a stylesheet with a dynamic name (can't)
From: "Joe Longo" <joe@xxxxxxxxxxx>
Date: Tue, 30 Jan 2001 07:59:41 -0800
joe longo
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.