applying the same processing to ID and IDREF nodes

Subject: applying the same processing to ID and IDREF nodes
From: "Alexandra Morgan" <lexalex@xxxxxxxxxxxxx>
Date: Tue, 09 Nov 1999 09:11:27 -0800
Here's what I currently have in my xsl. This fragment works as expected:

  <xsl:template match="bucket">
    <TR>
      <xsl:choose>
        <xsl:when test="@ref">
          <xsl:for-each select="id(@ref)">
            <TD><xsl:value-of select="@name"/></TD>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <TD><xsl:value-of select="@name" /></TD>
        </xsl:otherwise>
      </xsl:choose>
    </TR>
    <xsl:apply-templates/>
  </xsl:template>

Basically, there are two kinds of "bucket" elements in my XML: ones which actually contain the data, and which have an ID attribute; and ones that are just basically references, and have an IDREF attribute ("ref") to point to the bucket node with the data. This lets the same data be referred to multiple places in the document without repetition (if the data were repeated, the files would become huge). So, when I encounter a bucket element, if it has no "ref" attribute, I want to process it; if it does have a "ref" attribute, I want to select the element with that ID and process it _in_the_exact_same_way. Thus the TD line, where I'm printing @name, is repeated identically in two places. I don't consider this a desirable state of affairs, especially since a lot more additional processing will need to be added, and customized in different XSLs, and having to always keep two chunks of code in sync would be a Bad Thing. How do I express the idea, that if there is no value for @ref, apply this processing to the current node, but if there is, apply this processing to a node I select? I tried to replace the xsl:choose with 
<xsl:for-each select="id(@ref)|id(@tag)"> but IE5 didn't like that.

Thanks so much in advance,
Alex



***********************************
chickclick.com
http://www.chickclick.com
girl sites that don't fake it.
http://www.chickmail.com
sign up for your free email.
***********************************


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


Current Thread