[xsl] XSL design question

Subject: [xsl] XSL design question
From: pcarey@xxxxxxxxxxx
Date: Tue, 2 Sep 2003 13:04:41 -0400
Hello from an XSLT newbie.

My questions are prefaced with a little background info. Please ignore any
typos. Sorry for the verbosity!


The content model for a title is:

<!ELEMENT title (#PCDATA | b | i | tt | index)*>

Here's the template that matches b, i, and tt:

<xsl:template match = "b | i | tt">
      <span class="{local-name()}">

Here's the template that matches <index>:

<xsl:template match = "index">
      <a name="{generate-id()}"/>

Now, I can process <title> elements like this:

<xsl:template match = "title">

Let's say I want to create a Table of Contents.

This Table of Contents should not include the <index> elements.

The following will not work (obviously) because any <index> element will be

<xsl:template name="make_toc">
      <xsl:for-each select="//title">
            <p class="toc">

This won't work either:

<xsl:apply-templates select="*[not(self::index)]"/>

This, too will not work:

<xsl:apply-templates select="*[not(descendant::index)]"/>


1) Must I use modes?

This would involve a template like this:

<xsl:template match = "index" mode = "NO_INDEX"/>  <!-- EMPTY TEMPLATE -->

I would need to create "NO_INDEX" mode templates of any element that could
contain an <index> element, right?

2) Why doesn't <xsl:apply-templates select="*[not(descendant::index)]"/>
process all elements except <index> elements?

Sorry for the trivial questions. I remember cold sweats when we studied
recursion in school.


Pete Carey

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

Current Thread