<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2005 rel. 3 U (http://www.altova.com) by Hugues (EMBRACE) -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:proc="http://www.example.org/proc" xmlns:md="http://www.stambia.com/md" xmlns:tech="http://www.stambia.com/tech" xmlns:saxon="http://saxon.sf.net/" xmlns:metaInf="http://www.stambia.com/metaInf" xmlns:UUID="java.util.UUID" extension-element-prefixes="saxon">
	<xsl:output method="xml"/>
	<xsl:variable name="debug" select="false()"/>
	<xsl:variable name="endSourceSets" saxon:assignable="yes">
		<sourceSet/>
	</xsl:variable>
	<xsl:template match="/">
		<metaInf:descriptor>
			<xsl:apply-templates mode="analyse" select="*"/>
		</metaInf:descriptor>
	</xsl:template>
	<xsl:template match="*">
		<xsl:apply-templates mode="analyse" select="*"/>
	</xsl:template>
	<xsl:template match="element" mode="analyse">
		<xsl:param name="path"/>
		<xsl:variable name="path" select="if ($path!='') then concat($path,'/',@name) else @name"/>
		<xsl:choose>
			<xsl:when test="@maxOccurs=-1 or not(contains($path,'/'))">
				<datastore metaInf:path="{$path}">
					<xsl:apply-templates mode="analyse" select="@*">
						<xsl:with-param name="path" select="$path"/>
					</xsl:apply-templates>
					<xsl:apply-templates mode="analyse" select="*">
						<xsl:with-param name="path" select="$path"/>
					</xsl:apply-templates>
					<xsl:if test="not(*)">
						<field metaInf:path="{$path}" metaInf:originalType="element">
							<xsl:apply-templates mode="analyse" select="@*"/>
						</field>
					</xsl:if>
				</datastore>
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="*">
						<xsl:apply-templates mode="analyse" select="*">
							<xsl:with-param name="path" select="$path"/>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:otherwise>
						<field metaInf:path="{$path}" metaInf:originalType="element">
							<xsl:apply-templates mode="analyse" select="@*"/>
						</field>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="attribute" mode="analyse">
		<xsl:param name="path"/>
		<xsl:variable name="path" select="concat($path,'/@',@name)"/>
		<field metaInf:path="{$path}" metaInf:originalType="attribute">
			<xsl:apply-templates mode="analyse" select="@*"/>
		</field>
	</xsl:template>
	<xsl:template match="@*" mode="analyse">
		<xsl:copy/>
	</xsl:template>
</xsl:stylesheet>
