Print

Print


Jonathan,
I can see right away that there are some problems.

There cannot be a preceding-sibling or following-sibling DID element. Only one DID is allowed in a component (and/or the ARCHDESC). The XPATH needs to be changed there (pointing to whatever you need to).

This should occur at the <c0X> level.

1. Check to see if you need a new header
2. Check to see if you need to transform both <container> elements.

When there check for the need for a new heading build (a new HTML row in your table). This will of course occur before you build the row for the current <c0X>.

Send a param down to check for generating the other <container> element.

Code below.

Hope this helps,
Mike Ferrando
Library of Congress
Washington, DC
202-707-4454

<xsl:template match="c02">
  <xsl:variable name="cnt_01" select="child::did/container[1]/@type"/>
  <xsl:variable name="cnt_02" select="child::did/container[2]/@type"/>
  <xsl:variable 
    name="check_cnt_x" 
    select="
      preceding-sibling::c02[child::did/container/@type=$cnt_01]/@type | 

      preceding-sibling::c02[child::did/container/@type=$cnt_02]/@type
    "
  />
  <xsl:choose>
    <xsl:when test="string-length($check_cnt_x)& gt;0">
<!-- test = true = preceding @type = current @type -->
    </xsl:when>
    <xsl:otherwise>
<!-- test = false = prececing @type != current @type -->
    <tr>
      <td width="15%"
valign="top">
        <b>
          <xsl:value-of 
            select="
              child::did/container[2]/@type
            "
          />
        </b>
      </td>
      <td
width="65%" valign="top">
        <b>Title</b>
      </td>
      <td
width="20%"
valign="top">
        <b>Date</b>
      </td>
    </tr>
    </xsl:otherwse>
  </xsl:choose>
  <xsl:apply-templates select="*">
    <xsl:with-param name="check_cnt_x" select="$check_cnt_x"/>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="did">
  <xsl:param name="check_cnt_x"/>
    <xsl:choose>

      <xsl:when test="string-length($check_cnt_x)& gt;0">

<!-- test = true = preceding @type = current @type -->

      </xsl:when>

      <xsl:otherwise>
<!-- test = false = preceding @type = current @type -->
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


----- Original Message ----
From: "Lill, Jonathan" <[log in to unmask]>
To: [log in to unmask]
Sent: Friday, November 3, 2006 2:48:54 PM
Subject: Conditional testing

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]