Q:

XSLT: Using Variable to store and reuse the Attribute Value

I'm trying to making changes in an XML document and I'm having trouble by storing and reusing the Values of Attributes.
The variable stores all of the values from same repeating Elements. But I want it to store and reuse just the value of current Element.
here is my XSLT:
    <!-- set them -->
    <xsl:variable name="Signatur" select=".//Field[@Type='2950']/@Value"/>
    <xsl:variable name="Datum" select=".//Field[@Type='9920']/@Value"/>

    <xsl:template match=".//Field[@Type='8450']/Field[@Type='8540']"/>

    <xsl:template match=".//Field[@Type='8450']">
        <h1:Field Type="8450" Value="digitale Reproduktion">
            <!-- use them -->
            <h1:Field Type="8540" Value="{$Signatur}"/>
            <h1:Field Type="8494" Value="{$Datum}"/>
            <xsl:apply-templates/>
        </h1:Field>
    </xsl:template>

A:

ok, a colleague helped me out. preceding-sibling makes the trick:
 <xsl:template match=".//Field[@Type='8450']">
    <xsl:variable name="Signatur" select="preceding-sibling::Field[@Type='ob28']/Field[@Type='2950']/@Value"/>
    <xsl:variable name="Datum" select="preceding-sibling::Field[@Type='9920']/@Value"/>
    <h1:Field Type="8450" Value="digitale Reproduktion">
        <!-- use them -->
        <h1:Field Type="8540" Value="{$Signatur}"/>
        <h1:Field Type="8494" Value="{$Datum}"/>
        <xsl:apply-templates/>
    </h1:Field>
</xsl:template>

