convert elements based on place in document

hi all,

i have a document with 7 recurring elements, the problem is they all have the same name/attributes.
is there a possibility to ‘rename’ them according to their place in the document ?
the first element of the recurring cyclus always has the same text. e.g. “start”
sourcefile :
start
random text1
random text2
random text3
random text4
start
random text5

endfile :
start
random text1
random text2
random text3
random text4
start
random text5

can this be done in xslt ?
thanx in advance

How about:-

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version=“1.0” xmlns:xsl=“XSLT Namespace”>
<xsl:output method=“xml” version=“1.0” encoding=“UTF-8” indent=“yes”/>


<xsl:template match=“node()|@">
xsl:copy
<xsl:apply-templates select="node()|@
”/>
</xsl:copy>
</xsl:template>


<xsl:template match=“par[normalize-space(.) = ‘start’]”>

<xsl:element name=“element1”>
<xsl:apply-templates select=“node()|@"/>
</xsl:element>

<xsl:apply-templates select=“following-sibling::par[1]” mode=“renumber”>
<xsl:with-param name=“counter” select=“2”/>
</xsl:apply-templates>
</xsl:template>


<xsl:template match=“par”>
</xsl:template>


<xsl:template match=“par” mode=“renumber”>
<xsl:param name=“counter”/>

<xsl:if test=“normalize-space(.) != ‘start’”>

<xsl:element name=“element{$counter}”>
<xsl:apply-templates select="node()|@
”/>
</xsl:element>

<xsl:apply-templates select=“following-sibling::par[1]” mode=“renumber”>
<xsl:with-param name=“counter” select=“1 + $counter”/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>



</xsl:stylesheet>

thanx for the reply.

I worked with your solution and i’m almost finished now. as u can see in my code below i’m still an xslt newbie but i’m learning (slowly).

I have one problem left I can’t seem to solve : after processing i’ll have a structure

















I would like to group the elements in a element





















this is my code so far …

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version=“1.0” xmlns:xsl=“XSLT Namespace”>
<xsl:output method=“xml” version=“1.0” encoding=“UTF-8” indent=“yes”/>


<xsl:template match=“node()|@">
xsl:copy
<xsl:apply-templates select=“node()”/>
</xsl:copy>
</xsl:template>

<xsl:template match=“part”>

<xsl:apply-templates select=“node()”/>

</xsl:template>

<xsl:template match=“inline”>
xsl:copy
<xsl:apply-templates select="node()|@
”/>
</xsl:copy>
</xsl:template>

<xsl:template match=“document”>
<xsl:apply-templates select=“node()”/>
</xsl:template>

<xsl:template match=“documentinfo”>
<xsl:apply-templates select=“node()”/>
</xsl:template>

<xsl:template match=“property”>
<xsl:apply-templates select=“node()”/>
</xsl:template>


<xsl:template match=“par[normalize-space(.) = ‘start’]”>


<xsl:element name=“element1”>
<xsl:apply-templates select=“node()”/>
</xsl:element>

<xsl:apply-templates select=“following-sibling::par[1]” mode=“renumber”>
<xsl:with-param name=“counter” select=“2”/>
</xsl:apply-templates>

</xsl:template>



<xsl:template match=“par”>
</xsl:template>


<xsl:template match=“par” mode=“renumber”>
<xsl:param name=“counter”/>

<xsl:if test=“normalize-space(.) != ‘start’”>

<xsl:element name=“element{$counter}”>
<xsl:apply-templates select=“node()”/>
</xsl:element>
<xsl:if test=“$counter < 9” >

<xsl:apply-templates select=“following-sibling::par[1]” mode=“renumber”>
<xsl:with-param name=“counter” select=“1 + $counter”/>
</xsl:apply-templates>
</xsl:if>
<xsl:if test=“$counter >= 9” >

<xsl:apply-templates select=“following-sibling::par[1]” mode=“renumber”>
<xsl:with-param name=“counter” select=“9”/>
</xsl:apply-templates>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>


if the easiest solution is another xslt processing, i’m ready to do so, as i’m running out of ideas. thanx in advance

[This message was edited by jefke on 24 May 2004 at 16:20.]