I have the following XML.
<word>
<lemma POS="глагол" Aspect="несвършен" Transitive= "непреходен">викам</lemma>
<morph>
<FiniteForm Tense="present" Person="1" Number="ед.ч.">викам</FiniteForm>
<FiniteForm Tense="present" Person="2" Number="ед.ч.">викаш</FiniteForm>
<FiniteForm Tense="present" Person="3" Number="ед.ч.">вика</FiniteForm>
<FiniteForm Tense="past_simple" Person="2" Number="ед.ч.">вика</FiniteForm>
<FiniteForm Tense="past_simple" Person="3" Number="ед.ч.">вика</FiniteForm>
<FiniteForm Tense="past_continues" Person="1" Number="ед.ч.">виках</FiniteForm>
<FiniteForm Tense="past_continues" Person="2" Number="ед.ч.">викаше</FiniteForm>
<FiniteForm Tense="past_continues" Person="3" Number="ед.ч.">викаше</FiniteForm>
</morph>
</word>
<word>
<lemma POS="глагол" Aspect="несвършен" Transitive= "непреходен">вървя</lemma>
<morph>
<FiniteForm Tense="present" Person="1" Number="ед.ч.">вървя</FiniteForm>
<FiniteForm Tense="present" Person="2" Number="ед.ч.">вървиш</FiniteForm>
<FiniteForm Tense="present" Person="3" Number="ед.ч.">вървят</FiniteForm>
<FiniteForm Tense="past_simple" Person="2" Number="ед.ч.">вървят</FiniteForm>
<FiniteForm Tense="past_simple" Person="3" Number="ед.ч.">вървя</FiniteForm>
<FiniteForm Tense="past_continues" Person="1" Number="ед.ч.">вървях</FiniteForm>
<FiniteForm Tense="past_continues" Person="2" Number="ед.ч.">вървеше</FiniteForm>
<FiniteForm Tense="past_continues" Person="3" Number="ед.ч.">вървеше</FiniteForm>
</morph>
</word>
Sorry for the cyrilic symbols. What I want is to group this by FiniteForm @Tense for each word. What I am currently doing is I am looping through each word. And performing Muenchian grouping. The problem is that my key actually matches every FiniteForm and I want it to match only those FiniteForm tags inside the word tag I am in.
This is how I create the key currently.
<xsl:key name="finiteFormsByTense" match="FiniteForm" use="@Tense" />
And this is what I do.
<xsl:for-each select="word">
<xsl:for-each select="morph/FiniteForm[generate-id() = generate-id(key('finiteFormsByTense', @Tense)[1])]">
<xsl:variable name="current-grouping-key" select="@Tense"/>
<xsl:variable name="current-group" select="key('finiteFormsByTense', $current-grouping-key)"/>
<xsl:variable select="count($current-group)+1" name="groupSize"/>
<tr>
<td rowspan="{$groupSize}">
<xsl:value-of select="$current-grouping-
</td>
</tr>
<xsl:for-each select="$current-group">
<tr>
<td><xsl:value-of select="@Person"/></td>
<td><xsl:value-of select="@Number"/></td>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
</xsl:for-each>
lemma
(or the internal id of theword
) with theTense
. Show us some code, so that we can fix it for you, if necessary. – michael.hor257k