When you do your select for $nice_name you are utilizing the full XPath to
title:
select="/ead/archdesc/dsc/c01[@id='ser2']/c02/did/unittitle/title"/>
The problem with this is that the processor starts at the top of the
document tree and looks for the first instance of title that matches
that pattern - not the title in the c02 in which you are
working in your foreach loop.
Inside the foreach loop you could select on the title using the relative path
select="did/unittitle/title"
This selects the title in the current c02.
If I am reading your question right
<xsl:for-each select="/ead/archdesc/dsc/c01[@id='ser2']//c02">
<xsl:variable name="file_name" select="@id"/>
<xsl:variable name="nice_name"
select="did/unittitle/title"/>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="$file_name" />
</xsl:attribute>
<xsl:value-of select="$nice_name" />
</xsl:element>
</xsl:for-each>
should do the trick.
On Thu, 11 Jul 2002, Blake Carver wrote:
> Hi All,
> I am having a bit a problem on this little loop, and I'm hoping someone can
> correct me:
>
> <xsl:for-each select="/ead/archdesc/dsc/c01[@id='ser2']//c02">
> <xsl:variable name="file_name" select="@id"/>
> <xsl:variable name="nice_name"
> select="/ead/archdesc/dsc/c01[@id='ser2']/c02/did/unittitle/title"/>
> <xsl:element name="a">
> <xsl:attribute name="href">
> <xsl:value-of select="$file_name" />
> </xsl:attribute>
> <xsl:value-of select="$nice_name" />
> </xsl:element>
> </xsl:for-each>
>
>
> The problem being $nice_name is only displaying the First Title from the
> list of titles. $file_name is working fine.
> That is it'll pick up and display "AA Title", but it's not making it to or
> displaying "BA Title" [two examples of titles]
> The titles being here in my EAD:
>
> /ead/archdesc/dsc/c01[@id='ser2']/c02/did/unittitle/title
>
> I've tried this about a millions different ways, but can't get that second
> variable to appear.
> I'm not sure if that short snippet of code is enough to illustrate my
> point, if it's not please let me know.
>
>
> ------------------------------------------
> Blake Carver
> Web Librarian
> The Ohio State University Libraries
> [log in to unmask]
> 247-7424
>
|