RE: applying the same processing to ID and IDREF nodes

Subject: RE: applying the same processing to ID and IDREF nodes
From: "Vun Kannon, David" <dvunkannon@xxxxxxxx>
Date: Tue, 9 Nov 1999 13:37:49 -0500
	A) If this doesn't work in IE5, don't be surprised, given that IE5
is almost a year out of sync with the spec.

	B) It sounds like you want something like:
<template match="*">
	<choose>
		<when test="@ref">
			<apply-templates select="id(@ref)"/>
		</when>
		<otherwise>
			<apply-templates name="DO_ME"/>
		</otherwise>
	</choose>
</template>

<template name="DO_ME">
	<!-- actual processing goes here -->
</template>         

-----Original Message-----
From: Alexandra Morgan [mailto:lexalex@xxxxxxxxxxxxx]
Sent: Tuesday, November 09, 1999 12:11 PM
To: XSL-List@xxxxxxxxxxxxxxxx
Subject: applying the same processing to ID and IDREF nodes


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
*****************************************************************************
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorized. 

If you are not the intended recipient, any disclosure, copying, distribution
or any action taken or omitted to be taken in reliance on it, is prohibited
and may be unlawful. When addressed to our clients any opinions or advice
contained in this email are subject to the terms and conditions expressed in
the governing KPMG client engagement letter.         
*****************************************************************************


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


Current Thread