xsl-list
[Top] [All Lists]

Re: applying templates to all but ...

2004-09-24 05:49:55
Hi Jeni,

On Sep 24, 2004, at 8:08 AM, Jeni Tennison wrote:

The (cs:* except cs:creator) selects all child elements in the cs namespace, and then removes from that sequence the cs:creator child elements. It's slightly more understandable than using the self:: axis, I think.

Yes, indeed. My next question probably would have been "what is the self::axis doing here?" So thanks for that clarification.

Since, we're here, I wonder if you have any suggestions on expanding the logic of what I'm doing here?

I've modified the logic of my system (the stylesheets and the config schema) to have sort of two levels.

        1)   structural "class"
        2)  more concrete "type"

I then mandate the config file has definitions for the types article, book, and chapter, each of which reflect a "class." Those then serve as the generic fallback.

So, this is why:

              <xsl:when test="$issuance = 'continuing'">
<xsl:apply-templates select="$style-biblio/cs:reftype[(_at_)name='article']/cs:*">
                  <xsl:with-param name="source" select="."/>
                </xsl:apply-templates>
              </xsl:when>

Now, where I want to extend this is to allow additional definitions in each class. Example for the above might be "article-newspaper."

Those optional types can then either inherit from the fallback (which means basically that the only thing they are modifying is minor punctuation, which would be handled in other templates; there's an inherit-from attribute in the config schema), or not. If not, then my template here has to say select="$style-biblio/cs:reftype[(_at_)name='article-newspaper']/cs:*".

What I think this means is I need yet another layer of xsl:choose; e.g.:

              <xsl:when test="$issuance = 'continuing'">
                <xsl:choose>
<xsl:when test="$style-biblio/cs:reftype[(_at_)name='article-newspaper']"> <xsl:apply-templates select="$style-biblio/cs:reftype[(_at_)name='article-newspaper']/cs:*">
                    <xsl:with-param name="source" select="."/>
                  </xsl:apply-templates>
                  </xsl:when>
                  <xsl:otherwise>
<xsl:apply-templates select="$style-biblio/cs:reftype[(_at_)name='article']/cs:*">
                    <xsl:with-param name="source" select="."/>
                  </xsl:apply-templates>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:when>

This would work, but intuitively I feel like this is not a great approach (for one, it relies on hard-coding the types values; class is not directly coded in the config instances, though does structure the logic of validation).

Any better ideas?

Bruce