I am trying to group sibling data in an XML file.
Given :
<?xml version="1.0" encoding="UTF-8"?>
<data>
<competition>
<timeline>10:00</timeline>
<fixture>team a v team b</fixture>
<fixture>team c v team d</fixture>
<timeline>12:00</timeline>
<fixture>team e v team f</fixture>
<timeline>16:00</timeline>
<fixture>team g v team h</fixture>
<fixture>team i v team j</fixture>
<fixture>team k v team l</fixture>
</competition>
</data>
I am trying to produce :
<?xml version="1.0" encoding="UTF-8"?>
<data>
<competition>
<timeline time="10:00">
<fixture>team a v team b</fixture>
<fixture>team c v team d</fixture>
</timeline>
<timeline time="12:00">
<fixture>team e v team f</fixture>
</timeline>
<timeline time="16:00">
<fixture>team g v team h</fixture>
<fixture>team i v team j</fixture>
<fixture>team k v team l</fixture>
</timeline>
</competition>
</data>
I am using the following XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="competition" >
<xsl:apply-templates select="timeline" />
</xsl:template>
<xsl:template match="timeline">
<timeline>
<xsl:attribute name="time" >
<xsl:value-of select="." />
</xsl:attribute>
<xsl:apply-templates select="following-sibling::*" mode="copy"/>
</timeline>
</xsl:template>
<xsl:template match="fixture" mode="copy">
<fixture>
<xsl:value-of select="." />
</fixture>
</xsl:template>
<xsl:template match="timeline" mode="copy">
<xsl:apply-templates select="following-sibling::*" mode="null" />
</xsl:template>
<xsl:template match="*" mode="null">
</xsl:template>
</xsl:stylesheet>
My problem is that it is not stopping processing fixture nodes when it gets to the next timeline