<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!--
// // See license.txt for license information. // // schema_objectlist.xsl // // 7-Oct-2004 phamilton Created //
-->

<xsl:stylesheet xmlns:lit="urn:xmlliterate.schema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="text"/>
    <xsl:param name="objname"/>
    <xsl:template name="newline">
        <xsl:text> </xsl:text>
    </xsl:template>
    <xsl:template name="object">
        <xsl:param name="object"/>
        <xsl:param name="objname"/>
        <xsl:choose>
            <xsl:when test="$object/@name = $objname">
                <xsl:for-each select="$object/lit:constructors/lit:constructor">
                    <xsl:text>constructor_</xsl:text>
                    <xsl:value-of select="position()"/>
                    <xsl:call-template name="newline"/>
                </xsl:for-each>
                <xsl:if test="count($object/lit:destruct/lit:destructor) = 1">
                    <xsl:text>destructor</xsl:text>
                    <xsl:call-template name="newline"/>
                </xsl:if>
                <xsl:for-each select="$object/lit:methods/*">
<!--
handle non-unique method names by assigning a positional number to the end of them
-->

                    <xsl:variable name="methodname">
                        <xsl:value-of select="@name"/>
                    </xsl:variable>
                    <xsl:variable name="position">
                        <xsl:value-of select="position()"/>
                    </xsl:variable>
                    <xsl:value-of select="@name"/>
                    <xsl:if test="count($object/lit:methods/*[@name=$methodname]) > 1">
                        <xsl:text>_</xsl:text>
                        <xsl:value-of select="$position"/>
                    </xsl:if>
                    <xsl:call-template name="newline"/>
                </xsl:for-each>
            </xsl:when>
            <xsl:otherwise>
                <xsl:if test="count($object/lit:derived/*) > 0">
                    <xsl:for-each select="$object/lit:derived/*">
                        <xsl:call-template name="object">
                            <xsl:with-param name="object" select="."/>
                            <xsl:with-param name="objname" select="$objname"/>
                        </xsl:call-template>
                    </xsl:for-each>
                </xsl:if>
                <xsl:if test="count($object/lit:fragment/*) > 0">
                    <xsl:for-each select="$object/lit:fragment/*">
                        <xsl:call-template name="object">
                            <xsl:with-param name="object" select="."/>
                            <xsl:with-param name="objname" select="$objname"/>
                        </xsl:call-template>
                    </xsl:for-each>
                </xsl:if>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="/">
        <xsl:call-template name="object">
            <xsl:with-param name="object" select="lit:object"/>
            <xsl:with-param name="objname" select="$objname"/>
        </xsl:call-template>
    </xsl:template>
</xsl:stylesheet>