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

XSL design question

Subject: XSL design question
From: pcarey@xxxxxxxxxxx
Date: Tue, 2 Sep 2003 13:04:41 -0400
pete carey xml
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()}">
            <xsl:apply-templates/>
      </span>
</xsl:template>

Here's the template that matches <index>:

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


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

<xsl:template match = "title">
      <h2>
            <xsl:apply-templates/>
      </h2>
</xsl:template>

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
re-processed.

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

This won't work either:

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

This, too will not work:

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

TWO QUESTIONS:

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.

Thanks,

Pete Carey












 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.