This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Attributes, modes and templates


>>>>> "WP" == Wendell Piez <wapiez@mulberrytech.com> writes:

WP> Alex, I haven't tested this, but looking at your examples, I think
WP> the problem is in your wildcard template:

Wendell,

Thanks for your advice, unfortunately, I tried it out, and I don't
think I'm much closer to a solution.

>> <!-- template (1) --> <xsl:template match="*"
>> mode="programmer-info-mode"> <xsl:text>Running wildcard template
>> for mode: </xsl:text><br/> <xsl:apply-templates select="."/>
>> </xsl:template>

WP> What this template seems to be doing is putting out your tracing
WP> text, then processing the node again in the default mode. So any
WP> time the mode is invoked with the match not otherwise specified,
WP> it gets uninvoked. So the node with the mode calls the same node
WP> with no mode (sorry). This is overriding the default general match
WP> for elements in the mode, which would be:

WP> <xsl:template match="*" mode="programmer-info">
WP> <xsl:apply-templates mode="programmer-info"> </xsl:template>

WP> One solution may be to change the wildcard template to a called
WP> template, like: <xsl:template name="programmer-info-mode-start">
WP> <xsl:text>Starting processing in mode: </xsl:text><br/>
WP> <xsl:apply-templates select="." mode="programmer-info-mode"/>
WP> </xsl:template>

Thanks.  I created this.

I think this is what you were suggesting as the modified stylesheet to
use:

<xsl:import href="/opt/src/alex/src/docbook/xsl-1.9/xhtml/xtchunk.xsl"/>

  <xsl:template match="variablelist">
    <xsl:choose>
      <xsl:when test="@role='programmers'">
        <xsl:call-template name="programmer-info-mode-start"/>
    <!--    <xsl:apply-templates mode="programmer-info-mode"/> -->
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>Applying imports:</xsl:text><br/>
        <xsl:apply-imports/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="programmer-info-mode-start"> 
    <xsl:text>Starting processing in mode: </xsl:text><br/>
    <xsl:apply-templates select="."  mode="programmer-info-mode"/> 
  </xsl:template>

  <xsl:template match="corpauthor" mode="programmer-info-mode">
    <strong><em>
        <xsl:text>Group: </xsl:text>
      </em></strong>
    <em><xsl:value-of select="."/></em>
  </xsl:template> 
</xsl:stylesheet>

WP> Call this template using <xsl:call-template> instead of the
WP> <xsl:apply-templates mode="programmer-info-mode"/> in the calling
WP> template.  Let the default for the mode stay the default
WP> (i.e. process children in the mode).

I now call the named template, and yes in processing the children with
the "programmer-info-mode", I get the correct formatting for the
CORPAUTHOR element, but the text in the other (`non-special') elements
is just concatenated together, with no formatting (i.e no templates
applied to them) at all.  Here's what it looks like (when I use the
stylesheet I included above:

 http://www.santafe.edu/~alex/tmp/output.html

WP> Then you have to decide what you want to have happen with elements
WP> content called in the mode, but not in your special element. If
WP> it's just suppress it, one way would be to override the default
WP> template for text() in the mode, as in

WP> <xsl:template match="text()" mode="programmer-info"/>

This is the nub of my problem, exactly: for all elements called in the
mode (but not in the special element) I want the xsl templates in the
_imported_ Norman Walsh's stylesheets to be called (i.e. the templates
I didn't write!)  So my _desired_ output is:

 http://www.santafe.edu/~alex/tmp/desired-output.html

(Note I just hacked the HTML to look right in the above example).

In other words, the indentation and linking of the URL comes from the
imported stylesheets.

The LISTITEM is a child of VARIABLELIST, which is an element in the
mode, but I don't want to have to write a mode-specific rule for this,
because then I'd need to write a mode-specific rule for LINK (to get
the <A href > etc.).

Hopefully this makes my problem a bit clearer.

Alex
-- 
Alex Lancaster * alex@santafe.edu * www.santafe.edu/~alex * 505 984-8800 x242
Santa Fe Institute (www.santafe.edu) & Swarm Development Group (www.swarm.org)


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]