Subject: RE: applying the same processing to ID and IDREF nodes From: Patrick Cauldwell <Patc@xxxxxxxxxxxx> Date: Tue, 9 Nov 1999 10:29:03 -0800 |
How about <xsl:template match="bucket"> <TR> <xsl:if test="@name"> <TD> <xsl:value-of select="@name"/> </TD> </xsl:if> <xsl:apply-templates select="id(@ref)"/> </TR> <xsl:apply-templates/> </xsl:template> That way the name will be output if there is one, or the same template will be applied to the nodes resulting from id(@ref). This works fine in IE5. Patrick Patrick Cauldwell patc@xxxxxxxxxxxx (503) 892-4738 STEP Technology, Inc. 6915 SW Macadam Suite 200, Portland, OR 97219 -----Original Message----- From: Alexandra Morgan [mailto:lexalex@xxxxxxxxxxxxx] Sent: Tuesday, November 09, 1999 9:11 AM 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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
applying the same processing to ID , Alexandra Morgan | Thread | RE: applying the same processing to, Vun Kannon, David |
RE: IE5-- any use?, Ben Robb | Date | RE: applying the same processing to, Vun Kannon, David |
Month |