Re: [xsl] Man Page Transform and Modes

Subject: Re: [xsl] Man Page Transform and Modes
From: Michael B Allen <mba2000@xxxxxxxxxx>
Date: Wed, 5 Apr 2006 20:45:30 -0400
On Wed, 5 Apr 2006 19:24:44 -0500
"Jon Gorman" <jonathan.gorman@xxxxxxxxx> wrote:

> So did using the mutliple modes not work (the other of my two suggestions?)?

Modes work. In fact, I'm now certain that using modes is the correct
technique because SYNOPSIS, DESCRIPTION, RETURNS, etc are really just
different views of the same data (data about functions).

The problem is simply that you cannot define templates that should work
with multiple modes so you end up duplicating many potentially large
templates all over the place.

> ie
> <xsl:template match="daElement" mode="foo bar"
> 
> to match modes foo and bar?  Now that I think about it, it's probably
> only in XSLT 2.0 to do this.  I also think there's a mode like #all
> that matches all.

This is exactly what I need. But both yield an error with my current
processor:

  man.xsl:205:57: Error! Illegal value: description section used for
  QNAME attribute: mode Cause: java.lang.IllegalArgumentException:
  Localname in QNAME should be a valid NCName

I guess I'm not 2.0 yet :-/

> Also, you could always do a named template within.  Doesn't reduce
> clutter completely but helps.
> ie
> 
> <xsl:template match="foo" mode="hi">
> <xsl:call-template name="foo"...

Bingo! That works great:

  <xsl:template match="text()" mode="description">
      <xsl:call-template name="text"/>
  </xsl:template>
  <xsl:template match="text()" mode="returns">
      <xsl:call-template name="text"/>
  </xsl:template>

It's not as clean as the 2.0 way but I'm not duplicating templates all
over the place.

Thanks,
Mike

Current Thread