<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<!-- Map Viewer (Third Edition) by Howie Sternberg at howies@snet.net. Map Viewer is placed in the public domain and is "Freeware". Map Viewer may be freely used and redistributed, is provided "AS-IS" without warranty of any kind, and there is no technical support provided. --> 

<!-- input parameters and defauts --> 
<xsl:param name="currentMapServerUrl" select="'none'"/>
<xsl:param name="currentMapService" select="'none'"/>
<xsl:param name="currentMapTitle" select="'none'"/>
<xsl:param name="defaultMapTool" select="'zoomin'"/>
<xsl:param name="defaultMapOptionLevel2" select="'legend'"/>

<!-- Return delimited string of boolean values indicating which map viewer functions are enabled. See mapviewer.xml. Delimiter is vertical bar: | -->
<xsl:template match="/">
<xsl:for-each select="mapviewer/servers/server/mapservices/mapservice/map">
	<xsl:variable name="mapServerUrl">
		<xsl:value-of select="../../../@url"></xsl:value-of>
	</xsl:variable>
	<xsl:variable name="mapService">
		<xsl:value-of select="../@name"></xsl:value-of>
	</xsl:variable>
	<xsl:variable name="mapTitle">
		<xsl:value-of select="@title"></xsl:value-of>
	</xsl:variable>
	<xsl:choose>
		<xsl:when test="$currentMapServerUrl = $mapServerUrl">
			<xsl:choose>
				<xsl:when test="$currentMapService = $mapService">
					<xsl:choose>
						<xsl:when test="$currentMapTitle = $mapTitle">
							<!-- Return default map tool specified for this particular map, otherwise return default map tool specified for map viewer in general. -->						
						  	<xsl:choose>
								<xsl:when test="@defaultmaptool">
									<xsl:value-of select="translate(@defaultmaptool,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/><text>|</text>	
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$defaultMapTool"/>
									<text>|</text>
								</xsl:otherwise>
							</xsl:choose>
							<!-- Return default map function specified for this particular map, otherwise return default map option specified for map viewer in general. -->						
						  	<xsl:choose>
								<xsl:when test="@defaultmapoption">
									<xsl:value-of select="translate(@defaultmapoption,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/><text>|</text>		
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$defaultMapOptionLevel2"/>
									<text>|</text>
								</xsl:otherwise>
							</xsl:choose>
							<!-- enable layers function -->						
						  	<xsl:choose>
								<xsl:when test="layers/@enable">
									<xsl:variable name="varEnableLayers">
										<xsl:value-of select="translate(layers/@enable,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
									</xsl:variable>
									<xsl:choose>
										<xsl:when test="$varEnableLayers = 'true'">		
											<text>true|</text>
										</xsl:when>
										<xsl:otherwise>
											<text>false|</text>
										</xsl:otherwise>
									</xsl:choose>									
								</xsl:when>
								<xsl:otherwise>
									<text>true|</text>
								</xsl:otherwise>
							</xsl:choose>
							<!-- enable search function -->
						  	<xsl:choose>
								<xsl:when test="search/@enable">
									<xsl:variable name="varEnableSearch">
										<xsl:value-of select="translate(search/@enable,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
									</xsl:variable>
									<xsl:choose>
										<xsl:when test="$varEnableSearch = 'true'">		
											<text>true|</text>
										</xsl:when>
										<xsl:otherwise>
											<text>false|</text>
										</xsl:otherwise>
									</xsl:choose>									
								</xsl:when>
								<xsl:otherwise>
									<text>false|</text>
								</xsl:otherwise>
							</xsl:choose>
							<!-- enable legend function -->
						  	<xsl:choose>
								<xsl:when test="legend/@enable">
									<xsl:variable name="varEnableLegend">
										<xsl:value-of select="translate(legend/@enable,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
									</xsl:variable>
									<xsl:choose>
										<xsl:when test="$varEnableLegend = 'true'">		
											<text>true|</text>
										</xsl:when>
										<xsl:otherwise>
											<text>false|</text>
										</xsl:otherwise>
									</xsl:choose>									
								</xsl:when>
								<xsl:otherwise>
									<text>true|</text>
								</xsl:otherwise>
							</xsl:choose>
							<!-- enable properties function -->
						  	<xsl:choose>
								<xsl:when test="properties/@enable">
									<xsl:variable name="varEnableProperties">
										<xsl:value-of select="translate(properties/@enable,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
									</xsl:variable>
									<xsl:choose>
										<xsl:when test="$varEnableProperties = 'true'">		
											<text>true|</text>
										</xsl:when>
										<xsl:otherwise>
											<text>false|</text>
										</xsl:otherwise>
									</xsl:choose>									
								</xsl:when>
								<xsl:otherwise>
									<text>true|</text>
								</xsl:otherwise>
							</xsl:choose>
							<!-- enable print function -->
						  	<xsl:choose>
								<xsl:when test="print/@enable">
									<xsl:variable name="varEnablePrint">
										<xsl:value-of select="translate(print/@enable,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
									</xsl:variable>
									<xsl:choose>
										<xsl:when test="$varEnablePrint = 'true'">		
											<text>true|</text>
										</xsl:when>
										<xsl:otherwise>
											<text>false|</text>
										</xsl:otherwise>
									</xsl:choose>									
								</xsl:when>
								<xsl:otherwise>
									<text>true|</text>
								</xsl:otherwise>
							</xsl:choose>
							<!-- enable add new map function -->
						  	<xsl:choose>
								<xsl:when test="addnewmap/@enable">
									<xsl:variable name="varEnableAddnewmap">
										<xsl:value-of select="translate(addnewmap/@enable,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
									</xsl:variable>
									<xsl:choose>
										<xsl:when test="$varEnableAddnewmap = 'true'">		
											<text>true|</text>
										</xsl:when>
										<xsl:otherwise>
											<text>false|</text>
										</xsl:otherwise>
									</xsl:choose>									
								</xsl:when>
								<xsl:otherwise>
									<text>true|</text>
								</xsl:otherwise>
							</xsl:choose>
							<!-- enable about map viewer function -->
						  	<xsl:choose>
								<xsl:when test="aboutmapviewer/@enable">
									<xsl:variable name="varEnableAbout">
										<xsl:value-of select="translate(aboutmapviewer/@enable,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
									</xsl:variable>
									<xsl:choose>
										<xsl:when test="$varEnableAbout = 'true'">		
											<text>true</text>
										</xsl:when>
										<xsl:otherwise>
											<text>false</text>
										</xsl:otherwise>
									</xsl:choose>									
								</xsl:when>
								<xsl:otherwise>
									<text>true</text>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:when>
					</xsl:choose>
				</xsl:when>
			</xsl:choose>
		</xsl:when>
	</xsl:choose>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>