<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gen="dummy-namespace-for-the-generated-xslt"
 exclude-result-prefixes="xsl">
<xsl:namespace-alias stylesheet-prefix="gen" result-prefix="xsl"/>
<xsl:output indent="yes"/>

<xsl:template match="/">
    <!-- Generate the structure of the XSL stylesheet -->
    <gen:stylesheet version="1.0">
      <gen:output method="text"/>

      <!-- put the logic for the generated XSLT here -->
      <gen:template match="/">
	    <gen:for-each select="root/region/*">
	    <gen:choose>

	<xsl:for-each select="adapter/region/row">
	  <gen:when test="local-name() = '{rowName/text()}'">

		<xsl:for-each select="field">
			<xsl:variable name="currentpos" select="position()"/>
			<xsl:choose>
				<xsl:when test="$currentpos != count(../field)">
					<xsl:variable name="currentcount" select="count(../field)"/>
			        <gen:call-template name="pad-right">
						<gen:with-param name="str" select="{name/text()}"/>
						<gen:with-param name="len" select="{../field[$currentpos + 1]/@offset - @offset}"/>
					</gen:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:variable name="currentcount" select="count(../field)"/>
			        <gen:call-template name="pad-right">
						<gen:with-param name="str" select="{name/text()}"/>
						<gen:with-param name="len" select="{../../width - @offset}"/>
					</gen:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
		</gen:when>
	</xsl:for-each>
		</gen:choose>
		</gen:for-each>
      </gen:template>

	  	<gen:template name="pad-left">
		<gen:param name="str"/>
		<gen:param name="len"/>
		<gen:choose>
			<gen:when test="string-length($str) &gt; $len">
				<gen:value-of select="substring($str, 1, $len)"/>
			</gen:when>
			<gen:when test="string-length($str) &lt; $len">
				<gen:call-template name="pad-left">
					<gen:with-param name="str" select="concat(' ', $str)"/>
					<gen:with-param name="len" select="$len"/>
				</gen:call-template>
			</gen:when>
			<gen:otherwise>
				<gen:value-of select="$str"/>
			</gen:otherwise>
		</gen:choose>
	</gen:template>

	<gen:template name="pad-right">
		<gen:param name="str"/>
		<gen:param name="len"/>
		<gen:choose>
			<gen:when test="string-length($str) &gt; $len">
				<gen:value-of select="substring($str, 1, $len)"/>
			</gen:when>
			<gen:when test="string-length($str) &lt; $len">
				<gen:call-template name="pad-right">
					<gen:with-param name="str" select="concat($str, ' ')"/>
					<gen:with-param name="len" select="$len"/>
				</gen:call-template>
			</gen:when>
			<gen:otherwise>
				<gen:value-of select="$str"/>
			</gen:otherwise>
		</gen:choose>
	</gen:template>
    </gen:stylesheet>


	
</xsl:template>

</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2006. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="INF10" userelativepaths="yes" externalpreview="no" url="INF10OTIS.xml" htmlbaseurl="" outputurl="INF10OTIS&#x2D;flat.xsl" processortype="internal" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no" ><SourceSchema srcSchemaPath="..\Common\StylusConv.xsd" srcSchemaRoot="adapter" AssociatedInstance="" loaderFunction="document" loaderFunctionUsesURI="no"/></MapperInfo><MapperBlockPosition><template match="/"><block path="gen:stylesheet/gen:template/xsl:for&#x2D;each" x="167" y="126"/></template></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->