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

<!--
// // See license.txt for license information. // // schema.xsl // // NOTES // Schema used to output an object as an html file. // objname - The name of the object to use. // tree - the html tree file that we came from. // // 7-Oct-2004 phamilton Created //
-->

<xsl:stylesheet xmlns:db="http://docbook.org/ns/docbook" xmlns:str="http://exslt.org/strings" xmlns:lit="urn:xmlliterate.schema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" extension-element-prefixes="str" version="1.0">
    <xsl:include href="common/typename.xsl"/>
    <xsl:include href="common/describe_typenames.xsl"/>
    <xsl:include href="common/describe_method.xsl"/>
    <xsl:include href="common/describe_enums.xsl"/>
    <xsl:include href="common/get_node_jscript_path.xsl"/>
    <xsl:include href="common/get_jscript_node_name.xsl"/>
    <xsl:include href="common/parent_name.xsl"/>
    <xsl:include href="common/object_name.xsl"/>
    <xsl:include href="common/typeimpl.xsl"/>
    <xsl:output method="xml" indent="yes"/>
    <xsl:param name="objname"/>
    <xsl:param name="tree"/>
    <xsl:param name="schemapath"/>
    <xsl:param name="indexpath"/>
    <xsl:param name="date"/>
<!--
Describe an abstract method.
-->

    <xsl:template name="show_xref_abstract_method">
        <xsl:param name="methodname"/>
        <xsl:param name="object"/>
        <xsl:for-each select="$object/lit:methods/lit:method[@name=$methodname and lit:inheritance='override']">
            <db:member>
Overridden in                 <db:ulink>
                    <xsl:attribute name="url">
                        <xsl:value-of select="$object/@name"/>
                        <xsl:text>_</xsl:text>
                        <xsl:value-of select="$methodname"/>
                        <xsl:text>.html</xsl:text>
                    </xsl:attribute>
                    <xsl:value-of select="$object/@name"/>
:                     <xsl:value-of select="$methodname"/>
                </db:ulink>
            </db:member>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="walk_xref_abstract_method">
        <xsl:param name="methodname"/>
        <xsl:param name="object"/>
        <xsl:for-each select="$object/lit:derived/*">
            <xsl:call-template name="show_xref_abstract_method">
                <xsl:with-param name="methodname" select="$methodname"/>
                <xsl:with-param name="object" select="."/>
            </xsl:call-template>
            <xsl:call-template name="walk_xref_abstract_method">
                <xsl:with-param name="methodname" select="$methodname"/>
                <xsl:with-param name="object" select="."/>
            </xsl:call-template>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="search_xref_abstract_method_fragment">
        <xsl:param name="path"/>
        <xsl:param name="node"/>
        <xsl:param name="methodname"/>
        <xsl:choose>
            <xsl:when test="count($node/lit:fragment) > 0">
                <xsl:for-each select="$node/lit:fragment">
                    <xsl:choose>
                        <xsl:when test="$path = @location">
                            <xsl:for-each select="./*">
                                <xsl:call-template name="show_xref_abstract_method">
                                    <xsl:with-param name="methodname" select="$methodname"/>
                                    <xsl:with-param name="object" select="."/>
                                </xsl:call-template>
                                <xsl:call-template name="walk_xref_abstract_method">
                                    <xsl:with-param name="methodname" select="$methodname"/>
                                    <xsl:with-param name="object" select="."/>
                                </xsl:call-template>
                            </xsl:for-each>
                        </xsl:when>
                    </xsl:choose>
                </xsl:for-each>
            </xsl:when>
            <xsl:otherwise>
                <xsl:for-each select="$node/lit:derived/*">
                    <xsl:call-template name="search_xref_abstract_method_fragment">
                        <xsl:with-param name="path" select="$path"/>
                        <xsl:with-param name="node" select="."/>
                        <xsl:with-param name="methodname" select="$methodname"/>
                    </xsl:call-template>
                </xsl:for-each>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="xref_abstract_method">
        <xsl:param name="methodname"/>
        <xsl:param name="object"/>
        <db:para>
            <db:simplelist>
                <xsl:call-template name="walk_xref_abstract_method">
                    <xsl:with-param name="methodname" select="$methodname"/>
                    <xsl:with-param name="object" select="$object"/>
                </xsl:call-template>
