<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:test="test">
	<!-- 
	comment for stylesheet is the first comment in the file

	"quots" too?
	
    <p>
    USES HTML AND @tag COMMENTS!
    </p>
    <p>
    THIS FILE DOES NOT WORK - ONLY SHOWS HOW TO DOCUMENT 
    </p>
    <p>
    builds a simplified xml file of a given xsl stylesheet with only the needed information for xsldoc. 
    add here if you need to comment more elements.
    </p>
    <p>elements that are transformed are (all in the standard xslt namespace http://www.w3.org/1999/XSL/Transform)</p>
    <ul>
        <li>xsl:stylesheet or xsl:transform</li>
        <li>xsl:output</li>
        <li>xsl:param</li>
        <li>xsl:include</li>
        <li>xsl:import</li>
        <li>xsl:variable</li>
        <li>xsl:template</li>
    </ul>
    <p>all comments that are directly <b>in front of</b> an element are tranformed
    to a comment-element <b>except</b> for the opening xsl:stylesheet element for which the
    <b>first following comment</b> is used.</p>
	<p>non ASCII characters should work in comments (öäüÜÖÄß), pyxsldoc normally assumes
    UTF-8 documents</p>
	@author Christof Hoeke
	@version 0.43 040524
	-->
	<!-- comment for output -->
	<xsl:output encoding="UTF-8" indent="yes" method="xml" omit-xml-declaration="yes" standalone="no"/>
	<!-- comment for ns-alias -->
	<xsl:namespace-alias stylesheet-prefix="test" result-prefix="xsl"/>
	<!-- comment for strip space of all elements -->
	<xsl:strip-space elements="test | test2"/>
	<!-- comment for preserve -->
	<xsl:preserve-space elements="some"/>
	<!-- imports/includes -->
	<xsl:import href="test2.xsl"/>
	<!-- comment for import -->
	<xsl:import href="test1.xsl"/>
	<!-- comment for include -->
	<xsl:include href="testa.xsl"/>
	<xsl:include href="testc.xsl"/>
	<xsl:include href="testb.xsl"/>
	<!-- comment for param 1 -->
	<xsl:param name="par1" select="1"/>
	<!-- comment for param 2 -->
	<xsl:param name="par2">2</xsl:param>
	<!-- comment for variable var 2 -->
	<xsl:variable name="var2" select="2"/>
	<!--comment for  variable var 3 -->
	<xsl:variable name="var3" select="3"/>
	<!-- comment for variable var 1 -->
	<xsl:variable name="var1">1</xsl:variable>
	<!-- comment for key 2 -->
	<xsl:key name="n2" match="m2" use="u2"/>
	<!-- comment for key 1 -->
	<xsl:key name="n" match="m" use="u"/>
	<!-- comment for this attribute set -->
	<xsl:attribute-set name="as1">
		<xsl:attribute name="a2"><xsl:value-of select="$var3"/></xsl:attribute>
		<xsl:attribute name="a1">x</xsl:attribute>
	</xsl:attribute-set>
	<xsl:attribute-set name="as2">
		<xsl:attribute name="a2">y</xsl:attribute>
		<xsl:attribute name="a1">x</xsl:attribute>
	</xsl:attribute-set>
	<!-- comment for decimal formatter2 -->
	<xsl:decimal-format decimal-separator="." name="name2" NaN="NaN" pattern-separator=";" per-mille="&#x2030;" percent="%" zero-digit="0"/>
	<!-- comment for decimal formatter1 -->
	<xsl:decimal-format decimal-separator="," digit="#" grouping-separator="." infinity="Inf" minus-sign="-" name="name1" NaN="NaN" pattern-separator=";" per-mille="&#x2030;" percent="%" zero-digit="0"/>
	<!-- test if sorted right in summary -->
	<xsl:template match="sorted" mode="1"/>
	<!-- test if sorted right in summary -->
	<xsl:template match="sorted" mode="2"/>
	<!-- test if sorted right in summary -->
	<xsl:template name="sorted"/>
	<!-- test if sorted right in summary -->
	<xsl:template match="sorted"/>
	<!-- test if sorted right in summary -->
	<xsl:template match="sorted" priority="5"/>
	<!-- test if sorted right in summary -->
	<xsl:template match="sorted" mode="5" priority="1"/>
	<!-- test if sorted right in summary -->
	<xsl:template name="sorted" mode="2"/>
	<!-- test if sorted right in summary -->
	<xsl:template match="sorted" mode="1" priority="1"/>
	<!-- test if sorted right in summary -->
	<xsl:template match="sorted" mode="5" priority="6"/>
	<!-- test if sorted right in summary -->
	<xsl:template match="sorted" priority="3"/>
	<!-- match template without params, mode, priority

does nothing -->
	<xsl:template match="melement"/>
	<!-- named template without params, mode, priority

does nothing -->
	<xsl:template name="nelement"/>
	<!-- match/named template without params, mode, priority

does nothing -->
	<xsl:template match="mnelement" name="nmelement"/>
	<!-- match template without params, mode

does nothing -->
	<xsl:template match="mpelement" priority="1"/>
	<!-- named template without params, mode

does nothing -->
	<xsl:template name="npelement" priority="1"/>
	<!-- match/named template without params, mode

does nothing -->
	<xsl:template match="mnpelement" name="nmpelement" priority="1"/>
	<!-- match template without params

does nothing -->
	<xsl:template match="mpmelement" priority="1" mode="m1"/>
	<!-- named template without params
	
does nothing -->
	<xsl:template name="npmelement" priority="1" mode="m1"/>
	<!-- match/named template without params

does nothing -->
	<xsl:template match="mnpmelement" name="nmpmelement" priority="1" mode="m1"/>
	<!-- match template with everything

does nothing -->
	<xsl:template match="mall" mode="mode12" priority="2">
		<xsl:param name="t1">default in content</xsl:param>
		<xsl:param name="t2" select="default in select"/>
		<!-- no default -->
		<xsl:param name="t3"/>
	</xsl:template>
	<!-- named template with everything

does nothing -->
	<xsl:template name="nall" mode="x" priority="3">
		<xsl:param name="t1">default in content</xsl:param>
		<xsl:param name="t2" select="default in select"/>
		<!-- no default -->
		<xsl:param name="t3"/>
	</xsl:template>
	<!-- match and named template with everything

does nothing -->
	<xsl:template match="mnall" name="nmall" mode="mode1" priority="5">
		<xsl:param name="t1">default in content</xsl:param>
		<xsl:param name="t2" select="default in select"/>
		<!-- no default -->
		<xsl:param name="t3"/>
	</xsl:template>
	<!-- 
    all stylesheets start with these root elements. all attributes are processed.
    -->
	<xsl:template match="/xsl:stylesheet | /xsl:transform">
		<stylesheet href="{$href}">
			<!-- special comment for the whole stylesheet AFTER the element-starttag to comment -->
			<xsl:if test="(comment() | *)[1] = comment()[1]">
				<comment>
					<xsl:value-of select="comment()[1]"/>
				</comment>
			</xsl:if>
			<stylesheet-attributes>
				<xsl:copy-of select="@*"/>
			</stylesheet-attributes>
			<xsl:apply-templates select="xsl:include | xsl:import | xsl:output | xsl:param | xsl:variable | xsl:template"/>
		</stylesheet>
	</xsl:template>
	<!-- the attributes name and href are processed -->
	<xsl:template match="xsl:include | xsl:import">
		<xsl:element name="{local-name()}">
			<xsl:copy-of select="@name | @href"/>
			<!-- <xsl:call-template name="insert-comment" /> -->
		</xsl:element>
	</xsl:template>
	<!-- all attributes are processed -->
	<xsl:template match="xsl:output">
		<output>
			<xsl:copy-of select="@*"/>
			<xsl:call-template name="insert-comment"/>
		</output>
	</xsl:template>
	<!-- param and variable, select will be processed. content will be just copied! -->
	<xsl:template match="xsl:param | xsl:variable">
		<xsl:element name="{local-name()}">
			<xsl:copy-of select="@name | @select"/>
			<xsl:call-template name="insert-comment"/>
			<default>
				<xsl:copy-of select="* | text()"/>
			</default>
		</xsl:element>
	</xsl:template>
	<!-- match and name attributes and all param elements are processed -->
	<xsl:template match="xsl:template">
		<xsl:element name="{local-name()}">
			<xsl:copy-of select="@match | @name | @mode"/>
			<xsl:apply-templates select="xsl:param"/>
			<xsl:call-template name="insert-comment"/>
		</xsl:element>
	</xsl:template>
	<!-- inserts the comment as a comment-element for the calling element as a normalized-space value -->
	<xsl:template name="insert-comment" mode="mode3">
		<xsl:param name="test1" select="1"/>
		<xsl:param name="test2">2</xsl:param>
		<xsl:if test="(preceding-sibling::comment() | preceding-sibling::*)[last()] = preceding-sibling::comment()[1]">
			<comment>
				<xsl:value-of select="preceding-sibling::comment()[1]"/>
				<!-- for javadoc ???
                <xsl:value-of select="normalize-space(preceding-sibling::comment()[1])"/> -->
			</comment>
		</xsl:if>
	</xsl:template>
	<!-- Comment for <b>bug_1</b>
   		@author Doron Enav
   		@version 0.65
        @param test1 Javadoc param comment for test1
        @param test2 Javadoc param comment for test2
     -->
	<xsl:template name="bug_1">
		<!-- comment test 1 before test 1 -->
		<xsl:param name="test1" select="1"/>
		<!-- comment test 2 before test 2 -->
		<xsl:param name="test2">2</xsl:param>
		<!-- comment test 3 before test 3 -->
		<xsl:param name="test3"/>
		<xsl:if test="(preceding-sibling::comment() | preceding-sibling::*)[last()] = preceding-sibling::comment()[1]">
			<comment>
				<xsl:value-of select="preceding-sibling::comment()[1]"/>
			</comment>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
