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()}"> <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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Using a variable in XSLT, David Carlisle | Thread | Re: [xsl] XSL design question, David Carlisle |
Re: [xsl] Re: AW: AW: global variab, fe . sola | Date | Re: [xsl] XSL design question, David Carlisle |
Month |