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

Subject: Re: multiple output files/getting command-line parameters in XT
From: "James Tauber" <jtauber@xxxxxxxxxxx>
Date: Wed, 14 Jul 1999 13:03:51 +0800
----- Original Message -----
From: Mike Brown <mbrown@xxxxxxxxxxxxx>

> 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?

Sure. I'll provide the full stylesheet soon, but for now...

First of all, I have two named templates that call Java via XT's extension

The first, mkdir, makes a directory with the name passed as the parameter

<xsl:template name="mkdir">
  <xsl:param-variable name="directory"/>
  <P>created directory <xsl:value-of select="$directory"/>:<xsl:value-of

Notice that this constructs a P element in the result tree with a status
message "created directory foobar true/false". The result tree becomes the
status message and the real work is done by the side-effect of calling
"mkdir" and "write" (below).

The second named template I generally use is called "write", defined as:

<xsl:template name="write">
  <xsl:param-variable name="contents"/>
  <xsl:param-variable name="file"/>
  <xsl:value-of select="w:write($contents,string($file))"
  <P>wrote file <xsl:value-of select="$file"/></P>

This writes the given contents to the given file. It also constructs a
status message in the result tree.

My root template calls templates, one of which creates XMLSOFTWARE's
homepage, another of which creates all of the category pages (which are not
known in advance as they are derived from the single xml document that
XMLSOFTWARE is made from).

<xsl:template match="/">
  <xsl:call-template name="homepage"/>
  <xsl:call-template name="category-pages"/>

The start of the template "homepage" looks like this:

<xsl:template name="homepage">
  <xsl:call-template name="mkdir">
    <xsl:param name="directory">xmlsoftware-html</xsl:param>
  <xsl:call-template name="write">
    <xsl:param name="file">xmlsoftware-html/index.html</xsl:param>
    <xsl:param name="contents">
          <TITLE>XMLSOFTWARE: The XML Software Site</TITLE>

You can see that it called "mkdir" and then "write" with all the HTML as the
value of "contents".

I hope this helps.

James Tauber

 XSL-List info and archive:

Current Thread