<!--
Search through all the fragments as well.
-->

                <xsl:variable name="path">
                    <xsl:call-template name="get_node_jscript_path">
                        <xsl:with-param name="node" select="$object"/>
                        <xsl:with-param name="nodename" select="$object/@name"/>
                        <xsl:with-param name="path" select="''"/>
                        <xsl:with-param name="append" select="'.derived()'"/>
                    </xsl:call-template>
                </xsl:variable>
                <xsl:call-template name="search_xref_abstract_method_fragment">
                    <xsl:with-param name="path" select="$path"/>
                    <xsl:with-param name="node" select="/lit:object"/>
                    <xsl:with-param name="methodname" select="$methodname"/>
                </xsl:call-template>
            </db:simplelist>
        </db:para>
    </xsl:template>
    <xsl:template name="describe_abstract_method">
        <xsl:param name="access"/>
        <xsl:param name="method"/>
        <db:chapter>
            <xsl:attribute name="id">
                <xsl:value-of select="$method/@name"/>
_method            </xsl:attribute>
            <db:title>
                <xsl:value-of select="$method/@name"/>
            </db:title>
            <xsl:call-template name="describe_method">
                <xsl:with-param name="access" select="$access"/>
                <xsl:with-param name="method" select="$method"/>
            </xsl:call-template>
            <db:para> Here is a list of all overrides of this method inside sub-classes. Click on the object to take you to the definition. </db:para>
            <xsl:call-template name="xref_abstract_method">
                <xsl:with-param name="methodname" select="$method/@name"/>
                <xsl:with-param name="object" select="$method/../.."/>
            </xsl:call-template>
        </db:chapter>
    </xsl:template>
<!--
Output the signature of a method. We try to look like UML here.
-->

    <xsl:template name="method_signature">
        <xsl:param name="method"/>
        <xsl:value-of select="$method/@name"/>
        <xsl:text>(</xsl:text>
        <xsl:variable name="count">
            <xsl:value-of select="count($method/lit:arguments/*)"/>
        </xsl:variable>
        <xsl:for-each select="$method/lit:arguments/*">
            <xsl:value-of select="@name"/>
            <xsl:text>: </xsl:text>
            <xsl:call-template name="typename">
                <xsl:with-param name="object" select="."/>
                <xsl:with-param name="links" select="'false'"/>
            </xsl:call-template>
            <xsl:if test="position() != $count">
                <xsl:text>, </xsl:text>
            </xsl:if>
        </xsl:for-each>
        <xsl:text>)</xsl:text>
        <xsl:if test="$method/lit:returns/*">
            <xsl:text>: </xsl:text>
            <xsl:call-template name="typename">
                <xsl:with-param name="object" select="$method/lit:returns/*"/>
                <xsl:with-param name="links" select="'false'"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
<!--
Output the signature of an abstract method. We try to look like UML here.
-->

<!--
Search for objects on fragments.
-->

    <xsl:template name="search_fragment_method_signature">
        <xsl:param name="path"/>
        <xsl:param name="node"/>
        <xsl:param name="methodname"/>
        <xsl:variable name="nodepath">
            <xsl:call-template name="get_node_jscript_path">
                <xsl:with-param name="node" select="$node"/>
                <xsl:with-param name="nodename" select="$node/@name"/>
                <xsl:with-param name="path" select="''"/>
                <xsl:with-param name="append" select="'.derived()'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$nodepath = $path">
                <xsl:call-template name="parent_method_signature">
                    <xsl:with-param name="object" select="$node"/>
                    <xsl:with-param name="methodname" select="$methodname"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:for-each select="$node/lit:derived/*">
                    <xsl:call-template name="search_fragment_method_signature">
                        <xsl:with-param name="path" select="$path"/>
                        <xsl:with-param name="node" select="."/>
                        <xsl:with-param name="methodname" select="$methodname"/>
                    </xsl:call-template>
                </xsl:for-each>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="parent_method_signature">
        <xsl:param name="object"/>
        <xsl:param name="methodname"/>
        <xsl:choose>
            <xsl:when test="name($object) = 'fragment'">
                <xsl:call-template name="search_fragment_method_signature">
                    <xsl:with-param name="path" select="$object/@location"/>
                    <xsl:with-param name="node" select="/lit:object"/>
                    <xsl:with-param name="methodname" select="$methodname"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$object/@name = '@root'"> Not Found </xsl:when>
            <xsl:when test="count($object/lit:methods/lit:abstractmethod[@name=$methodname])">
                <xsl:call-template name="method_signature">
                    <xsl:with-param name="method" select="$object/lit:methods/lit:abstractmethod[@name=$methodname]"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="count($object/lit:methods/lit:method[lit:inheritance='abstract' and @name=$methodname])">
                <xsl:call-template name="method_signature">
                    <xsl:with-param name="method" select="$object/lit:methods/lit:method[lit:inheritance='abstract' and @name=$methodname]"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="parent_method_signature">
                    <xsl:with-param name="object" select="$object/.."/>
                    <xsl:with-param name="methodname" select="$methodname"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="abstract_method_signature">
        <xsl:param name="method"/>
