You can use this stylesheet. Check if the namespace xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0"
is the correct one for your version.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0"
version="1.0">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="list-item[../@list-type='order']">
<xsl:copy>
<xsl:call-template name="add-attribute-to-list-item">
<xsl:with-param name="type" select="'Order'"/>
</xsl:call-template>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="list-item[../@list-type='bullet']">
<xsl:copy>
<xsl:call-template name="add-attribute-to-list-item">
<xsl:with-param name="type" select="'SubBullet'"/>
</xsl:call-template>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template name="add-attribute-to-list-item">
<xsl:param name="type"/>
<xsl:attribute name="aid:pstyle">
<xsl:choose>
<xsl:when test="position() = 1">
<xsl:value-of select="concat($type,'-First')"/>
</xsl:when>
<xsl:when test="position() = last()">
<xsl:value-of select="concat($type,'-Last')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($type,'-Middle')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<root><xsl:apply-templates select="root/p"/></root>
</xsl:template>
</xsl:stylesheet>
The result will be:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0">
<p>
<list list-type="order">
<list-item aid:pstyle="Order-First">
<p>This is quick.</p>
</list-item>
<list-item aid:pstyle="Order-Middle">
<p>Sivakumar Given and the fact that
<list list-type="bullet">
<list-item aid:pstyle="SubBullet-First">
<p>This is sublist</p>
</list-item>
<list-item aid:pstyle="SubBullet-Middle">
<p>This is sub middle list</p>
</list-item>
<list-item aid:pstyle="SubBullet-Last">
<p>This is sub last list</p>
</list-item>
</list>
</p>
</list-item>
<list-item aid:pstyle="Order-Middle">
<p>We are now left with four remaining parameters:</p>
</list-item>
<list-item aid:pstyle="Order-Middle">
<p>Given and the fact that</p>
</list-item>
<list-item aid:pstyle="Order-Middle">
<p>In Section we obtained an estimate for the mean of.</p>
</list-item>
<list-item aid:pstyle="Order-Last">
<p>From steps 3, 4, and 5 above, we have generated (a table of) values for.</p>
</list-item>
</list>
</p>
</root>