Print

Print


Let me offer the following observation which may or may not be relevant to your problem.   
 
The preceding-sibling and following-sibling axes in XSLT refer to all preceding and all following siblings, respectively, not just the most immediate one.   
 
If you want to limit your select statement to just the sibling that immediately follows or preceeds, you will have to qualify that with the position function.  
 
In its full form, the syntax for limiting to the sibling that immediately preceeds would be, for example, preceding-sibling::did[position()=1].
 
The abbreviated form is preceding-sibling::did[1]
 
 
I'm not sure how a processor would interpret this statement- <xsl:variable name="container-type" select="container/@type"/> since each <did> has two containers.  Which container's content becomes the value of the variable?

I suspect you want to say <xsl:variable name="container-type" select="container[1]/@type"/> if it is the value of the first container (the box number) you want to test for.   Of course, this works only if you always have two container elements.
 
 
 
Michael

-----Original Message-----
From: Encoded Archival Description List [mailto:[log in to unmask]]On Behalf Of Lill, Jonathan
Sent: Friday, November 03, 2006 1:49 PM
To: [log in to unmask]
Subject: Conditional testing



This is a problem I'm trying to sort out and I know the problem exists either in my variable set up, my paths, or perhaps in my xsl:if argument.

I want my heading ([Container Type] Title Date) to display only when the container type is different than the previous c02 container. Since all my c02s have two containers, I want the headings to display if either type is different. I am not displaying the box heading or number and do not want the heading to reappear when the box (or first container) number changes; only when the type changes.

I have tried identifying the value of the "type" attribute in different ways and I have altered the paths numerous times. The xml parses and transforms but without the intended effect. As the code is (below) the heading is showing up for every unit. I am just beginning to learn xslt so it wouldn't surprise me if there are big problems here.

<xsl:variable name="container-type" select="container/@type"/> 
<xsl:variable name="following-sibling-container-type" select="container/following-sibling::container/@type"/> 
<xsl:if test="not (../preceding-sibling::did/container/@type=$container-type) or not (../preceding-sibling::did/container/following-sibling::container/@type=$following-sibling-container-type)">

<tr><td width="15%" valign="top"><b><xsl:value-of select="container/following-sibling::container/@type"/></b></td><td width="65%" valign="top"><b>Title</b></td><td width="20%" valign="top"><b>Date</b></td></tr>

</xsl:if> 
<tr><td width="15%" valign="top"><xsl:value-of select="container/following-sibling::container"/></td><td width="65%" valign="top"><b><xsl:value-of select="./unittitle"/></b></td><td width="20%" valign="top"><xsl:value-of select="./unitdate"/></td></tr>


Feel free to reply on or off list; I appreciate any help. 



Jonathan 



Jonathan Lill 
Project Archivist 
Museum Archives 
212.333.6514
[log in to unmask]