<!--
find any parent which implements this abstract method.
-->

        <xsl:call-template name="parent_method_signature">
            <xsl:with-param name="object" select="$method/../../.."/>
            <xsl:with-param name="methodname" select="$method/@name"/>
        </xsl:call-template>
    </xsl:template>
    <xsl:template name="describe_test">
        <xsl:param name="test"/>
        <db:chapter>
            <db:title>
                <xsl:value-of select="$test/@name"/>
            </db:title>
            <db:para>
                <xsl:value-of select="$test/description"/>
                <xsl:text> The method "</xsl:text>
                <xsl:value-of select="$test/lit:method"/>
                <xsl:text>" will be called to run the test.</xsl:text>
            </db:para>
            <db:para>
                <xsl:text>The test program will be run so that this test object will be passed the arguments </xsl:text>
                <xsl:value-of select="$test/args"/>
                <xsl:text>.</xsl:text>
            </db:para>
            <xsl:choose>
                <xsl:when test="$test/match = 'true'">
                    <db:para>The test unit framework will match any results with file contents that already exist.</db:para>
                </xsl:when>
                <xsl:otherwise>
                    <db:para>The test unit framework will generate results each run.</db:para>
                </xsl:otherwise>
            </xsl:choose>
        </db:chapter>
    </xsl:template>
<!--
Place any fragment tests correctly onto the node that they belong. The path passed in is the "location" of the object. If we find any we add in this object to the tree.
-->

    <xsl:template name="search_test_fragment">
        <xsl:param name="path"/>
        <xsl:param name="node"/>
        <xsl:choose>
            <xsl:when test="count($node/lit:fragment) > 0">
                <xsl:for-each select="$node/lit:fragment">
                    <xsl:choose>
                        <xsl:when test="$path = @location">
                            <xsl:for-each select="test">
                                <xsl:call-template name="describe_test">
                                    <xsl:with-param name="test" select="."/>
                                </xsl:call-template>
                            </xsl:for-each>
                        </xsl:when>
                    </xsl:choose>
                </xsl:for-each>
            </xsl:when>
            <xsl:otherwise>
                <xsl:for-each select="$node/lit:derived/*">
                    <xsl:call-template name="search_test_fragment">
                        <xsl:with-param name="path" select="$path"/>
                        <xsl:with-param name="node" select="."/>
                    </xsl:call-template>
                </xsl:for-each>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="method_ulink">
        <xsl:param name="object"/>
        <xsl:param name="methodname"/>
        <xsl:param name="method"/>
        <xsl:param name="position"/>
        <db:ulink>
            <xsl:attribute name="url">
                <xsl:value-of select="$object/@name"/>
                <xsl:text>_</xsl:text>
                <xsl:value-of select="$methodname"/>
                <xsl:if test="count($object/lit:methods/*[@name=$methodname]) > 1">
                    <xsl:text>_</xsl:text>
                    <xsl:value-of select="$position"/>
                </xsl:if>
                <xsl:text>.html</xsl:text>
            </xsl:attribute>
            <xsl:call-template name="method_signature">
                <xsl:with-param name="method" select="$method"/>
            </xsl:call-template>
        </db:ulink>
    </xsl:template>
<!--
Place any fragment objects correctly onto the node that they belong. The path passed in is the "location" of the object. If we find any we add in this object to the tree.
-->

    <xsl:template name="search_child_fragment">
        <xsl:param name="path"/>
        <xsl:param name="node"/>
        <xsl:choose>
            <xsl:when test="count($node/lit:fragment) > 0">
                <xsl:for-each select="$node/lit:fragment">
                    <xsl:choose>
                        <xsl:when test="$path = @location">
                            <xsl:for-each select="./*">
                                <db:member>
                                    <db:ulink>
                                        <xsl:attribute name="url">
                                            <xsl:value-of select="@name"/>
                                            <xsl:text>.html</xsl:text>
                                        </xsl:attribute>
                                        <xsl:call-template name="object_name">
                                            <xsl:with-param name="name" select="@name"/>
                                        </xsl:call-template>
                                    </db:ulink>
                                </db:member>
                            </xsl:for-each>
                        </xsl:when>
                    </xsl:choose>
                </xsl:for-each>
            </xsl:when>
            <xsl:otherwise>
                <xsl:for-each select="$node/lit:derived/*">
                    <xsl:call-template name="search_child_fragment">
                        <xsl:with-param name="path" select="$path"/>
                        <xsl:with-param name="node" select="."/>
                    </xsl:call-template>
                </xsl:for-each>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="walk_parent_find_fragment">
        <xsl:param name="path"/>
        <xsl:param name="node"/>
        <xsl:variable name="nodepath">
            <xsl:call-template name="get_node_jscript_path">
                <xsl:with-param name="node" select="$node"/>
                <xsl:with-param name="nodename" select="$node/@name"/>
                <xsl:with-param name="path" select="''"/>
                <xsl:with-param name="append" select="'.derived()'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$nodepath = $path">
