<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:cdm="http://cdm-fr.fr/2006/CDM-frSchema/">
	<xsl:key name="programCode" match="programCode"
		use="concat(@codeSet,' ',text())" />
	<xsl:key name="lov" match="lov" use="concat(@info,' ',@code)" />
	<xsl:key name="search" match="orioai-search"
		use="concat(@info,' ',@code)" />
	<xsl:output encoding="UTF-8" method="xml" indent="yes" />
	<!-- **************************************************
		Copie de tous les éléments et attributs pour les deux modes
		******************************************************* -->
	<xsl:template match="* | @* | comment() | text()">
		<!-- copie du noeud courant -->
		<xsl:copy>
			<xsl:apply-templates select="@*|*|text() | comment()" />
		</xsl:copy>
	</xsl:template>

	<xsl:template
		match="orioai-search[not(preceding-sibling::orioai-search)]">
		<xsl:for-each select="../orioai-search">
			<xsl:sort select="@info" order="ascending" />
			<xsl:sort select="@code" order="ascending" />
			<xsl:sort select="@rank" order="ascending" />
			<xsl:copy>
				<xsl:apply-templates select="@*|*|text() | comment()" />
			</xsl:copy>
		</xsl:for-each>

	</xsl:template>
	<xsl:template match="orioai-search" />
	<xsl:template match="lov[not(preceding-sibling::lov)]">
		<xsl:for-each select="../lov">
			<xsl:sort select="@info" order="ascending" />
			<xsl:sort select="@code" order="ascending" />
			<xsl:copy>
				<xsl:apply-templates select="@*|*|text() | comment()" />
			</xsl:copy>
		</xsl:for-each>

	</xsl:template>
	<xsl:template match="lov" />
	<xsl:template
		match="programCode[not(preceding-sibling::programCode)]">
		<xsl:for-each select="../programCode">
			<xsl:sort select="@codeSet" order="ascending" />
			<xsl:sort select="text()" order="ascending" />
			<xsl:copy>
				<xsl:apply-templates select="@*|*|text() | comment()" />
			</xsl:copy>
		</xsl:for-each>

	</xsl:template>
	<xsl:template match="programCode" />
	<xsl:template match="lov/@poids"/>
</xsl:stylesheet>

