[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: multiple output files/getting command-line parameters in XT


Subject: RE: multiple output files/getting command-line parameters in XT
From: "Sebastian Rahtz" <sebastian.rahtz@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Jul 1999 20:36:22 +0100 (BST)

Mike Brown writes:
 > James Tauber wrote:
 > > What I've started to do lately when producing multiple 
 > > HTML files from a single (possibly large) XML document
 > > is to generate *all* the HTML using XT's extension
 > > mechanism and making the result tree simply a "status
 > > document" (often just output to stdout).
 > 
 > Can you provide a short example of how you're doing this?

Suppose your document has a series of <div1> sections, with nested
<div2> sections. The following template makes a summary file called
"main.html" which lists the <div1> titles in a table of contents, and
links them to separate files. A separate template for "div1" would
take charge of starting a new file end naming it according to
generate-id().

This is for XT; Saxon's syntax for the file writing is more
elegant. Do the Lotus and Oracle XSL's have the facility at all?

the demo files split.xsl and slides.xsl in XT demonstrate these things 
rather well

sebastian


<xsl:template match="/">

 <xsl:apply-templates select="div1"/>

 <xsl:call-template name="write">
    <xsl:param name="file">main.html</xsl:param>
    <xsl:param name="contents">
 <html> 
 <head>
 <title></title>
 </head>
 <body>
 <ul>
 <xsl:for-each select="div1">
 <xsl:variable name="divname" expr="concat(generate-id(),'.html')"/>
  <li><a href="{$divname}">
     <xsl:apply-templates select="head"/>
 	</a>
    <xsl:if test="from-descendants(div2)">
    <ul>
     <xsl:for-each select="div2">
     <li><a href="{concat($divname,concat('#',generate-id()))}">
     <xsl:apply-templates select="head"/>
	</a>
     </li>
     </xsl:for-each>
    </ul>
   </xsl:if>
  </li>
 </xsl:for-each>
 </ul>
 </body>
 </html>
 </xsl:param>
 </xsl:call-template>
</xsl:template>

<xsl:template name="write">
  <xsl:param-variable name="contents"/>
  <xsl:param-variable name="file"/>
  <xsl:value-of select="w:write($contents,string($file))"
     xmlns:w="http://www.jclark.com/xt/java/com.jclark.xsl.sax.HTMLFileWriter"
   />
</xsl:template>


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



Current Thread
Keywords
xml