<!--
this is the node.
-->

                <xsl:call-template name="walk_parent">
                    <xsl:with-param name="object" select="$node"/>
                </xsl:call-template>
                <db:ulink>
                    <xsl:attribute name="url">
                        <xsl:value-of select="$node/@name"/>
                        <xsl:text>.html</xsl:text>
                    </xsl:attribute>
                    <xsl:call-template name="object_name">
                        <xsl:with-param name="name" select="$node/@name"/>
                    </xsl:call-template>
                </db:ulink>
                <xsl:text> -> </xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:for-each select="$node/lit:derived/*">
                    <xsl:call-template name="walk_parent_find_fragment">
                        <xsl:with-param name="path" select="$path"/>
                        <xsl:with-param name="node" select="."/>
                    </xsl:call-template>
                </xsl:for-each>
                <xsl:for-each select="$node/lit:fragment">
                    <xsl:variable name="location_start">
                        <xsl:value-of select="substring(@location, 1, string-length(@location)-1)"/>
                    </xsl:variable>
                    <xsl:for-each select="./*">
                        <xsl:variable name="locpath">
                            <xsl:value-of select="$location_start"/>
                            <xsl:text>'</xsl:text>
                            <xsl:value-of select="@name"/>
                            <xsl:text>').derived()</xsl:text>
                        </xsl:variable>
                        <xsl:choose>
                            <xsl:when test="$locpath = $path">
<!--
this is the node.
-->

                                <xsl:call-template name="walk_parent">
                                    <xsl:with-param name="object" select="."/>
                                </xsl:call-template>
                                <db:ulink>
                                    <xsl:attribute name="url">
                                        <xsl:value-of select="@name"/>
                                        <xsl:text>.html</xsl:text>
                                    </xsl:attribute>
                                    <xsl:call-template name="object_name">
                                        <xsl:with-param name="name" select="@name"/>
                                    </xsl:call-template>
                                </db:ulink>
                                <xsl:text> -> </xsl:text>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:variable name="locpath_start">
                                    <xsl:value-of select="substring($locpath, 1, string-length($locpath)-1)"/>
                                </xsl:variable>
                                <xsl:if test="starts-with($path, $locpath_start)">
<!--
it is possible that this location contains our path somewhere in it, so we want to search sub-objects of it for our object.
-->

                                    <xsl:for-each select="lit:derived/*">
                                        <xsl:call-template name="walk_parent_find_fragment">
                                            <xsl:with-param name="path" select="$path"/>
                                            <xsl:with-param name="node" select="."/>
                                        </xsl:call-template>
                                    </xsl:for-each>
                                </xsl:if>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:for-each>
                </xsl:for-each>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="walk_parent">
        <xsl:param name="$object"/>
        <xsl:choose>
            <xsl:when test="name($object/..) = 'fragment'">
                <xsl:call-template name="walk_parent_find_fragment">
                    <xsl:with-param name="path" select="$object/../@location"/>
                    <xsl:with-param name="node" select="/lit:object"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$object/../../@name = '@root'">
                <db:ulink>
                    <xsl:attribute name="url">
                        <xsl:value-of select="$object/../../@name"/>
                        <xsl:text>.html</xsl:text>
                    </xsl:attribute>
                    <xsl:call-template name="object_name">
                        <xsl:with-param name="name" select="$object/../../@name"/>
                    </xsl:call-template>
                </db:ulink>
                <xsl:text> -> </xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="walk_parent">
                    <xsl:with-param name="object" select="$object/../.."/>
                </xsl:call-template>
                <db:ulink>
                    <xsl:attribute name="url">
                        <xsl:value-of select="$object/../../@name"/>
                        <xsl:text>.html</xsl:text>
                    </xsl:attribute>
                    <xsl:call-template name="object_name">
                        <xsl:with-param name="name" select="$object/../../@name"/>
                    </xsl:call-template>
                </db:ulink>
                <xsl:text> -> </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="object_tree">
        <xsl:param name="object"/>
        <db:para>
            <db:simplelist>
                <db:member>
                    <xsl:if test="$object/@name != '@root'">
                        <xsl:call-template name="walk_parent">
                            <xsl:with-param name="object" select="$object"/>
                        </xsl:call-template>
                    </xsl:if>
                    <bold>
                        <xsl:call-template name="object_name">
                            <xsl:with-param name="name" select="$object/@name"/>
                        </xsl:call-template>
                    </bold>
                    <db:simplelist>
                        <xsl:for-each select="$object/lit:derived/lit:object">
                            <db:member>
                                <db:ulink>
                                    <xsl:attribute name="url">
                                        <xsl:value-of select="@name"/>
                                        <xsl:text>.html</xsl:text>
                                    </xsl:attribute>
                                    <xsl:call-template name="object_name">
                                        <xsl:with-param name="name" select="@name"/>
                                    </xsl:call-template>
                                </db:ulink>
                            </db:member>
                        </xsl:for-each>
