Jonathan --
Have you taken a look at the EAD Cookbook? Several of the style sheets
provided with the Cookbook do this sort of comparison (dsc6.xsl for
example does something similar to what you are trying to do), so you
might want to take a look. The EAD Cookbook is available at
http://www.archivists.org/saagroups/ead/ead2002cookbook.html either
bundled with the stylesheets, or you can download the stylesheets
individually.
I'd do it this way. Set all four of your container types as variables
right off the bat, and use index numbers (the square brackets) where
possible to make it a little easier to understand:
<xsl:variable name="first-container-type"
select="container[1]/@type"/>
<xsl:variable name="second-container-type"
select="container[2]/@type"/>
<xsl:variable name="prec-first-container-type"
select="../preceding-sibling::*[1]/did/container[1]/@type"/>
<xsl:variable name="prec-second-container-type"
select="../preceding-sibling::*[1]/did/container[2]/@type"/>
Then you can compare them to your heart's content, providing for all
four contingencies like so:
<xsl:choose>
<xsl:when test="($prec-first-container-type=$first-container-type)
and ($prec-second-container-type=$second-container-type)">
Containers are both the same
</xsl:when>
<xsl:when test="not
($prec-first-container-type=$first-container-type) and
($prec-second-container-type=$second-container-type)">
First container names differ
</xsl:when>
<xsl:when test="($prec-first-container-type=$first-container-type)
and not ($prec-second-container-type=$second-container-type)">
Second container names differ
</xsl:when>
<xsl:when
test="not($prec-first-container-type=$first-container-type) and not
($prec-second-container-type=$second-container-type)">
Both container names differ
</xsl:when>
</xsl:choose>
Michele C.
-=--=--=--=--=--=--=--=--=--=--=--=--=--=-
Michele R. Combs
Manuscripts Processor
Special Collections Research Center
Syracuse University Library
222 Waverly Avenue
Syracuse, NY 13244
(315) 443-2697
-=--=--=--=--=--=--=--=--=--=--=--=--=--=-
>>> [log in to unmask] 11/3/2006 2:48 PM >>>
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]
|