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

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

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
xsl param command line
----- 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
mechanism.

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

<xsl:template name="mkdir">
  <xsl:param-variable name="directory"/>
  <P>created directory <xsl:value-of select="$directory"/>:<xsl:value-of
select="f:mkdir(f:new(string($directory)))"
xmlns:f="http://www.jclark.com/xt/java/java.io.File"/></P>
</xsl:template>

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))"
xmlns:w="http://www.jclark.com/xt/java/com.jclark.xsl.sax.HTMLFileWriter"/>
  <P>wrote file <xsl:value-of select="$file"/></P>
</xsl:template>

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"/>
</xsl:template>

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>
  <xsl:call-template name="write">
    <xsl:param name="file">xmlsoftware-html/index.html</xsl:param>
    <xsl:param name="contents">
      <HTML>
        <HEAD>
          <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:  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.