<!--
calculate this objects path.
-->

                        <xsl:variable name="path">
                            <xsl:call-template name="get_node_jscript_path">
                                <xsl:with-param name="node" select="$object"/>
                                <xsl:with-param name="nodename" select="$object/@name"/>
                                <xsl:with-param name="path" select="''"/>
                                <xsl:with-param name="append" select="'.derived()'"/>
                            </xsl:call-template>
                        </xsl:variable>
<!--
place any fragments that belong under this location onto the path
-->

                        <xsl:call-template name="search_child_fragment">
                            <xsl:with-param name="path" select="$path"/>
                            <xsl:with-param name="node" select="/lit:object"/>
                        </xsl:call-template>
                    </db:simplelist>
                </db:member>
            </db:simplelist>
        </db:para>
    </xsl:template>
    <xsl:template name="show_object_xref">
        <xsl:param name="object"/>
        <xsl:param name="objname"/>
        <xsl:for-each select="$object/lit:methods/*">
            <xsl:variable name="methodname" select="@name"/>
            <xsl:variable name="inheritance" select="lit:inheritance"/>
            <xsl:for-each select="lit:arguments/*">
                <xsl:if test="lit:reftype = $objname">
                    <db:member>
Argument "                        <xsl:value-of select="@name"/>
" of                         <db:ulink>
                            <xsl:choose>
                                <xsl:when test="$inheritance = 'abstract'">
                                    <xsl:attribute name="url">
                                        <xsl:value-of select="$object/@name"/>
                                        <xsl:text>.html#</xsl:text>
                                        <xsl:value-of select="$methodname"/>
                                        <xsl:text>_method</xsl:text>
                                    </xsl:attribute>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:attribute name="url">
                                        <xsl:value-of select="$object/@name"/>
                                        <xsl:text>_</xsl:text>
                                        <xsl:value-of select="$methodname"/>
                                        <xsl:text>.html</xsl:text>
                                    </xsl:attribute>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:value-of select="$object/@name"/>
:                             <xsl:value-of select="$methodname"/>
                        </db:ulink>
                    </db:member>
                </xsl:if>
            </xsl:for-each>
            <xsl:for-each select="lit:returns/*">
                <xsl:if test="lit:reftype = $objname">
                    <db:member>
Return value of                         <db:ulink>
                            <xsl:attribute name="url">
                                <xsl:value-of select="$object/@name"/>
                                <xsl:text>_</xsl:text>
                                <xsl:value-of select="$methodname"/>
                                <xsl:text>.html</xsl:text>
                            </xsl:attribute>
                            <xsl:value-of select="$object/@name"/>
:                             <xsl:value-of select="$methodname"/>
                        </db:ulink>
                    </db:member>
                </xsl:if>
            </xsl:for-each>
        </xsl:for-each>
        <xsl:for-each select="$object/lit:members/*">
            <xsl:if test="lit:reftype = $objname">
                <db:member>
Member "                    <xsl:value-of select="@name"/>
" in                     <db:ulink>
                        <xsl:attribute name="url">
                            <xsl:value-of select="$object/@name"/>
                            <xsl:text>.html</xsl:text>
                        </xsl:attribute>
                        <xsl:value-of select="$object/@name"/>
                    </db:ulink>
                </db:member>
            </xsl:if>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="walk_object_xref">
        <xsl:param name="object"/>
        <xsl:param name="objname"/>
        <xsl:if test="count($object/lit:derived/*) > 0">
            <xsl:for-each select="$object/lit:derived/*">
                <xsl:call-template name="show_object_xref">
                    <xsl:with-param name="object" select="."/>
                    <xsl:with-param name="objname" select="$objname"/>
                </xsl:call-template>
                <xsl:call-template name="walk_object_xref">
                    <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="show_object_xref">
                    <xsl:with-param name="object" select="."/>
                    <xsl:with-param name="objname" select="$objname"/>
                </xsl:call-template>
                <xsl:call-template name="walk_object_xref">
                    <xsl:with-param name="object" select="."/>
                    <xsl:with-param name="objname" select="$objname"/>
                </xsl:call-template>
            </xsl:for-each>
        </xsl:if>
    </xsl:template>
    <xsl:template name="object_xref">
        <xsl:param name="object"/>
        <db:para>
            <db:simplelist>
                <xsl:call-template name="walk_object_xref">
                    <xsl:with-param name="object" select="/lit:object"/>
                    <xsl:with-param name="objname" select="$object/@name"/>
                </xsl:call-template>
            </db:simplelist>
        </db:para>
    </xsl:template>
