我正在尝试对以下 xml 的每两个 tei:div 元素进行分组(这是包含我的简历的较大文件的一部分),并将它们包装在一个<div type="reference_block">
:
<div type="category">
<head n="references">References</head>
<div type="reference" xml:id="1">
<persName>
<forename type="first">firstname1</forename>
<surname>surname1</surname>
</persName>
<address>
<name type="building">building1</name>
<postBox>postbox1</postBox>
<placeName>
<settlement>settlement1</settlement>
<region>region1</region>
<country>country1</country>
</placeName>
<postCode>postcode1</postCode>
</address>
<num n="telephone">telephone1</num>
<email>email1</email>
</div>
<div type="reference" xml:id="2">
<persName>
<forename type="first">firstname2</forename>
<surname>surname2</surname>
</persName>
<address>
<name type="building">building2</name>
<postBox>postbox2</postBox>
<placeName>
<settlement>settlement2</settlement>
<region>region2</region>
<country>country2</country>
</placeName>
<postCode>postcode2</postCode>
</address>
<num n="telephone">telephone2</num>
<email>email2</email>
</div>
<div type="reference" xml:id="3">
<persName>
<forename type="first">firstname3</forename>
<surname>surname3</surname>
</persName>
<address>
<name type="building">building3</name>
<postBox>postbox3</postBox>
<placeName>
<settlement>settlement3</settlement>
<region>region3</region>
<country>country3</country>
</placeName>
<postCode>postcode3</postCode>
</address>
<num n="telephone">telephone3</num>
<email>email3</email>
</div>
<div type="reference" xml:id="4">
<persName>
<forename type="first">firstname4</forename>
<surname>surname4</surname>
</persName>
<address>
<name type="building">building4</name>
<postBox>postbox4</postBox>
<placeName>
<settlement>settlement4</settlement>
<region>region4</region>
<country>country4</country>
</placeName>
<postCode>postcode4</postCode>
</address>
<num n="telephone">telephone4</num>
<email>email4</email>
</div>
<div type="reference" xml:id="5">
<persName>
<forename type="first">firstname5</forename>
<surname>surname5</surname>
</persName>
<address>
<name type="building">building5</name>
<postBox>postbox5</postBox>
<placeName>
<settlement>settlement5</settlement>
<region>region5</region>
<country>country5</country>
</placeName>
<postCode>postcode5</postCode>
</address>
<num n="telephone">telephone5</num>
<email>email5</email>
</div>
<div type="reference" xml:id="6">
<persName>
<forename type="first">firstname6</forename>
<surname>surname6</surname>
</persName>
<address>
<name type="building">building6</name>
<postBox>postbox6</postBox>
<placeName>
<settlement>settlement6</settlement>
<region>region6</region>
<country>country6</country>
</placeName>
<postCode>postcode6</postCode>
</address>
<num n="telephone">telephone6</num>
<email>email6</email>
</div>
<div type="reference" xml:id="7">
<persName>
<forename type="first">firstname7</forename>
<surname>surname7</surname>
</persName>
<address>
<name type="building">building7</name>
<postBox>postbox7</postBox>
<placeName>
<settlement>settlement7</settlement>
<region>region7</region>
<country>country7</country>
</placeName>
<postCode>postcode7</postCode>
</address>
<num n="telephone">telephone7</num>
<email>email7</email>
</div>
</div>
我正在使用此模板尝试包装项目:
<xsl:template match="tei:div[@type='reference']">
<xsl:if test="@xml:id mod 2 = 1">
<div class="reference_block">
<xsl:apply-templates select=".|following-sibling::tei:div[@type='reference'][@xml:id < 2]"/>
</div>
</xsl:if>
</xsl:template>
但是,当我这样做时,我收到一条错误消息:“嵌套的应用模板调用过多。样式表可能正在循环”
问题似乎是“。” 在我的选择中,但我不确定为什么会收到错误消息。也许是因为它在呼唤自己而我没有意识到?有人能给我一些关于为什么会发生这种情况的见解,或者另一种方法来对不需要“。”的项目进行分组。选择?谢谢!