xsl-list
[Top] [All Lists]

Re: union vs. "or" vs. contains?

2004-10-19 15:09:15
Hi Bruce,

At 02:37 PM 10/19/2004, you wrote:
On Oct 19, 2004, at 7:03 AM, David Carlisle wrote:

The following does the same, but I think it's clearer, and it's probably
more efficient as the test only has to be done once, not on every
element that might possibly match.

<xsl:apply-templates select="*[$foo='x']"/>
or perhaps clearer
<xsl:if test="$foo='x'">
 <xsl:apply-templates/>
</xsl:if>

I'm not understanding how to implement this. How do I distinguish among the five different mods:modsCollection templates I'm applying if I'm not putting a conditional statement on the match statement of those templates?

Doing it this way, you're probably going to have to use modes to distinguish the pathways.

But this is precisely the advantage of implementing the different processing pathways by using layered modules (a core module plus a separate stylesheet "shell" for each processing pathway), rather than using testing-against-parameters.

It's not that it can't be done this way; it's just much more cumbersome and hard to maintain. (Giving XSLT the reputation of being "hard".) If the citation-class is implemented as simply a call to a special 'author-year' stylesheet (or whatever), all the templates particular to that kind of processing can be in that stylesheet, with no variable testing anywhere at all.

Cheers,
Wendell

This is what I started to do, but it's not making much sense to me.

<xsl:template match="db:bibliography">
  <xsl:choose>
  <xsl:when test="not($citation-class='note-nobib')">
    <div id="bibliography">
      <h2>References</h2>
      <xsl:choose>
        <xsl:when test="$citation-class='author-year'">
<xsl:apply-templates select="mods:modsCollection[$citation-class='author-year']" mode="bibliography"/>
        </xsl:when>
        <xsl:when test="$citation-class='citekey'">
<xsl:apply-templates select="mods:modsCollection[$citation-class='citekey']" mode="bibliography"/>
        </xsl:when>
        ....
      </xsl:choose>
    </div>
  </xsl:when>
  </xsl:choose>
</xsl:template>



======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================