<!--
Output a description of an entire object.
-->

    <xsl:template name="object_description">
        <xsl:param name="object"/>
        <db:bookinfo>
            <db:title>
                <xsl:call-template name="object_name">
                    <xsl:with-param name="name" select="$object/@name"/>
                </xsl:call-template>
            </db:title>
        </db:bookinfo>
        <db:chapter>
            <db:para>
                <xsl:copy-of select="$object/lit:description"/>
                <xsl:if test="$object/lit:classname">
                    <xsl:text> It's class-name (used for any type of code generation) is "</xsl:text>
                    <xsl:value-of select="$object/lit:classname"/>
                    <xsl:text>".</xsl:text>
                </xsl:if>
            </db:para>
            <xsl:if test="$object/lit:namespace">
                <db:para>
                    <xsl:text>The namespace within the parent namespace is "</xsl:text>
                    <xsl:value-of select="$object/lit:namespace"/>
                    <xsl:text>".</xsl:text>
                </db:para>
            </xsl:if>
<!--
output the object tree.
-->

            <db:para> The object fits into the tree of objects in the following way. Click on other objects in to navigate to that object. Objects to the left of this object are superclasses, and objects listed below it derive from this one. </db:para>
            <xsl:call-template name="object_tree">
                <xsl:with-param name="object" select="$object"/>
            </xsl:call-template>
<!--
output the XRef list.
-->

            <db:para> Here is a list of all uses of this object inside others. Click on the object to take you to the definition. </db:para>
            <xsl:call-template name="object_xref">
                <xsl:with-param name="object" select="$object"/>
            </xsl:call-template>
            <db:para>
                <db:ulink url="index.html">Click here</db:ulink>
to see a tree representation of all objects.             </db:para>
            <db:para>
                <db:ulink>
                    <xsl:attribute name="url">
                        <xsl:value-of select="$indexpath"/>
                        <xsl:text>index.html</xsl:text>
                    </xsl:attribute>
                    <xsl:text>Click here</xsl:text>
                </db:ulink>
to return to the main index page.             </db:para>
        </db:chapter>
        <xsl:if test="count($object/lit:enumerations/*) > 0">
            <db:chapter id="enumerations">
                <db:title>Enumerations</db:title>
                <db:para>Here are the enumerations that will be used:</db:para>
                <db:sect1>
                    <xsl:call-template name="describe_enums">
                        <xsl:with-param name="enums" select="$object/lit:enumerations"/>
                    </xsl:call-template>
                </db:sect1>
            </db:chapter>
        </xsl:if>
        <xsl:if test="count($object/lit:members/*) > 0">
            <db:chapter id="members">
                <db:title>Members</db:title>
                <db:para>This object contains members which hold data for the object. Following is a list of those members. The declaration of the member closely follows the UML conventions.</db:para>
                <db:sect1>
                    <xsl:call-template name="describe_typenames">
                        <xsl:with-param name="typenames" select="$object/lit:members"/>
                    </xsl:call-template>
                </db:sect1>
            </db:chapter>
        </xsl:if>
        <xsl:if test="count($object/lit:methods/*) > 0">
            <db:chapter>
                <db:title>Methods</db:title>
                <db:para>This object contains methods which can be called from other objects. Following is a list of those methods. The syntax of the method, it's arguments and return value follow closely the UML conventions.</db:para>
                <db:para>
                    <db:simplelist>
                        <xsl:if test="count($object/lit:constructors) > 0">
                            <db:member>
Constructors                                 <db:simplelist>
                                    <xsl:for-each select="$object/lit:constructors/lit:constructor">
                                        <db:member>
                                            <db:ulink>
                                                <xsl:attribute name="url">
                                                    <xsl:value-of select="$object/@name"/>
                                                    <xsl:text>_</xsl:text>
                                                    <xsl:text>constructor_</xsl:text>
                                                    <xsl:value-of select="position()"/>
                                                    <xsl:text>.html</xsl:text>
                                                </xsl:attribute>
                                                <xsl:call-template name="method_signature">
                                                    <xsl:with-param name="method" select="."/>
                                                </xsl:call-template>
                                            </db:ulink>
                                        </db:member>
                                    </xsl:for-each>
                                </db:simplelist>
                            </db:member>
                        </xsl:if>
                        <xsl:if test="count($object/lit:destruct) > 0">
                            <db:member>
                                <db:ulink>
                                    <xsl:attribute name="url">
                                        <xsl:value-of select="$object/@name"/>
                                        <xsl:text>_</xsl:text>
                                        <xsl:text>destructor</xsl:text>
                                        <xsl:text>.html</xsl:text>
                                    </xsl:attribute>
Destructor                                 </db:ulink>
                            </db:member>
                        </xsl:if>
                        <xsl:if test="count($object/lit:methods/lit:method[lit:inheritance='abstract']) > 0">
                            <db:member>
Abstract methods                                 <db:simplelist>
                                    <xsl:for-each select="$object/lit:methods/lit:method[lit:inheritance='abstract']">
                                        <db:member>
                                            <db:link>
                                                <xsl:attribute name="linkend">
                                                    <xsl:value-of select="@name"/>
_method                                                </xsl:attribute>
                                                <xsl:call-template name="method_signature">
                                                    <xsl:with-param name="method" select="."/>
                                                </xsl:call-template>
                                            </db:link>
                                        </db:member>
                                    </xsl:for-each>
                                </db:simplelist>
                            </db:member>
                        </xsl:if>
<!--
in all of the following, the position() of the metjod is important for those methods which have the same name. That's why we loop over all methods and test for the right type rather than using an XSL XPath select.
-->

                        <xsl:if test="count($object/lit:methods/lit:method[(lit:inheritance='concrete' and lit:access != 'private') or lit:scope='global']) > 0">
                            <db:member>
Concrete methods                                 <db:simplelist>
                                    <xsl:for-each select="$object/lit:methods/*">
                                        <xsl:if test="(lit:inheritance='concrete' and lit:access != 'private') or lit:scope='global'">
                                            <db:member>
                                                <xsl:call-template name="method_ulink">
                                                    <xsl:with-param name="object" select="$object"/>
                                                    <xsl:with-param name="methodname" select="@name"/>
                                                    <xsl:with-param name="method" select="."/>
                                                    <xsl:with-param name="position" select="position()"/>
                                                </xsl:call-template>
                                            </db:member>
                                        </xsl:if>
                                    </xsl:for-each>
                                </db:simplelist>
                            </db:member>
                        </xsl:if>
                        <xsl:if test="count($object/lit:methods/lit:method[(lit:inheritance='concrete' and lit:access = 'private') or lit:scope='global']) > 0">
                            <db:member>
Concrete methods (private)                                 <db:simplelist>
                                    <xsl:for-each select="$object/lit:methods/*">
                                        <xsl:if test="(lit:inheritance='concrete' and lit:access = 'private') or lit:scope='global'">
                                            <db:member>
                                                <xsl:call-template name="method_ulink">
                                                    <xsl:with-param name="object" select="$object"/>
                                                    <xsl:with-param name="methodname" select="@name"/>
                                                    <xsl:with-param name="method" select="."/>
                                                    <xsl:with-param name="position" select="position()"/>
                                                </xsl:call-template>
                                            </db:member>
                                        </xsl:if>
                                    </xsl:for-each>
                                </db:simplelist>
                            </db:member>
                        </xsl:if>
                        <xsl:if test="count($object/lit:methods/lit:method[lit:inheritance='override']) > 0">
                            <db:member>
Overridden methods (from parent objects)                                 <db:simplelist>
                                    <xsl:for-each select="$object/lit:methods/*">
                                        <xsl:if test="lit:inheritance='override'">
                                            <db:member>
                                                <xsl:call-template name="method_ulink">
                                                    <xsl:with-param name="object" select="$object"/>
                                                    <xsl:with-param name="methodname" select="@name"/>
                                                    <xsl:with-param name="method" select="."/>
                                                    <xsl:with-param name="position" select="position()"/>
                                                </xsl:call-template>
                                            </db:member>
                                        </xsl:if>
                                    </xsl:for-each>
                                </db:simplelist>
                            </db:member>
                        </xsl:if>
                        <xsl:if test="count($object/lit:methods/lit:method[lit:inheritance='virtual']) > 0">
                            <db:member>
Virtual methods                                 <db:simplelist>
                                    <xsl:for-each select="$object/lit:methods/*">
                                        <xsl:if test="lit:inheritance='virtual'">
                                            <db:member>
                                                <xsl:call-template name="method_ulink">
                                                    <xsl:with-param name="object" select="$object"/>
                                                    <xsl:with-param name="methodname" select="@name"/>
                                                    <xsl:with-param name="method" select="."/>
                                                    <xsl:with-param name="position" select="position()"/>
                                                </xsl:call-template>
                                            </db:member>
                                        </xsl:if>
                                    </xsl:for-each>
                                </db:simplelist>
                            </db:member>
                        </xsl:if>
                    </db:simplelist>
                </db:para>
            </db:chapter>
        </xsl:if>
        <xsl:for-each select="$object/lit:methods/lit:method[lit:inheritance='abstract']">
            <xsl:call-template name="describe_abstract_method">
                <xsl:with-param name="method" select="."/>
                <xsl:with-param name="access" select="lit:access"/>
            </xsl:call-template>
        </xsl:for-each>
        <xsl:if test="count($object/lit:tests/*) > 0">
            <xsl:call-template name="describe_test">
                <xsl:with-param name="test" select="."/>
            </xsl:call-template>
        </xsl:if>
<!--
tests are often placed as fragments somewhere else in the file. So search for any fragments with locations that belong under "tests"
-->

        <xsl:variable name="path">
            <xsl:call-template name="get_node_jscript_path">
                <xsl:with-param name="node" select="$object"/>
                <xsl:with-param name="nodename" select="$object/@name"/>
                <xsl:with-param name="path" select="''"/>
                <xsl:with-param name="append" select="'.tests()'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="search_test_fragment">
            <xsl:with-param name="path" select="$path"/>
            <xsl:with-param name="node" select="/lit:object"/>
        </xsl:call-template>
        <xsl:if test="count($object/lit:templates/*) > 0 or count($object/lit:typeimpls/*) > 0">
            <db:chapter id="types">
                <db:title>Types</db:title>
                <db:para>This object defines a number of types, all listed here. Objects that appear as sub-classes if this one may use these types in return types, arguments to methods or when defining methods.</db:para>
                <db:sect1>
                    <db:title>Builtin type definitions</db:title>
                    <db:para>The following builtin types are defined in this object. Click on a type to take you to it's description.</db:para>
                    <db:para>
<!--
We find any types that don't have a definition but have an implementation. These are most likely builtins.
-->

                        <db:simplelist>
                            <xsl:for-each select="$object/lit:typeimpls/*">
                                <xsl:sort select="@name" order="ascending"/>
                                <xsl:variable name="name" select="@name"/>
                                <xsl:if test="count($object/lit:templates/*[@name=$name]) = 0">
                                    <db:member>
                                        <db:link>
                                            <xsl:attribute name="linkend">
                                                <xsl:value-of select="@name"/>
                                            </xsl:attribute>
                                            <xsl:value-of select="@name"/>
                                        </db:link>
                                    </db:member>
                                </xsl:if>
                            </xsl:for-each>
                        </db:simplelist>
                    </db:para>
                </db:sect1>
                <xsl:if test="count($object/lit:templates/*) > 0">
                    <db:sect1>
                        <db:title>Definitions</db:title>
                        <db:para>The following types are defined in this object.</db:para>
                        <xsl:for-each select="$object/lit:templates/*">
                            <xsl:sort select="@name" order="ascending"/>
                            <db:sect2>
                                <xsl:attribute name="id">
                                    <xsl:value-of select="@name"/>
                                </xsl:attribute>
                                <db:title>
                                    <xsl:value-of select="@name"/>
                                </db:title>
                                <db:para>
                                    <xsl:copy-of select="lit:description"/>
                                </db:para>
                            </db:sect2>
                        </xsl:for-each>
                    </db:sect1>
                </xsl:if>
                <xsl:if test="count($object/lit:typeimpls/*) > 0">
                    <db:sect1>
                        <db:title>Implementations</db:title>
                        <db:para>The following types have implementations defined in this object. Each implementation is language specific, and is used to output code for that language when using the type.</db:para>
                        <xsl:for-each select="$object/lit:typeimpls/*">
                            <xsl:sort select="@name" order="ascending"/>
                            <db:sect2>
                                <xsl:attribute name="id">
                                    <xsl:value-of select="@name"/>
                                </xsl:attribute>
                                <xsl:call-template name="typeimpl">
                                    <xsl:with-param name="typeimpl" select="."/>
                                </xsl:call-template>
                            </db:sect2>
                        </xsl:for-each>
                    </db:sect1>
                </xsl:if>
            </db:chapter>
        </xsl:if>
    </xsl:template>
<!--
Output an object.
-->

    <xsl:template name="object">
        <xsl:param name="object"/>
        <xsl:if test="name($object) = 'object' and $object/@name = $objname">
            <xsl:call-template name="object_description">
                <xsl:with-param name="object" select="$object"/>
            </xsl:call-template>
        </xsl:if>
        <xsl:for-each select="$object/lit:derived/*">
            <xsl:call-template name="object">
                <xsl:with-param name="object" select="."/>
            </xsl:call-template>
        </xsl:for-each>
        <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:call-template>
            </xsl:for-each>
        </xsl:if>
    </xsl:template>
    <xsl:template match="/">
        <xsl:comment>
Woven from             <xsl:value-of select="$schemapath"/>
through schema.xsl on             <xsl:value-of select="$date"/>
. Edit at your own risk!         </xsl:comment>
        <db:book>
            <xsl:call-template name="object">
                <xsl:with-param name="object" select="lit:object"/>
            </xsl:call-template>
        </db:book>
    </xsl:template>
</xsl:stylesheet>