<ctl:package xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:xi="http://www.w3.org/2001/XInclude">
<ctl:package xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:function name="functions:version">
      <ctl:return>The string '1.3.0'</ctl:return>
      <ctl:description>Gets the version number tested by these scripts test</ctl:description>
      <ctl:code>
         <xsl:text>1.3.0</xsl:text>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:version-as-integer">
      <ctl:param name="version-string">Version String</ctl:param>
      <ctl:description>Gets the integer value of a version number</ctl:description>
      <ctl:code>
         <xsl:variable name="major" select="substring-before($version-string, '.')"/>
         <xsl:variable name="minor"
                       select="substring-before(substring-after($version-string, '.'), '.')"/>
         <xsl:variable name="rev" select="substring-after(substring-after($version-string, '.'), '.')"/>
         <xsl-value-of select="$major * 10000 + $minor * 100 + $rev"/>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:layer-info">
      <ctl:param name="root-layer">Root layer from Capabilities XML</ctl:param>
      <ctl:param name="preferred-name">Preferred Layer Name</ctl:param>
      <ctl:param name="preferred-crs">Preferred CRS</ctl:param>
      <ctl:param name="preferred-bbox">Preferred Bounding Box</ctl:param>
      <ctl:param name="preferred-width">Preferred width</ctl:param>
      <ctl:param name="preferred-height">Preferred height</ctl:param>
      <ctl:return>A LayerInfo element containing name, CRS, minx, miny, maxx, and maxy attributes.</ctl:return>
      <ctl:description>Determines the crs, bbox, width, and height of a layer advertised in the Capabilities XML.</ctl:description>
      <ctl:code>
         <xsl:variable name="layer-name">
            <xsl:choose>
               <xsl:when test="$root-layer/descendant-or-self::wms:Layer[wms:Name = $preferred-name]">
                  <xsl:value-of select="$preferred-name"/>
               </xsl:when>
               <xsl:when test="$root-layer/descendant-or-self::wms:Layer[wms:Name and ancestor-or-self::wms:Layer/wms:BoundingBox and not(number(@fixedWidth) &gt; 0) and not(number(@fixedHeight) &gt; 0)]">
                  <xsl:value-of select="$root-layer/descendant-or-self::wms:Layer[wms:Name and ancestor-or-self::wms:Layer/wms:BoundingBox and not(number(@fixedWidth) &gt; 0) and not(number(@fixedHeight) &gt; 0)][1]/wms:Name"/>
               </xsl:when>
               <xsl:when test="$root-layer/descendant-or-self::wms:Layer[wms:Name and not(number(@fixedWidth) &gt; 0) and not(number(@fixedHeight) &gt; 0)]">
                  <xsl:value-of select="$root-layer/descendant-or-self::wms:Layer[wms:Name and not(number(@fixedWidth) &gt; 0) and not(number(@fixedHeight) &gt; 0)][1]/wms:Name"/>
               </xsl:when>
               <xsl:when test="$root-layer/descendant-or-self::wms:Layer[wms:Name]">
                  <xsl:value-of select="$root-layer/descendant-or-self::wms:Layer[wms:Name][1]/wms:Name"/>
               </xsl:when>
               <xsl:otherwise>NoNamedLayers</xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         <xsl:variable name="crs">
            <xsl:choose>
               <xsl:when test="$root-layer/descendant-or-self::wms:Layer[wms:Name = $layer-name]/ancestor-or-self::wms:Layer[wms:CRS = $preferred-crs]">
                  <xsl:value-of select="$preferred-crs"/>
               </xsl:when>
               <xsl:when test="$root-layer/descendant-or-self::wms:Layer[wms:Name = $layer-name]/ancestor-or-self::wms:Layer/wms:BoundingBox">
                  <xsl:value-of select="$root-layer/descendant-or-self::wms:Layer[wms:Name = $layer-name]/ancestor-or-self::wms:Layer[1]/wms:BoundingBox[1]/@CRS"/>
               </xsl:when>
               <xsl:when test="$root-layer/descendant-or-self::wms:Layer[wms:Name = $layer-name]/ancestor-or-self::wms:Layer/wms:CRS">
                  <xsl:value-of select="$root-layer/descendant-or-self::wms:Layer[wms:Name = $layer-name]/ancestor-or-self::wms:Layer[1]/wms:CRS[1]"/>
               </xsl:when>
               <xsl:otherwise>NoCRSForLayer</xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         <xsl:variable name="bbox">
            <xsl:choose>
               <xsl:when test="$crs = $preferred-crs and $preferred-bbox != '' and functions:boolean-as-integer($root-layer/descendant-or-self::wms:Layer[wms:Name = $layer-name]/@noSubsets) = 0">
                  <xsl:value-of select="$preferred-bbox"/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:variable name="bboxes">
                     <xsl:copy-of select="$root-layer/descendant-or-self::wms:Layer[wms:Name = $layer-name]/ancestor-or-self::wms:Layer/wms:BoundingBox[@CRS = $crs]"/>
                  </xsl:variable>
                  <xsl:for-each select="$bboxes/wms:BoundingBox[not(following::wms:BoundingBox)]">
                     <xsl:value-of select="concat(@minx, ',', @miny, ',', @maxx, ',', @maxy)"/>
                  </xsl:for-each>
                  <xsl:if test="not($bboxes/wms:BoundingBox)">0,0,1,1</xsl:if>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         <LayerInfo>
            <xsl:attribute name="name">
               <xsl:value-of select="$layer-name"/>
            </xsl:attribute>
            <xsl:attribute name="crs">
               <xsl:value-of select="$crs"/>
            </xsl:attribute>
            <xsl:attribute name="bbox">
               <xsl:value-of select="$bbox"/>
            </xsl:attribute>
            <xsl:attribute name="height">
               <xsl:for-each select="$root-layer/descendant-or-self::wms:Layer[wms:Name = $layer-name]">
                  <xsl:choose>
                     <xsl:when test="@fixedHeight &gt; 0">
                        <xsl:value-of select="@fixedHeight"/>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:value-of select="$preferred-height"/>
                     </xsl:otherwise>
                  </xsl:choose>
               </xsl:for-each>
            </xsl:attribute>
            <xsl:attribute name="width">
               <xsl:for-each select="$root-layer/descendant-or-self::wms:Layer[wms:Name = $layer-name]">
                  <xsl:choose>
                     <xsl:when test="@fixedWidth &gt; 0">
                        <xsl:value-of select="@fixedWidth"/>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:value-of select="$preferred-width"/>
                     </xsl:otherwise>
                  </xsl:choose>
               </xsl:for-each>
            </xsl:attribute>
            <xsl:for-each select="$root-layer//wms:Layer[wms:Name=$layer-name]/ancestor-or-self::wms:Layer/wms:Dimension[not(@default)]">
               <dim>
                  <xsl:attribute name="param-name">
                     <xsl:variable name="name" select="functions:to-lowercase(@name)"/>
                     <xsl:if test="$name != 'time' and $name != 'elevation'">dim_</xsl:if>
                     <xsl:value-of select="$name"/>
                  </xsl:attribute>
                  <xsl:value-of select="substring-before(concat(translate(., '/', ','), ','), ',')"/>
               </dim>
            </xsl:for-each>
         </LayerInfo>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:queryable-layer-info">
      <ctl:param name="root-layer">Root layer from Capabilities XML</ctl:param>
      <ctl:param name="preferred-name">Preferred Layer Name</ctl:param>
      <ctl:param name="preferred-crs">Preferred CRS</ctl:param>
      <ctl:param name="preferred-bbox">Preferred Bounding Box</ctl:param>
      <ctl:param name="preferred-width">Preferred width</ctl:param>
      <ctl:param name="preferred-height">Preferred height</ctl:param>
      <ctl:return>A LayerInfo element containing name, CRS, minx, miny, maxx, and maxy attributes.</ctl:return>
      <ctl:description>Determines the CRS, layer name, and bounds of a layer advertised in the Capabilities XML.</ctl:description>
      <ctl:code>
         <xsl:variable name="layer-name">
            <xsl:choose>
               <xsl:when test="$root-layer/descendant-or-self::wms:Layer[wms:Name = $preferred-name and functions:boolean-as-integer(@queryable) = 1]">
                  <xsl:value-of select="$preferred-name"/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:value-of select="$root-layer/descendant-or-self::wms:Layer[wms:Name and functions:boolean-as-integer(@queryable) = 1]/wms:Name"/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         <xsl:copy-of select="functions:layer-info($root-layer, $preferred-name, $preferred-crs, $preferred-bbox, $preferred-width, $preferred-height)"/>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:split">
      <ctl:param name="s">String to split</ctl:param>
      <ctl:param name="match">String that divides tokens</ctl:param>
      <ctl:description>Splits a string into tokens.</ctl:description>
      <ctl:code>
         <xsl:if test="$s != ''">
            <token>
               <xsl:value-of select="substring-before(concat($s, $match), $match)"/>
            </token>
            <xsl:if test="contains($s, $match)">
               <xsl:copy-of select="functions:split(substring-after($s, $match), $match)"/>
            </xsl:if>
         </xsl:if>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:remove-mime-comment">
      <ctl:param name="mime">MIME from which to remove comments</ctl:param>
      <ctl:description>Removes comments (enclosed in parenthesis) from a MIME string</ctl:description>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="contains($mime, '(')">
               <xsl:variable name="before" select="substring-before($mime, '(')"/>
               <xsl:variable name="after" select="substring-after(substring-after($mime, '('), ')')"/>
               <xsl:value-of select="concat($before, functions:remove-mime-comment($after))"/>
            </xsl:when>
            <xsl:otherwise>
               <xsl:value-of select="$mime"/>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:mime-match">
      <ctl:param name="test-mime">MIME type to test.</ctl:param>
      <ctl:param name="match-mime">MIME type to match.</ctl:param>
      <ctl:return/>
      <ctl:description>Determines whether a MIME type matches a normalized MIME type.</ctl:description>
      <ctl:code>
         <xsl:variable name="failures">
            <xsl:variable name="test-string"
                          select="concat(functions:remove-mime-comment($test-mime), ';')"/>
            <xsl:variable name="match-string"
                          select="concat(functions:remove-mime-comment($match-mime), ';')"/>
            <xsl:variable name="base-test-mime"
                          select="normalize-space(substring-before($test-string, ';'))"/>
            <xsl:variable name="base-match-mime"
                          select="normalize-space(substring-before($match-string, ';'))"/>
            <xsl:choose>
               <xsl:when test="functions:to-lowercase($base-test-mime) = functions:to-lowercase($base-match-mime)"><!--
MIME parameters don't have to match anymore - see issue 24, MIME type test too strict
                  <xsl:variable name="test-params">
                     <xsl:copy-of select="functions:split(substring-after($test-string, ';'), ';')"/>
                  </xsl:variable>
                  <xsl:variable name="match-params">
                     <xsl:copy-of select="functions:split(substring-after($match-string, ';'), ';')"/>
                  </xsl:variable>
                  <xsl:for-each select="$match-params/token[normalize-space(.) != '']">
                     <xsl:variable name="param" select="functions:to-lowercase(normalize-space(.))"/>
                     <xsl:if test="not($test-params/token[functions:to-lowercase(normalize-space(.)) = $param])">
                        <fail/>
                     </xsl:if>
                  </xsl:for-each>
--></xsl:when>
               <xsl:otherwise>
                  <fail/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         <xsl:value-of select="not($failures/fail)"/>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:boolean-as-integer">
      <ctl:param name="boolean-or-int">'true', 'false', or integer value</ctl:param>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="string($boolean-or-int) = '1'">1</xsl:when>
            <xsl:when test="string($boolean-or-int) = 'true'">1</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:to-lowercase">
      <ctl:param name="string">string value</ctl:param>
      <ctl:code>
         <xsl:value-of select="translate($string, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:correct-url-prefix">
      <ctl:param name="url-prefix">URL Prefix Value</ctl:param>
      <ctl:code>
         <xsl:value-of select="$url-prefix"/>
         <xsl:choose>
            <xsl:when test="not(contains($url-prefix, '?'))">?</xsl:when>
            <xsl:when test="not(substring($url-prefix, string-length($url-prefix)) = '&amp;')">&amp;</xsl:when>
         </xsl:choose>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:increment-updatesequence">
      <ctl:param name="updatesequence">An updatesequence value</ctl:param>
      <ctl:param name="increment">Increment value (1 for up, -1 for down)</ctl:param>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="string(number($updatesequence)) = 'NaN'">
               <xsl:variable name="down">ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy012345678</xsl:variable>
               <xsl:variable name="up">BCDEFGHIJKLMNOPQRSTUVWXYZbcdefghijklmnopqrstuvwxyz123456789</xsl:variable>
               <xsl:choose>
                  <xsl:when test="$increment = 1">
                     <xsl:value-of select="translate($updatesequence, $down, $up)"/>
                  </xsl:when>
                  <xsl:otherwise>
                     <xsl:value-of select="translate($updatesequence, $up, $down)"/>
                  </xsl:otherwise>
               </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
               <xsl:value-of select="number($updatesequence) + $increment"/>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:image-format">
      <ctl:param name="format">A format</ctl:param>
      <ctl:code>
         <xsl:value-of select="boolean(functions:mime-match($format, 'image/png') = 'true' or functions:mime-match($format, 'image/gif') = 'true' or functions:mime-match($format, 'image/jpeg') = 'true')"/>
      </ctl:code>
   </ctl:function>
   <ctl:function name="functions:encode">
      <ctl:param name="str">String to be percent-encoded.</ctl:param>
      <ctl:code>
         <xsl:value-of select="encode-for-uri($str)"/>
      </ctl:code>
   </ctl:function>
</ctl:package>
<ctl:package xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:test name="basic_elements:basic_elements">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The basic service elements behave properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="basic_elements:version-negotiation"/>
         <ctl:call-test name="basic_elements:reserved-chars"/>
         <ctl:call-test name="basic_elements:param-rules"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:version-negotiation">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Version negotiation behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="basic_elements:negotiate-no-version"/>
         <ctl:call-test name="basic_elements:negotiate-basic_elements-version"/>
         <ctl:call-test name="basic_elements:negotiate-higher-version"/>
         <ctl:call-test name="basic_elements:negotiate-lower-version"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:reserved-chars">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Reserved characters in HTTP GET URLs are hanled properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="basic_elements:escaped-chars"/>
         <ctl:call-test name="basic_elements:escaped-space"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:param-rules">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The request parameter rules behave properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="basic_elements:extra-GetCapabilities-param"/>
         <ctl:call-test name="basic_elements:extra-GetMap-param"/>
         <ctl:call-test name="basic_elements:extra-GetFeatureInfo-param"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:extra-GetCapabilities-param">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetCapabilities request contains a parameter which is not defined by the spec, the result is valid.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 6.8.1">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.param_rules.order_and_case</ctl:link>
      <ctl:code>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="BoGuS">ignored</ctl:param>
               <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="SeRvIcE">WMS</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/wms:WMS_Capabilities)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:extra-GetMap-param">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains a parameter which is not defined by the spec, the result is valid.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 6.8.1">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.param_rules.order_and_case</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">200</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="$layer-info/LayerInfo/@name = 'NoNamedLayers'">
               <ctl:message>Error: No Named layers in capabilities XML.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:when test="$layer-info/LayerInfo/@crs = 'NoCRSForLayer'">
               <ctl:message>Error: No CRS for layer <xsl:value-of select="$layer-info/LayerInfo/@name"/> in capabilities XML.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                        <!--<xsl:value-of select="functions:encode($image-format)"/>--></ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="BoGuS">ignored</ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:message>FAILURE: Unexpected Content-Type header value.</ctl:message>
                  <ctl:message>Expected <xsl:value-of select="$image-format"/> but received <xsl:value-of select="$response/response/headers/header[functions:to-lowercase(@name) = 'content-type']"/>
                  </ctl:message>
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:extra-GetFeatureInfo-param">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetFeatureInfo request contains a parameter which is not defined by the spec, the result is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 6.8.1">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.param_rules.order_and_case</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="wms:Capability/wms:Request/wms:GetFeatureInfo">
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="featureinfo-format"
                             select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:queryable-layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name" select="//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">200</ctl:with-param>
                     <ctl:with-param name="preferred-height">200</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:choose>
                  <xsl:when test="$layer-info/LayerInfo/@name = 'NoNamedLayers'">
                     <ctl:message>Error: No queryable layers in capabilities XML.</ctl:message>
                     <ctl:fail/>
                  </xsl:when>
                  <xsl:when test="$layer-info/LayerInfo/@crs = 'NoCRSForLayer'">
                     <ctl:message>Error: No CRS for layer <xsl:value-of select="$layer-info/LayerInfo/@name"/> in capabilities XML.</ctl:message>
                     <ctl:fail/>
                  </xsl:when>
                  <xsl:otherwise>
                     <xsl:variable name="response">
                        <ctl:request>
                           <ctl:url>
                              <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                           </ctl:url>
                           <ctl:method>get</ctl:method>
                           <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
                           <ctl:param name="StYlEs"/>
                           <ctl:param name="FoRmAt">
                              <xsl:value-of select="functions:encode($image-format)"/>
                              <!--<xsl:value-of select="functions:encode($image-format)"/>--></ctl:param>
                           <ctl:param name="J">64</ctl:param>
                           <ctl:param name="CrS">
                              <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                           </ctl:param>
                           <ctl:param name="InFo_fOrMaT">
                              <xsl:value-of select="functions:encode($featureinfo-format)"/>
                           </ctl:param>
                           <ctl:param name="LaYeRs">
                              <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                           </ctl:param>
                           <ctl:param name="I">188</ctl:param>
                           <ctl:param name="VeRsIoN">
                              <xsl:value-of select="functions:version()"/>
                           </ctl:param>
                           <ctl:param name="HeIgHt">
                              <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                           </ctl:param>
                           <ctl:param name="BbOx">
                              <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                           </ctl:param>
                           <ctl:param name="WiDtH">
                              <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                           </ctl:param>
                           <ctl:param name="QuErY_LaYeRs">
                              <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                           </ctl:param>
                           <ctl:param name="BoGuS">ignored</ctl:param>
                           <parsers:HTTPParser>
                              <parsers:parse>
                                 <parsers:NullParser/>
                              </parsers:parse>
                           </parsers:HTTPParser>
                        </ctl:request>
                     </xsl:variable>
                     <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $featureinfo-format) = 'false'">
                        <ctl:message>FAILURE: Unexpected Content-Type header value.</ctl:message>
                        <ctl:message>Expected <xsl:value-of select="$featureinfo-format"/> but received <xsl:value-of select="$response/response/headers/header[functions:to-lowercase(@name) = 'content-type']"/>
                        </ctl:message>
                        <ctl:fail/>
                     </xsl:if>
                  </xsl:otherwise>
               </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
               <ctl:message>GetFeatureInfo requests are not supported.</ctl:message>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:escaped-chars">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The server can decode escaped hex values.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 6.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.request_rules.reserved_chars</ctl:link>
      <ctl:code>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">%47%65%74%43%61%70%61%62%69%6C%69%74%69%65%73</ctl:param>
               <!-- The escaped value for GetCapabilities --><ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="SeRvIcE">WMS</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/wms:WMS_Capabilities)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:escaped-space">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The server can decode the "+" character as a space.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 6.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.request_rules.reserved_chars</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="//wms:Layer[contains(wms:Name, ' ')][1]/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">200</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="not(contains($layer-info/LayerInfo/@name, ' '))">
               <ctl:message>Can't check since no layer names contain spaces.</ctl:message>
            </xsl:when>
            <xsl:when test="$layer-info/LayerInfo/@crs = ''">
               <ctl:message>Error: No CRS for layer <xsl:value-of select="$layer-info/LayerInfo/@name"/> in capabilities XML.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="translate($layer-info/LayerInfo/@name, ' ', '+')"/>
                     </ctl:param>
                     <ctl:param name="BoGuS">ignored</ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:negotiate-no-version">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetCapabilities request is made without a version number, then the response is not lower than 1.3.0.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 6.2.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.version.negotiation</ctl:link>
      <ctl:code>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
               <ctl:param name="SeRvIcE">WMS</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="version">
            <xsl:value-of select="$response/WMT_MS_Capabilities/@version"/>
            <xsl:value-of select="$response/wms:WMS_Capabilities/@version"/>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="$version = ''">
               <ctl:message>Warning: Could not determine version number.</ctl:message>
            </xsl:when>
            <xsl:when test="functions:version-as-integer($version) &lt; functions:version-as-integer(functions:version())">
               <ctl:fail/>
            </xsl:when>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:negotiate-basic_elements-version">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetCapabilities request is made for version 1.3.0, then the response is version 1.3.0.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 6.2.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.version.negotiation</ctl:link>
      <ctl:code>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="SeRvIcE">WMS</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/wms:WMS_Capabilities/@version = functions:version())">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:negotiate-higher-version">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetCapabilities request is made for version 100.0.0, then the response is not lower than 1.3.0.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 6.2.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.version.negotiation</ctl:link>
      <ctl:code>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
               <ctl:param name="VeRsIoN">100.0.0</ctl:param>
               <ctl:param name="SeRvIcE">WMS</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="version">
            <xsl:value-of select="$response/WMT_MS_Capabilities/@version"/>
            <xsl:value-of select="$response/wms:WMS_Capabilities/@version"/>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="$version = ''">
               <ctl:message>Warning: Could not determine version number.</ctl:message>
            </xsl:when>
            <xsl:when test="functions:version-as-integer($version) &lt; functions:version-as-integer(functions:version())">
               <ctl:fail/>
            </xsl:when>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic_elements:negotiate-lower-version">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetCapabilities request is made for version 0.0.0, the response is not higher than 1.3.0.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 6.2.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.version.negotiation</ctl:link>
      <ctl:code>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
               <ctl:param name="VeRsIoN">100.0.0</ctl:param>
               <ctl:param name="SeRvIcE">WMS</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="version">
            <xsl:value-of select="$response/WMT_MS_Capabilities/@version"/>
            <xsl:value-of select="$response/wms:WMS_Capabilities/@version"/>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="$version = ''">
               <ctl:message>Warning: Could not determine version number.</ctl:message>
            </xsl:when>
            <xsl:when test="functions:version-as-integer($version) &gt; functions:version-as-integer(functions:version())">
               <ctl:fail/>
            </xsl:when>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
</ctl:package>
<ctl:package xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:test name="interactive:interactive">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The tests that require user interaction behave properly.</ctl:assertion>
      <ctl:code>
         <xsl:if test="wms:Capability/wms:Exception[wms:Format='INIMAGE']">
            <ctl:call-test name="interactive:exceptions-inimage"/>
         </xsl:if>
         <ctl:call-test name="interactive:fees-and-access-constraints"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="interactive:exceptions-inimage">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When an exception is raised and EXCEPTIONS=INIMAGE, then the error messages are graphically returned as part of the content.</ctl:assertion>
      <ctl:comment><![CDATA[The user will be asked to verify that an image containing an error message indicating that the layer requested was not defined is returned.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.3.3.11">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.exceptions</ctl:link>
      <ctl:code>
         <xsl:variable name="form-values">
            <ctl:form width="700" height="500">
               <img border="1">
                  <xsl:attribute name="src">
                     <xsl:value-of select="functions:correct-url-prefix(wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href)"/>
                     <xsl:text>VERSION=</xsl:text>
                     <xsl:value-of select="functions:version()"/>
                     <xsl:text>&amp;REQUEST=GetMap</xsl:text>
                     <xsl:text>&amp;LAYERS=NonExistant</xsl:text>
                     <xsl:text>&amp;STYLES=</xsl:text>
                     <xsl:text>&amp;CRS=CRS:84</xsl:text>
                     <xsl:text>&amp;BBOX=-1,-1,1,1</xsl:text>
                     <xsl:text>&amp;WIDTH=300</xsl:text>
                     <xsl:text>&amp;HEIGHT=300</xsl:text>
                     <xsl:text>&amp;FORMAT=</xsl:text>
                     <xsl:value-of select="functions:encode(wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif') or starts-with(., 'image/jpeg')][1])"/>
                     <xsl:text>&amp;EXCEPTIONS=INIMAGE</xsl:text>
                  </xsl:attribute>
               </img>
               <p>
                  Does the image above contain an error message indicating that the layer requested was not defined?
               </p>
               <p>
                  <input type="submit" name="submit" value="yes"/>
                  <input type="submit" name="submit" value="no"/>
               </p>
            </ctl:form>
         </xsl:variable>
         <xsl:if test="not($form-values/values/value[@key='submit']='yes')">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="interactive:fees-and-access-constraints">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When there are no fees or access constraints for using of the service and Fees and AccessConstraints elements are supplied in the service metadata, the reserved word "none" (case-insensitive) is used.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.3.3.11">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.exceptions</ctl:link>
      <ctl:link title="WMS 1.3.0 section 7.2.4.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.general_metadata</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="(wms:Service/wms:Fees and functions:to-lowercase(wms:Service/wms:Fees) != 'none') or (wms:Service/wms:AccessConstraints and functions:to-lowercase(wms:Service/wms:AccessConstraints) != 'none')">
               <xsl:variable name="form-values">
                  <ctl:form>
                     <xsl:if test="wms:Service/wms:Fees">
                        <pre>&lt;Fees&gt;<xsl:value-of select="wms:Service/wms:Fees"/>&lt;/Fees&gt;</pre>
                     </xsl:if>
                     <xsl:if test="wms:Service/wms:AccessConstraints">
                        <pre>&lt;AccessConstraints&gt;<xsl:value-of select="wms:Service/wms:AccessConstraints"/>&lt;/AccessConstraints&gt;</pre>
                     </xsl:if>
                     <p>
                        The service metadata indicates that there are fees or access constraints for using this service.
                        If there are no fees or access constraints, the elements may be omitted or the reserved keyword none (case insensitive) must be used.
                     </p>
                     <p>
                        Is the service metadata correct?
                     </p>
                     <p>
                        <input type="submit" name="submit" value="yes"/>
                        <input type="submit" name="submit" value="no"/>
                     </p>
                  </ctl:form>
               </xsl:variable>
               <xsl:if test="not($form-values/values/value[@key='submit']='yes')">
                  <ctl:fail/>
               </xsl:if>
            </xsl:when>
            <xsl:otherwise>
               <ctl:message>The service metadata indicates that there are no fees or access constraints.</ctl:message>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
</ctl:package>
<ctl:package xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:test name="getcapabilities:getcapabilities">
      <ctl:param name="high-updatesequence">An updateSequence value higher than the current updateSequence value advertised in the capabilities XML.</ctl:param>
      <ctl:param name="low-updatesequence">An updateSequence value lower than the current updateSequence value advertised in the capabilities XML.</ctl:param>
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The GetCapabilities request behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getcapabilities:requests">
            <ctl:with-param name="high-updatesequence" select="$high-updatesequence"/>
            <ctl:with-param name="low-updatesequence" select="$low-updatesequence"/>
         </ctl:call-test>
         <ctl:call-test name="getcapabilities:xml-validation"/>
         <ctl:call-test name="getcapabilities:capability-metadata"/>
         <ctl:call-test name="getcapabilities:layer-properties"/>
         <ctl:call-test name="getcapabilities:dimensions"/>
         <ctl:call-test name="getcapabilities:layer-extents"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:requests">
      <ctl:param name="high-updatesequence">An updateSequence value higher than the current updateSequence value advertised in the capabilities XML.</ctl:param>
      <ctl:param name="low-updatesequence">An updateSequence value lower than the current updateSequence value advertised in the capabilities XML.</ctl:param>
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Each request parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <xsl:variable name="capabilities" select="."/>
         <ctl:for-each select="wms:Capability/wms:Request/wms:GetCapabilities/wms:Format">
            <ctl:call-test name="getcapabilities:each-format">
               <ctl:with-param name="capabilities" select="$capabilities"/>
               <ctl:with-param name="format" select="." label="each GetCapabilities format"
                               label-expr="concat('format &#34;', ., '&#34;')"/>
            </ctl:call-test>
         </ctl:for-each>
         <ctl:call-test name="getcapabilities:no-format"/>
         <ctl:call-test name="getcapabilities:invalid-format"/>
         <ctl:call-test name="getcapabilities:updatesequence-ignored"/>
         <ctl:call-test name="getcapabilities:updatesequence-current"/>
         <ctl:call-test name="getcapabilities:updatesequence-lower">
            <ctl:with-param name="low-updatesequence" select="$low-updatesequence"/>
         </ctl:call-test>
         <ctl:call-test name="getcapabilities:updatesequence-higher">
            <ctl:with-param name="high-updatesequence" select="$high-updatesequence"/>
         </ctl:call-test>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:xml-validation">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The Capabilities XML validates.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getcapabilities:normative-schema"/>
         <ctl:call-test name="getcapabilities:validate-using-schemaLocation"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:capability-metadata">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The capability metadata is advertised correctly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getcapabilities:capability-onlineresource"/>
         <ctl:call-test name="getcapabilities:capability-xml-getcapabilities-format"/>
         <ctl:call-test name="getcapabilities:capability-xml-exception-format"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:layer-properties">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The layer properties are advertised correctly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getcapabilities:logourls"/>
         <ctl:call-test name="getcapabilities:bbox-crs-advertised"/>
         <ctl:call-test name="getcapabilities:bbox-present"/>
         <ctl:call-test name="getcapabilities:bbox-distinct-crs"/>
         <ctl:call-test name="getcapabilities:crs-auto2-declarations"/>
         <ctl:call-test name="getcapabilities:crs-present"/>
         <ctl:call-test name="getcapabilities:crs-for-all-layers"/>
         <ctl:call-test name="getcapabilities:dataurls"/>
         <ctl:call-test name="getcapabilities:ex_geobbox-present"/>
         <ctl:call-test name="getcapabilities:ex_geobbox-coordinates"/>
         <ctl:call-test name="getcapabilities:featurelisturls"/>
         <ctl:call-test name="getcapabilities:authorityurl-unique"/>
         <ctl:call-test name="getcapabilities:identifier-matches-authorityurl"/>
         <ctl:call-test name="getcapabilities:metadataurls"/>
         <ctl:call-test name="getcapabilities:style-unique"/>
         <ctl:call-test name="getcapabilities:style-legendurls"/>
         <ctl:call-test name="getcapabilities:style-stylesheeturls"/>
         <ctl:call-test name="getcapabilities:style-styleurls"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:dimensions">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Dimensions are declared properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getcapabilities:dims-time"/>
         <ctl:call-test name="getcapabilities:dims-elevation-crs88"/>
         <ctl:call-test name="getcapabilities:dims-no-redeclarations"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:each-format">
      <ctl:param name="capabilities"/>
      <ctl:param name="format"/>
      <ctl:assertion>For {$format}, when the FORMAT parameter is set to that format, the MIME type of the response matches that format.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.3.1">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.params.format</ctl:link>
      <ctl:code>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="$capabilities/wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($format)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="SeRvIcE">WMS</ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:no-format">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When no FORMAT parameter is supplied, the response is capabilities XML with MIME type text/xml.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.3.1">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.params.format</ctl:link>
      <ctl:code>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="SeRvIcE">WMS</ctl:param>
               <parsers:HTTPParser/>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], 'text/xml') = 'false'">
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="not($response/response/content/wms:WMS_Capabilities)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:invalid-format">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When an invalid FORMAT parameter is supplied, the response is capabilities XML with MIME type text/xml.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.3.1">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.params.format</ctl:link>
      <ctl:code>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="FoRmAt">invalid</ctl:param>
               <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="SeRvIcE">WMS</ctl:param>
               <parsers:HTTPParser/>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], 'text/xml') = 'false'">
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="not($response/response/content/wms:WMS_Capabilities)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:updatesequence-ignored">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When no updateSequence number is advertised in the Capabilities XML, The UPDATESEQUENCE parameter is ignored.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.params.updatesequence</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="@updateSequence">
               <ctl:message>An updateSequence number is advertised in the Capabilities XML.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
                     <ctl:param name="SeRvIcE">WMS</ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="UpDaTeSeQuEnCe">ignored</ctl:param>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="not($response/wms:WMS_Capabilities)">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:updatesequence-current">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetCapabilities request is made with an UPDATESEQUENCE parameter set to the current update sequence value, then the server returns a valid exception (code=CurrentUpdateSequence).</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.params.updatesequence</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="@updateSequence">
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
                     <ctl:param name="SeRvIcE">WMS</ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="UpDaTeSeQuEnCe">
                        <xsl:value-of select="@updateSequence"/>
                     </ctl:param>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='CurrentUpdateSequence'])">
                  <ctl:fail/>
               </xsl:if>
            </xsl:when>
            <xsl:otherwise>
               <ctl:message>No updateSequence number is advertised in the Capabilities XML.</ctl:message>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:updatesequence-lower">
      <ctl:param name="low-updatesequence">An updateSequence value higher than the current updateSequence value advertised in the capabilities XML.</ctl:param>
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetCapabilities request is made with an UPDATESEQUENCE parameter set to a value lower than the current update sequence value, then the server returns capabilities XML.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.params.updatesequence</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="@updateSequence">
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
                     <ctl:param name="SeRvIcE">WMS</ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="UpDaTeSeQuEnCe">
                        <xsl:value-of select="$low-updatesequence"/>
                     </ctl:param>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="not($response/wms:WMS_Capabilities)">
                  <ctl:fail/>
               </xsl:if>
            </xsl:when>
            <xsl:otherwise>
               <ctl:message>No updateSequence number is advertised in the Capabilities XML.</ctl:message>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:updatesequence-higher">
      <ctl:param name="high-updatesequence">An updateSequence value higher than the current updateSequence value advertised in the capabilities XML.</ctl:param>
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetCapabilities request is made with an UPDATESEQUENCE parameter set to a value higher than the current update sequence value, then the server returns an exception (code=InvalidUpdateSequence).</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.params.updatesequence</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="@updateSequence">
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetCapabilities/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="ReQuEsT">GetCapabilities</ctl:param>
                     <ctl:param name="SeRvIcE">WMS</ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="UpDaTeSeQuEnCe">
                        <xsl:value-of select="$high-updatesequence"/>
                     </ctl:param>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='InvalidUpdateSequence'])">
                  <ctl:fail/>
               </xsl:if>
            </xsl:when>
            <xsl:otherwise>
               <ctl:message>No updateSequence number is advertised in the Capabilities XML.</ctl:message>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:normative-schema">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The normative content of the schema document referred to by the schemaLocation attribute in the capabilities document is identical to the normative content of the on-line schema referred to in Annex E.1.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(@xsi:schemaLocation)">
               <ctl:message>A schemaLocation attribute is required on the root element.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:when test="not(contains(@xsi:schemaLocation, 'http://www.opengis.net/wms'))">
               <ctl:message>The schemaLocation attribute must provide a schema for the http://www.opengis.net/wms namespace.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="schema-url"
                             select="substring-before(concat(substring-after(normalize-space(@xsi:schemaLocation), 'http://www.opengis.net/wms '), ' '), ' ')"/>
               <xsl:variable name="normalized-schema">
                  <xsl:call-template name="getcapabilities:normalize-schema">
                     <xsl:with-param name="schema" select="document($schema-url)"/>
                  </xsl:call-template>
               </xsl:variable>
               <xsl:variable name="normalized-normative-schema">
                  <xsl:call-template name="getcapabilities:normalize-schema">
                     <xsl:with-param name="schema"
                                     select="document('http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd')"/>
                  </xsl:call-template>
                  <!--                  <xsl:copy-of select="functions:get-resource('net/opengis/schemas/wms/1.3.0/normalized_capabilities_1_3_0.xsd')"/> --></xsl:variable>
               <xsl:for-each select="$normalized-normative-schema/objects/*">
                  <xsl:variable name="element" select="."/>
                  <xsl:if test="count($normalized-schema/objects/*[saxon:deep-equal(., $element, none, 'w')]) = 0">
                     <ctl:message>Error: The schema does not define <xsl:value-of select="concat(name($element), ' ', $element/@name)"/> correctly.</ctl:message>
                     <ctl:fail/>
                  </xsl:if>
               </xsl:for-each>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:validate-using-schemaLocation">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The response to a GetCapabilities request validates against the schema(s) provided with the schemaLocation attribute.</ctl:assertion>
      <ctl:comment><![CDATA[Apache Xerces is used to validate the capabilities document.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.2.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response</ctl:link>
      <ctl:code>
         <xsl:variable name="reparsed-capabilities">
            <ctl:parse>
               <ctl:content>
                  <xsl:copy-of select="."/>
               </ctl:content>
               <parsers:XMLValidatingParser/>
            </ctl:parse>
         </xsl:variable>
         <xsl:if test="not($reparsed-capabilities/*)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:capability-onlineresource">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Each OnlineResource URL intended for HTTP Get requests in the capabilities document is a URL prefix</ctl:assertion>
      <ctl:comment><![CDATA[Each OnlineResource URL must ends in a ? or both contain a ? and end in an &amp;.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.2.4.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.capability_metadata</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability/wms:Request/*">
            <xsl:variable name="href"
                          select="string(wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href)"/>
            <xsl:if test="not(contains($href, '?') and (substring-after($href, '?') = '' or substring($href, string-length($href)) = '&amp;'))">
               <ctl:message>The HTTP Get OnlineResource URL for the <xsl:value-of select="local-name()"/> request is not a prefix.</ctl:message>
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:capability-xml-getcapabilities-format">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The server advertises the text/xml format for the GetCapabilities operation.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.capability_metadata</ctl:link>
      <ctl:link title="WMS 1.3.0 section 7.2.3.1">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.params.format</ctl:link>
      <ctl:code>
         <xsl:if test="not(wms:Capability/wms:Request/wms:GetCapabilities/wms:Format[. = 'text/xml'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:capability-xml-exception-format">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The server advertises the XML service exception format.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.capability_metadata</ctl:link>
      <ctl:link title="WMS 1.3.0 section 7.3.3.11">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.exceptions</ctl:link>
      <ctl:code>
         <xsl:if test="not(wms:Capability/wms:Exception/wms:Format[. = 'XML'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:resource-format">
      <ctl:param name="resource">The URL of a resource</ctl:param>
      <ctl:param name="advertised-format">The advertised format for the resource</ctl:param>
      <ctl:param name="actual-format">The actual format of the resource</ctl:param>
      <ctl:assertion>The MIME-type returned for {$resource} is {$advertised-format}.</ctl:assertion>
      <ctl:code>
         <xsl:if test="functions:mime-match($actual-format, $advertised-format) = 'false'">
            <ctl:message>Error: The actual MIME-type for '<xsl:value-of select="$resource"/>' is '<xsl:value-of select="$actual-format"/>'</ctl:message>
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:resource-size">
      <ctl:param name="resource">The URL of a resource</ctl:param>
      <ctl:param name="advertised-width">The advertised width for the resource</ctl:param>
      <ctl:param name="advertised-height">The advertised height for the resource</ctl:param>
      <ctl:param name="actual-width">The actual width of the resource</ctl:param>
      <ctl:param name="actual-height">The actual height of the resource</ctl:param>
      <ctl:assertion>The size of {$resource} is {$advertised-width}x{$advertised-height}.</ctl:assertion>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="string($actual-width) = '' or string($actual-height) = ''">
               <ctl:message>Error: Could not determine size of '<xsl:value-of select="$resource"/>'.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:when test="not($actual-width = $advertised-width and $actual-height = $advertised-height)">
               <ctl:message>Error: The actual size of '<xsl:value-of select="$resource"/>' is <xsl:value-of select="$actual-width"/>x<xsl:value-of select="$actual-height"/>
               </ctl:message>
               <ctl:fail/>
            </xsl:when>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:logourls">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The metadata for each of the LogoURL resources is correct.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.12">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.attribution</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(wms:Capability//wms:Layer/wms:Attribution/wms:LogoURL)">
               <ctl:message>No LogoURL elements</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:for-each select="wms:Capability//wms:Layer/wms:Attribution/wms:LogoURL">
                  <xsl:variable name="response">
                     <ctl:request>
                        <ctl:url>
                           <xsl:value-of select="wms:OnlineResource/@xlink:href"/>
                        </ctl:url>
                        <ctl:method>get</ctl:method>
                        <parsers:HTTPParser>
                           <parsers:parse>
                              <xsl:choose>
                                 <xsl:when test="functions:image-format(wms:Format) and @width and @height">
                                    <parsers:ImageParser>
                                       <parsers:width/>
                                       <parsers:height/>
                                    </parsers:ImageParser>
                                 </xsl:when>
                                 <xsl:otherwise>
                                    <parsers:NullParser/>
                                 </xsl:otherwise>
                              </xsl:choose>
                           </parsers:parse>
                        </parsers:HTTPParser>
                     </ctl:request>
                  </xsl:variable>
                  <ctl:call-test name="getcapabilities:resource-format">
                     <ctl:with-param name="resource" select="wms:OnlineResource/@xlink:href"
                                     label="the LogoURL resource"
                                     label-expr="concat('the LogoURL for Layer ', ../../wms:Name)"/>
                     <ctl:with-param name="advertised-format" select="wms:Format" label="the advertised format"
                                     label-expr="wms:Format"/>
                     <ctl:with-param name="actual-format"
                                     select="$response/response/headers/header[functions:to-lowercase(@name) = 'content-type']"/>
                  </ctl:call-test>
                  <xsl:if test="functions:image-format(wms:Format) and @width and @height">
                     <ctl:call-test name="getcapabilities:resource-size">
                        <ctl:with-param name="resource" select="wms:OnlineResource/@xlink:href"
                                        label="the LogoURL resource"
                                        label-expr="concat('the LogoURL for Layer ', ../../wms:Name)"/>
                        <ctl:with-param name="advertised-width" select="@width" label="the advertised width"
                                        label-expr="@width"/>
                        <ctl:with-param name="advertised-height" select="@height" label="the advertised height"
                                        label-expr="@height"/>
                        <ctl:with-param name="actual-width"
                                        select="$response/response/content/parsers:ImageParser/parsers:width"/>
                        <ctl:with-param name="actual-height"
                                        select="$response/response/content/parsers:ImageParser/parsers:height"/>
                     </ctl:call-test>
                  </xsl:if>
               </xsl:for-each>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:bbox-crs-advertised">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>There are no BoundingBoxes provided for a CRS that is not advertised.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.8">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.bbox</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability/wms:Layer//wms:BoundingBox[@CRS and not(ancestor-or-self::wms:Layer/wms:CRS = @CRS)]">
            <ctl:message>Layer <xsl:value-of select="../wms:Name"/> has a BoundingBox element for CRS <xsl:value-of select="@CRS"/>, but there is no corresponding CRS element.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:bbox-present">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Every named layer in the capabilities document has at least one BoundingBox element (direct or inherited).</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.8">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.bbox</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer[wms:Name and not(ancestor-or-self::wms:Layer/wms:BoundingBox)]">
            <ctl:message>Layer <xsl:value-of select="wms:Name"/> does not contain a BoundingBox element.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:bbox-distinct-crs">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>For each of the layer elements in the capabilities document, each BoundingBox on the layer states a different CRS.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.8">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.bbox</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer/wms:BoundingBox[@CRS = following-sibling::*/@CRS]">
            <ctl:message>Layer <xsl:value-of select="../wms:Name"/> has multiple BoundingBox elements for CRS <xsl:value-of select="@CRS"/>.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:crs-auto2-declarations">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>None of the CRS declarations in the AUTO2 namespace contain factor, longitude, or latitude variables.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 6.7.3.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.cs.layer.auto2</ctl:link>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.7">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.crs</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer/wms:CRS[starts-with(., 'AUTO2:') and contains(., ',')]">
            <ctl:message>Variables are supplied with CRS <xsl:value-of select="substring-before(., ',')"/> in Layer <xsl:value-of select="wms:Name"/>.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:crs-present">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Every named layer in the capabilities document has at least one CRS element that is either stated explicitly or inherited from a parent Layer.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.7">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.crs</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer[wms:Name and not(ancestor-or-self::wms:Layer/wms:CRS)]">
            <ctl:message>No CRS declared for Layer <xsl:value-of select="wms:Name"/>.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:crs-for-all-layers">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The root layer lists all CRSs that are common to all subsidiary layers.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.7">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.crs</ctl:link>
      <ctl:code>
         <xsl:variable name="named-layer-count" select="count(wms:Capability//wms:Layer[wms:Name])"/>
         <xsl:for-each select="wms:Capability//wms:Layer/wms:CRS">
            <xsl:variable name="crs" select="string(.)"/>
            <xsl:if test="count(wms:Capability//wms:Layer[wms:Name and ancestor-or-self::wms:Layer/wms:CRS=$crs]) = $named-layer-count and not(wms:Capability/wms:Layer[wms:CRS=$crs])">
               <ctl:message>Error: CRS <xsl:value-of select="$crs"/> is not listed on the root layer, but is common to all of the subsidiary named layers.</ctl:message>
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:dataurls">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>For each of the DataURL elements in the capabilities document, the MIME-type returned by the resource is the same as the Format element.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.15">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.dataurl</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(wms:Capability//wms:Layer/wms:DataURL)">
               <ctl:message>No DataURL elements</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:for-each select="wms:Capability//wms:Layer/wms:DataURL">
                  <xsl:variable name="response">
                     <ctl:request>
                        <ctl:url>
                           <xsl:value-of select="wms:OnlineResource/@xlink:href"/>
                        </ctl:url>
                        <ctl:method>get</ctl:method>
                        <parsers:HTTPParser>
                           <parsers:parse>
                              <parsers:NullParser/>
                           </parsers:parse>
                        </parsers:HTTPParser>
                     </ctl:request>
                  </xsl:variable>
                  <ctl:call-test name="getcapabilities:resource-format">
                     <ctl:with-param name="resource" select="wms:OnlineResource/@xlink:href"
                                     label="the DataURL resource"
                                     label-expr="concat('the DataURL for Layer ', ../wms:Name)"/>
                     <ctl:with-param name="advertised-format" select="wms:Format" label="the advertised format"
                                     label-expr="wms:Format"/>
                     <ctl:with-param name="actual-format"
                                     select="$response/response/headers/header[functions:to-lowercase(@name) = 'content-type']"/>
                  </ctl:call-test>
               </xsl:for-each>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:ex_geobbox-present">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Every named layer in the capabilities document has an EX_GeographicBoundingBox element that is either stated explicitly or inherited from a parent Layer.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.ex_geobbox</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer[wms:Name and not(ancestor-or-self::wms:Layer/wms:EX_GeographicBoundingBox)]">
            <ctl:message>No EX_GeographicBoundingBox declared for Layer <xsl:value-of select="wms:Name"/>.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:ex_geobbox-coordinates">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>For each EX_GeographicBoundingBox element, westBoundLongitude is less than eastBoundLongitude and southBoundLatitude is less than northBoundLatitude.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.ex_geobbox</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:EX_GeographicBoundingBox">
            <xsl:if test="xsd:float(wms:westBoundLongitude) &gt; xsd:float(wms:eastBoundLongitude) or xsd:float(wms:southBoundLatitude) &gt; xsd:float(wms:northBoundLatitude)">
               <ctl:message>
                  <xsl:text>The EX_GeographicBoundingBox for Layer </xsl:text>
                  <xsl:choose>
                     <xsl:when test="../wms:Name">
                        <xsl:value-of select="../wms:Name"/>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:text>titled "</xsl:text>
                        <xsl:value-of select="../wms:Title"/>
                        <xsl:text>"</xsl:text>
                     </xsl:otherwise>
                  </xsl:choose>
                  <xsl:text> is invalid.</xsl:text>
               </ctl:message>
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:featurelisturls">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>For each of the FeatureListURL elements in the capabilities document, the MIME-type returned by the resource is the same as the Format element.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.14">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.featurelisturl</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(wms:Capability//wms:Layer/wms:FeatureListURL)">
               <ctl:message>No FeatureListURL elements</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:for-each select="wms:Capability//wms:Layer/wms:FeatureListURL">
                  <xsl:variable name="response">
                     <ctl:request>
                        <ctl:url>
                           <xsl:value-of select="wms:OnlineResource/@xlink:href"/>
                        </ctl:url>
                        <ctl:method>get</ctl:method>
                        <parsers:HTTPParser>
                           <parsers:parse>
                              <parsers:NullParser/>
                           </parsers:parse>
                        </parsers:HTTPParser>
                     </ctl:request>
                  </xsl:variable>
                  <ctl:call-test name="getcapabilities:resource-format">
                     <ctl:with-param name="resource" select="wms:OnlineResource/@xlink:href"
                                     label="the FeatureListURL resource"
                                     label-expr="concat('the FeatureListURL for Layer ', ../wms:Name)"/>
                     <ctl:with-param name="advertised-format" select="wms:Format" label="the advertised format"
                                     label-expr="wms:Format"/>
                     <ctl:with-param name="actual-format"
                                     select="$response/response/headers/header[functions:to-lowercase(@name) = 'content-type']"/>
                  </ctl:call-test>
               </xsl:for-each>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:authorityurl-unique">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>There are no child Layer elements in the capabilities document that define an AuthorityURL with the same name attribute as one inherited from a parent layer.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.13">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.identifier_and_authorityurl</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer/wms:AuthorityURL[@name = ../ancestor::wms:Layer/wms:AuthorityURL/@name]">
            <ctl:message>The AuthorityURL <xsl:value-of select="@name"/> is redefined in Layer <xsl:value-of select="../wms:Name"/>.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:identifier-matches-authorityurl">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>There are no Layer elements in the capabilities document that declare an Identifier without also declaring or inheriting a corresponding AuthorityURL.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.13">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.identifier_and_authorityurl</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer/wms:Identifier[not(@authority = ../ancestor-or-self::wms:Layer/wms:AuthorityURL/@name)]">
            <ctl:message>There is no corresponding AuthorityURL for Identifier <xsl:value-of select="."/> in Layer <xsl:value-of select="../wms:Name"/>.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:metadataurls">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>For each of the MetadataURL elements in the capabilities document, the MIME-type returned by the resource is the same as the Format element.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.11">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.metadataurl</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(wms:Capability//wms:Layer/wms:MetadataURL)">
               <ctl:message>No MetadataURL elements</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:for-each select="wms:Capability//wms:Layer/wms:MetadataURL[wms:Format != '']">
                  <xsl:variable name="response">
                     <ctl:request>
                        <ctl:url>
                           <xsl:value-of select="wms:OnlineResource/@xlink:href"/>
                        </ctl:url>
                        <ctl:method>get</ctl:method>
                        <parsers:HTTPParser>
                           <parsers:parse>
                              <parsers:NullParser/>
                           </parsers:parse>
                        </parsers:HTTPParser>
                     </ctl:request>
                  </xsl:variable>
                  <ctl:call-test name="getcapabilities:resource-format">
                     <ctl:with-param name="resource" select="wms:OnlineResource/@xlink:href"
                                     label="the MetadataURL resource"
                                     label-expr="concat('the MetadataURL for Layer ', ../wms:Name)"/>
                     <ctl:with-param name="advertised-format" select="wms:Format" label="the advertised format"
                                     label-expr="wms:Format"/>
                     <ctl:with-param name="actual-format"
                                     select="$response/response/headers/header[functions:to-lowercase(@name) = 'content-type']"/>
                  </ctl:call-test>
               </xsl:for-each>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:style-unique">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>There are no child layers in the capabilities document that redefine a Style with the same name as one inherited from one of its parents.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.style</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer/wms:Style[wms:Name = ../ancestor::wms:Layer/wms:Style/wms:Name]">
            <ctl:message>The Style <xsl:value-of select="wms:Name"/> is redefined in Layer <xsl:value-of select="../wms:Name"/>.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:style-legendurls">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The metadata for each LegendURL resource in each Style element is correct.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.style</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(wms:Capability//wms:Layer/wms:Style/wms:LegendURL)">
               <ctl:message>No LegendURL elements</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:for-each select="wms:Capability//wms:Layer/wms:Style/wms:LegendURL">
                  <xsl:variable name="response">
                     <ctl:request>
                        <ctl:url>
                           <xsl:value-of select="wms:OnlineResource/@xlink:href"/>
                        </ctl:url>
                        <ctl:method>get</ctl:method>
                        <parsers:HTTPParser>
                           <parsers:parse>
                              <xsl:choose>
                                 <xsl:when test="functions:image-format(wms:Format) and @width and @height">
                                    <parsers:ImageParser>
                                       <parsers:width/>
                                       <parsers:height/>
                                    </parsers:ImageParser>
                                 </xsl:when>
                                 <xsl:otherwise>
                                    <parsers:NullParser/>
                                 </xsl:otherwise>
                              </xsl:choose>
                           </parsers:parse>
                        </parsers:HTTPParser>
                     </ctl:request>
                  </xsl:variable>
                  <ctl:call-test name="getcapabilities:resource-format">
                     <ctl:with-param name="resource" select="wms:OnlineResource/@xlink:href"
                                     label="the LegendURL resource"
                                     label-expr="concat('the LegendURL for Style ', ../wms:Name, ' in Layer ', ../../wms:Name)"/>
                     <ctl:with-param name="advertised-format" select="wms:Format" label="the advertised format"
                                     label-expr="wms:Format"/>
                     <ctl:with-param name="actual-format"
                                     select="$response/response/headers/header[functions:to-lowercase(@name) = 'content-type']"/>
                  </ctl:call-test>
                  <xsl:if test="functions:image-format(wms:Format) and @width and @height">
                     <ctl:call-test name="getcapabilities:resource-size">
                        <ctl:with-param name="resource" select="wms:OnlineResource/@xlink:href"
                                        label="the LegendURL resource"
                                        label-expr="concat('the LegendURL for Style ', ../wms:Name, ' in Layer ', ../../wms:Name)"/>
                        <ctl:with-param name="advertised-width" select="@width" label="the advertised width"
                                        label-expr="@width"/>
                        <ctl:with-param name="advertised-height" select="@height" label="the advertised height"
                                        label-expr="@height"/>
                        <ctl:with-param name="actual-width"
                                        select="$response/response/content/parsers:ImageParser/parsers:width"/>
                        <ctl:with-param name="actual-height"
                                        select="$response/response/content/parsers:ImageParser/parsers:height"/>
                     </ctl:call-test>
                  </xsl:if>
               </xsl:for-each>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:style-stylesheeturls">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The metadata for the StyleSheetURL resource in each Style element is correct.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.style</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(wms:Capability//wms:Layer/wms:Style/wms:StyleSheetURL)">
               <ctl:message>No StyleSheetURL elements</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:for-each select="wms:Capability//wms:Layer/wms:Style/wms:StyleSheetURL">
                  <xsl:variable name="response">
                     <ctl:request>
                        <ctl:url>
                           <xsl:value-of select="wms:OnlineResource/@xlink:href"/>
                        </ctl:url>
                        <ctl:method>get</ctl:method>
                        <parsers:HTTPParser>
                           <parsers:parse>
                              <parsers:NullParser/>
                           </parsers:parse>
                        </parsers:HTTPParser>
                     </ctl:request>
                  </xsl:variable>
                  <ctl:call-test name="getcapabilities:resource-format">
                     <ctl:with-param name="resource" select="wms:OnlineResource/@xlink:href"
                                     label="the StyleSheetURL resource"
                                     label-expr="concat('the StyleSheetURL for Style ', ../wms:Name, ' in Layer ', ../../wms:Name)"/>
                     <ctl:with-param name="advertised-format" select="wms:Format" label="the advertised format"
                                     label-expr="wms:Format"/>
                     <ctl:with-param name="actual-format"
                                     select="$response/response/headers/header[functions:to-lowercase(@name) = 'content-type']"/>
                  </ctl:call-test>
               </xsl:for-each>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:style-styleurls">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The metadata for the StyleURL resource in each Style element is correct.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.style</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(wms:Capability//wms:Layer/wms:Style/wms:StyleURL)">
               <ctl:message>No StyleURL elements</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:for-each select="wms:Capability//wms:Layer/wms:Style/wms:StyleURL">
                  <xsl:variable name="response">
                     <ctl:request>
                        <ctl:url>
                           <xsl:value-of select="wms:OnlineResource/@xlink:href"/>
                        </ctl:url>
                        <ctl:method>get</ctl:method>
                        <parsers:HTTPParser>
                           <parsers:parse>
                              <parsers:NullParser/>
                           </parsers:parse>
                        </parsers:HTTPParser>
                     </ctl:request>
                  </xsl:variable>
                  <ctl:call-test name="getcapabilities:resource-format">
                     <ctl:with-param name="resource" select="wms:OnlineResource/@xlink:href"
                                     label="the StyleURL resource"
                                     label-expr="concat('the StyleURL for Style ', ../wms:Name, ' in Layer ', ../../wms:Name)"/>
                     <ctl:with-param name="advertised-format" select="wms:Format" label="the advertised format"
                                     label-expr="wms:Format"/>
                     <ctl:with-param name="actual-format"
                                     select="$response/response/headers/header[functions:to-lowercase(@name) = 'content-type']"/>
                  </ctl:call-test>
               </xsl:for-each>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:dims-time">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>All declarations for the time dimension use 'ISO8601' for units.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0, Annex C, Section C.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.declaring</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer/wms:Dimension[functions:to-lowercase(@name) = 'time' and not(@units = 'ISO8601')]">
            <ctl:message>Error: The units attribute is not "ISO8601" for the time dimension in the layer titled "<xsl:value-of select="../wms:Title"/>".</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:dims-elevation-crs88">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>No declarations for the elevation dimension using the vertical datum CRS:88 use a unitSymbol other than 'm'.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0, Annex C, Section C.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.declaring</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer/wms:Dimension[functions:to-lowercase(@name) = 'elevation' and @units='CRS:88' and not(@unitSymbol='m')]">
            <ctl:message>Error: The unitSymbol attribute is not "m" for the elevation dimension using the vertical datum CRS:88 in the layer titled "<xsl:value-of select="../wms:Title"/>".</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:dims-no-redeclarations">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>There are no Dimension elements in the capabilities document that are redeclared using conflicting unit or unitSymbol attributes.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0, Annex C, Section C.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.declaring</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer/wms:Dimension">
            <xsl:variable name="name" select="functions:to-lowercase(@name)"/>
            <xsl:variable name="units" select="@units"/>
            <xsl:variable name="unitSymbol" select="@unitSymbol"/>
            <xsl:for-each select="../ancestor::wms:Layer/wms:Dimension[functions:to-lowercase(@name)=$name and not(@units=$units and @unitSymbol=$unitSymbol)]">
               <ctl:message>The Dimension <xsl:value-of select="@name"/> is redeclared in the layer titled "<xsl:value-of select="../wms:Title"/>" using conflicting units and/or unitSymbol attributes.</ctl:message>
               <ctl:fail/>
            </xsl:for-each>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getcapabilities:layer-extents">
      <ctl:context>WMS_Capabilities</ctl:context>
      <ctl:assertion>
    A layer extent must be consistent with its CRS reference. In particular, the 
    following constraints apply to every extent: 1) coordinates shall be listed 
    in accord with the CRS definition; 2) ordinates are represented as decimal 
    degrees; and 3) area &gt; 0. Currently only the commonly used geographic CRS 
    definitions CRS:84 and EPSG:4326 are supported.
  </ctl:assertion>
      <ctl:comment><![CDATA[See ISO 19128:2005, cl. 6.7.3: Layer CRS]]></ctl:comment>
      <ctl:comment><![CDATA[See ISO 19128:2005, cl. 6.7.4: Bounding boxes]]></ctl:comment>
      <ctl:code>
         <xsl:for-each select=".//wms:BoundingBox"><!-- select the nearest EX_GeographicBoundingBox --><xsl:variable name="geobbox"
                          select="(ancestor::wms:Layer/wms:EX_GeographicBoundingBox)[last()]"/>
            <xsl:choose>
               <xsl:when test="ends-with(@CRS, '4326')"><!-- lat,lon axis order --><xsl:if test="xsd:float(@minx) != xsd:float($geobbox/wms:southBoundLatitude)">
                     <ctl:message>[FAILURE] @minx != southBoundLatitude in BoundingBox[<xsl:value-of select="position()"/>].
            Expected value: <xsl:value-of select="$geobbox/wms:southBoundLatitude"/>
                     </ctl:message>
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="xsd:float(@miny) != xsd:float($geobbox/wms:westBoundLongitude)">
                     <ctl:message>[FAILURE] @miny != westBoundLongitude in BoundingBox[<xsl:value-of select="position()"/>].
            Expected value: <xsl:value-of select="$geobbox/wms:westBoundLongitude"/>
                     </ctl:message>
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="ends-with(@CRS, '84')"><!-- lon,lat axis order --><xsl:if test="xsd:float(@minx) != xsd:float($geobbox/wms:westBoundLongitude)">
                     <ctl:message>[FAILURE] @minx != westBoundLongitude in BoundingBox[<xsl:value-of select="position()"/>].
            Expected value: <xsl:value-of select="$geobbox/wms:westBoundLongitude"/>
                     </ctl:message>
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="xsd:float(@miny) != xsd:float($geobbox/wms:southBoundLatitude)">
                     <ctl:message>[FAILURE] @miny != southBoundLatitude in BoundingBox[<xsl:value-of select="position()"/>].
            Expected value: <xsl:value-of select="$geobbox/wms:southBoundLatitude"/>
                     </ctl:message>
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
            </xsl:choose>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
</ctl:package>
<ctl:package xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:fn="http://www.w3.org/2005/xpath-functions"
             xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:test name="dims:dims">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Support for dimensional data is correct.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="dims:missing-no-default"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="dims:missing-no-default">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a layer that has a dimension without a default value is requested without supplying the dimension parameter, the response is an exception with code=MissingDimensionValue.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section C.4.1">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.responses.incorrect</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="dimension"
                       select="//wms:Layer/wms:Dimension[not(@default) or @default='0' or @default='false'][1]"/>
         <xsl:variable name="layer"
                       select="string($dimension/../descendant-or-self::wms:Layer[wms:Name][1]/wms:Name)"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="$layer"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox"/>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No Named layers that have a dimension without a default value.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='MissingDimensionValue'])">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
</ctl:package>
<ctl:package xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:test name="getmap:getmap">
      <ctl:param name="exhaustive"/>
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The GetMap request behaves properly.</ctl:assertion>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(wms:Capability//wms:Layer/wms:Name)">
               <ctl:message>Error: No Named layers in capabilities XML.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:otherwise>
               <ctl:call-test name="getmap:bbox"/>
               <ctl:call-test name="getmap:crs">
                  <ctl:with-param name="exhaustive" select="$exhaustive"/>
               </ctl:call-test>
               <ctl:call-test name="getmap:exceptions"/>
               <ctl:call-test name="getmap:format"/>
               <ctl:call-test name="getmap:layers">
                  <ctl:with-param name="exhaustive" select="$exhaustive"/>
               </ctl:call-test>
               <ctl:call-test name="getmap:styles"/>
               <ctl:call-test name="getmap:transparent"/>
               <ctl:call-test name="getmap:width-and-height"/>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:bbox">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The BBOX parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getmap:bbox-direct"/>
         <ctl:call-test name="getmap:bbox-inherited"/>
         <ctl:call-test name="getmap:bbox-below-scale"/>
         <ctl:call-test name="getmap:bbox-above-scale"/>
         <ctl:call-test name="getmap:bbox-minx-gt-maxx"/>
         <ctl:call-test name="getmap:bbox-minx-eq-maxx"/>
         <ctl:call-test name="getmap:bbox-miny-gt-maxy"/>
         <ctl:call-test name="getmap:bbox-miny-eq-maxy"/>
         <ctl:call-test name="getmap:bbox-no-overlap"/>
         <ctl:call-test name="getmap:bbox-outside-crs"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:crs">
      <ctl:param name="exhaustive"/>
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The CRS parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getmap:crs-direct"/>
         <ctl:call-test name="getmap:crs-inherited"/>
         <ctl:call-test name="getmap:invalid-crs"/>
         <xsl:variable name="capabilities" select="."/>
         <xsl:if test="$exhaustive != 'exhaustive'">
            <ctl:for-each select="wms:Capability//wms:Layer//wms:CRS[not(. = ../preceding::wms:Layer/wms:CRS) and not(. = ../ancestor::wms:Layer/wms:CRS)]">
               <ctl:call-test name="getmap:each-crs">
                  <ctl:with-param name="capabilities" select="$capabilities"/>
                  <ctl:with-param name="layer" select="(../descendant-or-self::wms:Layer[wms:Name])[1]/wms:Name"/>
                  <ctl:with-param name="crs" select="." label="each CRS" label-expr="concat('CRS &#34;', ., '&#34;')"/>
               </ctl:call-test>
            </ctl:for-each>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:exceptions">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The EXCEPTIONS parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getmap:exceptions-default"/>
         <ctl:call-test name="getmap:exceptions-xml"/>
         <xsl:if test="wms:Capability/wms:Exception[wms:Format='INIMAGE']">
            <ctl:call-test name="getmap:exceptions-inimage-mime"/>
         </xsl:if>
         <xsl:if test="wms:Capability/wms:Exception[wms:Format='BLANK']">
            <ctl:call-test name="getmap:exceptions-blank-red"/>
            <ctl:call-test name="getmap:exceptions-blank-transparent"/>
            <ctl:call-test name="getmap:exceptions-blank-mime"/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:format">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The FORMAT parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getmap:invalid-format"/>
         <xsl:variable name="capabilities" select="."/>
         <ctl:for-each select="wms:Capability/wms:Request/wms:GetMap/wms:Format">
            <ctl:call-test name="getmap:each-format">
               <ctl:with-param name="capabilities" select="$capabilities"/>
               <ctl:with-param name="format" select="." label="each GetMap format"
                               label-expr="concat('format &#34;', ., '&#34;')"/>
            </ctl:call-test>
         </ctl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:layers">
      <ctl:param name="exhaustive"/>
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The LAYERS parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getmap:two-layers"/>
         <ctl:call-test name="getmap:three-layers"/>
         <ctl:call-test name="getmap:invalid-layer"/>
         <ctl:call-test name="getmap:first-layer-invalid"/>
         <ctl:call-test name="getmap:second-layer-invalid"/>
         <ctl:call-test name="getmap:layerlimit"/>
         <xsl:variable name="capabilities" select="."/>
         <ctl:for-each select="wms:Capability//wms:Layer/wms:Name">
            <xsl:choose>
               <xsl:when test="$exhaustive = 'exhaustive'">
                  <ctl:call-test name="getmap:each-layer-crs-combination">
                     <ctl:with-param name="capabilities" select="$capabilities"/>
                     <ctl:with-param name="layer" select="string(.)" label="each named layer"
                                     label-expr="concat('layer &#34;', ., '&#34;')"/>
                  </ctl:call-test>
               </xsl:when>
               <xsl:otherwise>
                  <ctl:call-test name="getmap:each-layer">
                     <ctl:with-param name="capabilities" select="$capabilities"/>
                     <ctl:with-param name="layer" select="string(.)" label="each named layer"
                                     label-expr="concat('layer &#34;', ., '&#34;')"/>
                  </ctl:call-test>
               </xsl:otherwise>
            </xsl:choose>
         </ctl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:styles">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The STYLES parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getmap:styles-direct"/>
         <ctl:call-test name="getmap:styles-inherited"/>
         <ctl:call-test name="getmap:two-styles"/>
         <ctl:call-test name="getmap:three-styles"/>
         <ctl:call-test name="getmap:invalid-style"/>
         <ctl:call-test name="getmap:styles-default-single-layer"/>
         <ctl:call-test name="getmap:styles-default-multiple-layers"/>
         <ctl:call-test name="getmap:styles-default-commas"/>
         <ctl:call-test name="getmap:styles-some-default"/>
         <ctl:call-test name="getmap:first-style-invalid"/>
         <ctl:call-test name="getmap:second-style-invalid"/>
         <xsl:variable name="capabilities" select="."/>
         <ctl:for-each select="wms:Capability//wms:Layer/wms:Style[not(wms:Name=../preceding::wms:Layer/wms:Style/wms:Name) and not(wms:Name=../ancestor::wms:Layer/wms:Style/wms:Name)]/wms:Name">
            <ctl:call-test name="getmap:each-style">
               <ctl:with-param name="capabilities" select="$capabilities"/>
               <ctl:with-param name="style" select="string(.)" label="each style"
                               label-expr="concat('style &#34;', ., '&#34;')"/>
            </ctl:call-test>
         </ctl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:transparent">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The TRANSPARENT parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getmap:transparent-default"/>
         <ctl:call-test name="getmap:transparent-false"/>
         <ctl:call-test name="getmap:transparent-opaque-layer"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:width-and-height">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The WIDTH and HEIGHT parameters behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getmap:large-size"/>
         <ctl:call-test name="getmap:small-size"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:bbox-direct">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains a layer whose BoundingBox is contained directly in the layer, then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:code>
         <xsl:variable name="layer"
                       select="string(wms:Capability/descendant::wms:Layer[wms:Name and wms:BoundingBox][1]/wms:Name)"/>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No named layers with a BoundingBox contained directly in the layer.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="string(wms:Capability/wms:Request/wms:GetMap/wms:Format[1])"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name" select="$layer"/>
                     <ctl:with-param name="preferred-crs"/>
                     <ctl:with-param name="preferred-bbox"/>
                     <ctl:with-param name="preferred-width">200</ctl:with-param>
                     <ctl:with-param name="preferred-height">200</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:bbox-inherited">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains a layer whose BoundingBox is inherited from a parent layer, then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:code>
         <xsl:variable name="layer"
                       select="string(wms:Capability/descendant::wms:Layer[wms:Name and not(wms:BoundingBox) and ancestor::wms:Layer/wms:BoundingBox][1]/wms:Name)"/>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No named layers with an inherited BoundingBox.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="string(wms:Capability/wms:Request/wms:GetMap/wms:Format[1])"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name" select="$layer"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">200</ctl:with-param>
                     <ctl:with-param name="preferred-height">200</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:bbox-below-scale">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a map is requested where the scale is below the appropriate range as indicated by the MinScaleDenominator element, then the response is not an exception.</ctl:assertion>
      <ctl:comment><![CDATA[Only tested if CRS:84 is available]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.9">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.scale_denominators</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="string(wms:Capability/wms:Request/wms:GetMap/wms:Format[1])"/>
         <xsl:variable name="layer"
                       select="string(wms:Capability/descendant::wms:Layer[wms:Name and ancestor-or-self::wms:Layer[wms:CRS='CRS:84'] and number(ancestor-or-self::wms:Layer/wms:MinScaleDenominator) &gt; 0][1]/wms:Name)"/>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No named CRS:84 layers with a minimum scale denominator greater than 0.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="min-scale-denominator"
                             select="number(wms:Capability/descendant::wms:Layer[wms:Name=$layer]/ancestor-or-self::wms:Layer/wms:MinScaleDenominator[number(.) &gt; 0][1])"/>
               <xsl:variable name="pixel-size" select="number(200)"/>
               <!-- Calculate the size for a bbox with a scale denominator that is 90% of the minimum scale denominator --><xsl:variable name="bbox-size"
                             select="number(($min-scale-denominator * .9 * 0.00028 * $pixel-size * 360) div (6378137 * 2 * 3.14159265))"/>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="CrS">CRS:84</ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$pixel-size"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="BbOx">0,0,<xsl:value-of select="$bbox-size"/>,<xsl:value-of select="$bbox-size"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$pixel-size"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer)"/>
                     </ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:bbox-above-scale">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a map is requested where the scale is above the appropriate range as indicated by the MaxScaleDenominator element, then the response is not an exception.</ctl:assertion>
      <ctl:comment><![CDATA[Only tested if CRS:84 is available]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.9">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.scale_denominators</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="string(wms:Capability/wms:Request/wms:GetMap/wms:Format[1])"/>
         <xsl:variable name="layer"
                       select="string(wms:Capability/descendant::wms:Layer[wms:Name and ancestor-or-self::wms:Layer[wms:CRS='CRS:84'] and ancestor-or-self::wms:Layer/wms:MaxScaleDenominator][1]/wms:Name)"/>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No named CRS:84 layers with a maximum scale denominator.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="max-scale-denominator"
                             select="number(wms:Capability/descendant::wms:Layer[wms:Name=$layer]/ancestor-or-self::wms:Layer/wms:MaxScaleDenominator[1])"/>
               <xsl:variable name="pixel-size" select="number(200)"/>
               <!-- Calculate the size for a bbox with a scale denominator that is 110% of the maximum scale denominator --><xsl:variable name="bbox-size"
                             select="number(($max-scale-denominator * 1.1 * 0.00028 * $pixel-size * 360) div (6378137 * 2 * 3.14159265))"/>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="CrS">CRS:84</ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$pixel-size"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="BbOx">0,0,<xsl:value-of select="$bbox-size"/>,<xsl:value-of select="$bbox-size"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$pixel-size"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer)"/>
                     </ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:bbox-minx-gt-maxx">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the BBOX parameter's minimum X is greater than the maximum X, then the server throws an exception.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="string(wms:Capability/wms:Request/wms:GetMap/wms:Format[1])"/>
         <xsl:variable name="layer"
                       select="string(//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="$layer"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox"/>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">200</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="StYlEs"/>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="BbOx">1,0,0,1</ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:bbox-minx-eq-maxx">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the BBOX parameter's minimum X is equal to the maximum X, then the server throws an exception.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="string(wms:Capability/wms:Request/wms:GetMap/wms:Format[1])"/>
         <xsl:variable name="layer"
                       select="string(//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="$layer"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox"/>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">200</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="BbOx">0,0,0,1</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:bbox-miny-gt-maxy">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the BBOX parameter's minimum Y is greater than the maximum Y, then the server throws an exception.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="string(wms:Capability/wms:Request/wms:GetMap/wms:Format[1])"/>
         <xsl:variable name="layer"
                       select="string(//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="$layer"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox"/>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">200</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="BbOx">0,1,1,0</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:bbox-miny-eq-maxy">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the BBOX parameter's minimum Y is equal to the maximum Y, then the server throws an exception.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="string(wms:Capability/wms:Request/wms:GetMap/wms:Format[1])"/>
         <xsl:variable name="layer"
                       select="string(//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="$layer"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox"/>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">200</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="BbOx">0,0,1,0</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:bbox-no-overlap">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a request contains a Bounding Box whose area does not overlap at all with the BoundingBox advertised, then the server returns empty content.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="geobbox"
                       select="wms:Capability/descendant::wms:Layer/wms:EX_GeographicBoundingBox[wms:westBoundLongitude &gt; -180 and wms:southBoundLongitude &gt; -90][1]"/>
         <xsl:variable name="x" select="$geobbox/wms:EX_GeographicBoundingBox/wms:westBoundLongitude"/>
         <xsl:variable name="y" select="$geobbox/wms:EX_GeographicBoundingBox/wms:southBoundLatitude"/>
         <xsl:variable name="layer"
                       select="string(wms:Capability//wms:Layer[wms:Name and ancestor-or-self::wms:Layer[wms:CRS='CRS:84'] and ancestor-or-self::wms:Layer[wms:EX_GeographicBoundingBox[wms:westBoundLongitude = $x and wms:southBoundLongitude = $y]]]/wms:Name)"/>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No named CRS:84 layers that don't cover the entire world.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="BbOx">-180,-90,<xsl:value-of select="$x"/>,<xsl:value-of select="$y"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">100</ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer)"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">100</ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="CrS">CRS:84</ctl:param>
                     <ctl:param name="StYlEs"/>
                     <parsers:ImageParser>
                        <parsers:model value="RGB">
                           <parsers:count bands="RGB" sample="all"/>
                        </parsers:model>
                     </parsers:ImageParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="not($response/parsers:ImageParser and count($response/parsers:ImageParser/parsers:model/parsers:count[@sample != '0xffffff']) = 0)">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:bbox-outside-crs">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a request contains a Bounding Box that falls outside of the defined range of the CRS, then the server returns empty content for the area.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer"
                       select="string(wms:Capability/descendant::wms:Layer[wms:Name and ancestor-or-self::wms:Layer[wms:CRS='CRS:84']][1]/wms:Name)"/>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No named CRS:84 layers.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="BbOx">-10,90,10,110</ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer)"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="CrS">CRS:84</ctl:param>
                     <ctl:param name="WiDtH">100</ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="HeIgHt">100</ctl:param>
                     <ctl:param name="StYlEs"/>
                     <parsers:ImageParser>
                        <parsers:model value="RGB">
                           <parsers:count bands="RGB" sample="all"/>
                        </parsers:model>
                     </parsers:ImageParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="not($response/parsers:ImageParser and count($response/parsers:ImageParser/parsers:model/parsers:count[@sample != '0xffffff']) = 0)">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:crs-direct">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains a single layer and a CRS where the CRS is contained directly in the layer in the capabilities document, then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.crs</ctl:link>
      <ctl:code>
         <xsl:variable name="crs"
                       select="string(wms:Capability/descendant::wms:Layer[wms:Name][last()]/wms:CRS[1])"/>
         <xsl:choose>
            <xsl:when test="$crs = ''">
               <ctl:message>Error: No Named layers with a CRS contained directly in the layer.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name"
                                     select="string(wms:Capability/descendant::wms:Layer[wms:CRS=$crs][last()]/wms:Name)"/>
                     <ctl:with-param name="preferred-crs" select="$crs"/>
                     <ctl:with-param name="preferred-bbox"/>
                     <ctl:with-param name="preferred-width">200</ctl:with-param>
                     <ctl:with-param name="preferred-height">200</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:crs-inherited">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains a single layer and a CRS where the CRS is inherited from a parent layer in the capabilities document, then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.crs</ctl:link>
      <ctl:code>
         <xsl:variable name="crs"
                       select="string(wms:Capability/descendant::wms:Layer[wms:Name][1]/ancestor::wms:Layer/wms:CRS[1])"/>
         <xsl:choose>
            <xsl:when test="$crs = ''">
               <ctl:message>Error: No Named layers with a CRS inherited from a parent layer.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name"
                                     select="string(wms:Capability/descendant::wms:Layer[wms:Name and ancestor::wms:Layer/wms:CRS=$crs][1]/wms:Name)"/>
                     <ctl:with-param name="preferred-crs" select="$crs"/>
                     <ctl:with-param name="preferred-bbox"/>
                     <ctl:with-param name="preferred-width">200</ctl:with-param>
                     <ctl:with-param name="preferred-height">200</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:invalid-crs">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the CRS parameter in a GetMap request contains a CRS that is not valid for any of the layers being requested, then the server shall throw a Service Exception (code=InvalidCRS).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.crs</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer"
                       select="string(wms:Capability/descendant::wms:Layer[wms:Name and wms:Name/text() != ''][1]/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>GET</ctl:method>
               <ctl:param name="StYlEs"/>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="HeIgHt">200</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="BbOx">-1,-1,1,1</ctl:param>
               <ctl:param name="CrS">UndefinedCRS</ctl:param>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <parsers:HTTPParser><!-- ignore entity body --><parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="content-type"
                       select="$response//header[functions:to-lowercase(@name) = 'content-type']"/>
         <xsl:choose>
            <xsl:when test="contains($content-type, '/xml')"><!-- repeat request and check entity body --><xsl:variable name="response2">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>GET</ctl:method>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="HeIgHt">200</ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">-1,-1,1,1</ctl:param>
                     <ctl:param name="CrS">UndefinedCRS</ctl:param>
                     <ctl:param name="WiDtH">200</ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer)"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="not($response2//ogc:ServiceExceptionReport/ogc:ServiceException[@code='InvalidCRS'])">
                  <ctl:message>[FAIL] Expected ServiceException with code 'InvalidCRS'.</ctl:message>
                  <ctl:fail/>
               </xsl:if>
            </xsl:when>
            <xsl:otherwise>
               <ctl:message>[FAIL] Expected XML media type, but received Content-Type: '<xsl:value-of select="$content-type"/>'</ctl:message>
               <ctl:fail/>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:each-layer-crs-combination">
      <ctl:param name="capabilities"/>
      <ctl:param name="layer"/>
      <ctl:assertion>For {$layer}, each of its CRSs is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.layers</ctl:link>
      <ctl:code>
         <ctl:for-each select="$capabilities/wms:Capability//wms:Layer[wms:Name=$layer]/ancestor-or-self::wms:Layer/wms:CRS[not(. = ../ancestor::wms:Layer/wms:CRS)]">
            <ctl:call-test name="getmap:each-crs">
               <ctl:with-param name="capabilities" select="$capabilities"/>
               <ctl:with-param name="layer" select="$layer"/>
               <ctl:with-param name="crs" select="." label="each CRS" label-expr="concat('CRS &#34;', ., '&#34;')"/>
            </ctl:call-test>
         </ctl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:each-crs">
      <ctl:param name="capabilities"/>
      <ctl:param name="crs"/>
      <ctl:param name="layer"/>
      <ctl:assertion>For {$crs}, when the CRS parameter is set to that CRS, then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.crs</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="$capabilities/wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="$capabilities/wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="$layer"/>
               <ctl:with-param name="preferred-crs" select="$crs"/>
               <ctl:with-param name="preferred-bbox"/>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No Named layers for CRS <xsl:value-of select="$crs"/>.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="$capabilities/wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@bbox)"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <xsl:for-each select="$layer-info/LayerInfo/dim">
                        <ctl:param name="{@param-name}">
                           <xsl:value-of select="functions:encode(.)"/>
                        </ctl:param>
                     </xsl:for-each>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:exceptions-default">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When an exception is raised without specifying the EXCEPTIONS parameter, then the response is a valid exception with a Content-type header of text/xml.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.11">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.exceptions</ctl:link>
      <ctl:link title="WMS 1.3.0 Annex E section E.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#schemas.service_exception</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="BbOx">0,0,1,1</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="LaYeRs">NonExistant</ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:XMLValidatingParser>
                        <parsers:schemas>
                           <parsers:schema type="url">http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd</parsers:schema>
                        </parsers:schemas>
                     </parsers:XMLValidatingParser>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="mime"
                       select="string($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'])"/>
         <xsl:if test="functions:mime-match($mime, 'text/xml') = 'false'">
            <ctl:message>Content-type header was <xsl:value-of select="$mime"/> instead of text/xml.</ctl:message>
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="not($response/response/content/ogc:ServiceExceptionReport)">
            <ctl:message>The results do not validate against the exceptions schema.</ctl:message>
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:exceptions-xml">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When an exception is raised and EXCEPTIONS=XML, then the response is a valid exception with a Content-type header of text/xml.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.11">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.exceptions</ctl:link>
      <ctl:link title="WMS 1.3.0 Annex E section E.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#schemas.service_exception</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="BbOx">0,0,1,1</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">NonExistant</ctl:param>
               <ctl:param name="ExCePtIoNs">XML</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="StYlEs"/>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:XMLValidatingParser>
                        <parsers:schemas>
                           <parsers:schema type="url">http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd</parsers:schema>
                        </parsers:schemas>
                     </parsers:XMLValidatingParser>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="mime"
                       select="string($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'])"/>
         <xsl:if test="functions:mime-match($mime, 'text/xml') = 'false'">
            <ctl:message>Content-type header was <xsl:value-of select="$mime"/> instead of text/xml.</ctl:message>
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="not($response/response/content/ogc:ServiceExceptionReport)">
            <ctl:message>The results do not validate against the exceptions schema.</ctl:message>
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:exceptions-inimage-mime">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When an exception is raised and EXCEPTIONS=INIMAGE, then the Content-type of the return header is the same as the FORMAT requested.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.11">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.exceptions</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="LaYeRs">NonExistant</ctl:param>
               <ctl:param name="BbOx">0,0,1,1</ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="ExCePtIoNs">INIMAGE</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:exceptions-blank-red">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When an exception is raised and EXCEPTIONS=BLANK, TRANSPRENT=FALSE, and BGCOLOR=0xFF0000, then the image returned contains only red pixels.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.11">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.exceptions</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">NonExistant</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="BbOx">0,0,1,1</ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="BgCoLoR">0xFF0000</ctl:param>
               <ctl:param name="ExCePtIoNs">BLANK</ctl:param>
               <ctl:param name="StYlEs"/>
               <parsers:ImageParser>
                  <parsers:model value="RGB">
                     <parsers:count bands="RGB" sample="0xff0000"/>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/parsers:ImageParser/parsers:model/parsers:count = 10000)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:exceptions-blank-transparent">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When an exception is raised and EXCEPTIONS=BLANK and TRANSPRENT=TRUE, then the image returned contains only transparent pixels.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.11">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.exceptions</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">NonExistant</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="TrAnSpArEnT">TRUE</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="ExCePtIoNs">BLANK</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="BbOx">0,0,1,1</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:count bands="A" sample="0x00"/>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/parsers:ImageParser/parsers:model/parsers:count = 10000)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:exceptions-blank-mime">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When an exception is raised and EXCEPTIONS=BLANK, then the Content-type of the return header is the same as the FORMAT requested.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.11">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.exceptions</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="StYlEs"/>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="BbOx">0,0,1,1</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="ExCePtIoNs">BLANK</ctl:param>
               <ctl:param name="LaYeRs">NonExistant</ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:invalid-format">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains a Format that is not advertised, then the server throws a Service Exception (code=InvalidFormat).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.7">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.format</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="FoRmAt">UnknownFormat</ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='InvalidFormat'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:each-format">
      <ctl:param name="capabilities"/>
      <ctl:param name="format"/>
      <ctl:assertion>For {$format}, when the FORMAT parameter is set to that format, the MIME type of the response matches that format.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.7">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.format</ctl:link>
      <ctl:code>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="$capabilities/wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string($capabilities/wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="$capabilities/wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($format)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $format) = 'false'">
            <xsl:choose>
               <xsl:when test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], 'image/png') = 'true'">
                  <xsl:if test="not(contains($format, 'image/png'))">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:otherwise>
                  <ctl:fail/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:two-layers">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains two valid layer names (separated by a comma), then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.layers</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info-1">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-2">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Streams']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-2/LayerInfo/@name)"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:three-layers">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains three valid layer names (separated by commas), then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.layers</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info-1">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-2">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Streams']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-3">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Bridges']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-2/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-3/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:invalid-layer">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the layer in a GetMap request is invalid, then the response is an exception (code=LayerNotDefined).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.layers</ctl:link>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.name</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">NonExistant</ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='LayerNotDefined'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:first-layer-invalid">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains two layers where the first is invalid and the second is valid, then the response is an exception (code=LayerNotDefined).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.layers</ctl:link>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.name</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="LaYeRs">NonExistant,<xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='LayerNotDefined'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:second-layer-invalid">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains two layers where the first is valid and the second is invalid, then the response is an exception (code=LayerNotDefined).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.layers</ctl:link>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.name</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>,NonExistant</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='LayerNotDefined'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:each-layer">
      <ctl:param name="capabilities"/>
      <ctl:param name="layer"/>
      <ctl:assertion>For {$layer}, when the LAYERS parameter is set to that layer name, the MIME type of the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.layers</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="$capabilities/wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="$capabilities/wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="$layer"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="$capabilities/wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <xsl:for-each select="$layer-info/LayerInfo/dim">
                  <ctl:param name="{@param-name}">
                     <xsl:value-of select="functions:encode(.)"/>
                  </ctl:param>
               </xsl:for-each>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:styles-direct">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains a single layer and a single style where the style is contained directly in the layer in the capabilities document, then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:variable name="style"
                       select="string(wms:Capability/descendant::wms:Layer[wms:Name][1]/wms:Style[1]/wms:Name)"/>
         <xsl:choose>
            <xsl:when test="$style = ''">
               <ctl:message>No named layers with a style contained directly in the layer.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <!-- select last layer in list --><ctl:with-param name="preferred-name"
                                     select="string(wms:Capability/descendant::wms:Layer[wms:Name and wms:Style/wms:Name = $style][last()]/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="StYlEs">
                        <xsl:value-of select="functions:encode($style)"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:styles-inherited">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains a single layer and a single style where the style is inherited by the layer in the capabilities document, then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:variable name="style"
                       select="string(wms:Capability//wms:Layer[wms:Name]/ancestor::wms:Layer/wms:Style[1]/wms:Name)"/>
         <xsl:choose>
            <xsl:when test="$style = ''">
               <ctl:message>No named layers with a style inherited from a parent layer.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name"
                                     select="string(wms:Capability//wms:Layer[wms:Name and wms:Style/wms:Name = $style]/wms:Name)"/>
                     <ctl:with-param name="preferred-crs"/>
                     <ctl:with-param name="preferred-bbox"/>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="StYlEs">
                        <xsl:value-of select="functions:encode($style)"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:two-styles">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains two valid layers and two valid styles (separated by a comma), then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:variable name="style"
                       select="string(wms:Capability/descendant::wms:Layer[wms:Name][1]/ancestor-or-self::wms:Layer[1]/wms:Style[1]/wms:Name)"/>
         <xsl:choose>
            <xsl:when test="$style = ''">
               <ctl:message>No named layers with a style.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <!-- select last layer in list --><ctl:with-param name="preferred-name"
                                     select="string(wms:Capability/descendant::wms:Layer[wms:Name and wms:Style/wms:Name = $style][last()]/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="StYlEs">
                        <xsl:value-of select="functions:encode($style)"/>,<xsl:value-of select="functions:encode($style)"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:message>FAILURE: Unexpected Content-Type header value.</ctl:message>
                  <ctl:message>Expected <xsl:value-of select="$image-format"/> but received <xsl:value-of select="$response/response/headers/header[functions:to-lowercase(@name) = 'content-type']"/>
                  </ctl:message>
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:three-styles">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains three valid layers and three valid styles (separated by commas), then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:variable name="style"
                       select="string(wms:Capability/descendant::wms:Layer[wms:Name][1]/ancestor-or-self::wms:Layer[1]/wms:Style[1]/wms:Name)"/>
         <xsl:choose>
            <xsl:when test="$style = ''">
               <ctl:message>No named layers with a style.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <!-- select last layer in list --><ctl:with-param name="preferred-name"
                                     select="string(wms:Capability/descendant::wms:Layer[wms:Name and wms:Style/wms:Name = $style][last()]/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="StYlEs">
                        <xsl:value-of select="functions:encode($style)"/>,<xsl:value-of select="functions:encode($style)"/>,<xsl:value-of select="functions:encode($style)"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:message>FAILURE: Unexpected Content-Type header value.</ctl:message>
                  <ctl:message>Expected <xsl:value-of select="$image-format"/> but received <xsl:value-of select="$response/response/headers/header[functions:to-lowercase(@name) = 'content-type']"/>
                  </ctl:message>
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:invalid-style">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains an unadvertised Style, then the response is an exception (code=StyleNotDefined).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="StYlEs">UndefinedStyle</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='StyleNotDefined'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:styles-default-single-layer">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains a single layer and a null style value (as in "STYLES="), then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:styles-default-multiple-layers">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains multiple layers and requests all layers to be shown in the default style by using a single null value (as in "STYLES="), then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info-1">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Bridges']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-2">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:RoadSegments']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-3">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:DividedRoutes']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-4">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Buildings']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-2/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-3/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-4/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="StYlEs"/>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:styles-default-commas">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains multiple layers and requests all layers to be shown in the default style by using null values between commas (as in "STYLES=,,,"), then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info-1">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Bridges']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-2">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:RoadSegments']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-3">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:DividedRoutes']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-4">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="string(wms:Capability//wms:Layer[wms:Title='cite:Buildings']/wms:Name)"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-2/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-3/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-4/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="StYlEs">,,,</ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@bbox"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:styles-some-default">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains multiple layers and a mixture of named and default styles (as in "STYLES=style1,,style2,,"), then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:variable name="style"
                       select="(//wms:Layer[wms:Name]/ancestor-or-self::wms:Layer/wms:Style[1]/wms:Name)[1]/text()"/>
         <xsl:choose>
            <xsl:when test="empty($style)">
               <ctl:message>No named layers with a style.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <!-- select last layer in list --><ctl:with-param name="preferred-name"
                                     select="string(wms:Capability//wms:Layer[wms:Name and wms:Style/wms:Name = $style and position()=last()]/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="layer-info-1">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name"
                                     select="string(wms:Capability//wms:Layer[wms:Title='cite:Bridges']/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="layer-info-2">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name"
                                     select="string(wms:Capability//wms:Layer[wms:Title='cite:RoadSegments']/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="layer-info-3">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name"
                                     select="string(wms:Capability//wms:Layer[wms:Title='cite:DividedRoutes']/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-2/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-3/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="StYlEs">
                        <xsl:value-of select="functions:encode($style)"/>,,<xsl:value-of select="functions:encode($style)"/>,,</ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:first-style-invalid">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains two layers, where the first style is not valid and the second style is, then the response is an exception (code=StyleNotDefined).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:variable name="style"
                       select="(//wms:Layer[wms:Name]/ancestor-or-self::wms:Layer/wms:Style[1]/wms:Name)[1]/text()"/>
         <xsl:choose>
            <xsl:when test="empty($style)">
               <ctl:message>No named layers with a style.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="styled-layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <!-- select last layer in list --><ctl:with-param name="preferred-name"
                                     select="string(//wms:Layer[wms:Name and wms:Style/wms:Name = $style and position()=last()]/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="other-layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name"
                                     select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$styled-layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$styled-layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="StYlEs">UndefinedStyle,<xsl:value-of select="functions:encode($style)"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($other-layer-info/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($styled-layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$styled-layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($styled-layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='StyleNotDefined'])">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:second-style-invalid">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains two layers, where the first style is valid and the second style is not, then the response is an exception (code=StyleNotDefined).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:variable name="style"
                       select="(//wms:Layer[wms:Name]/ancestor-or-self::wms:Layer/wms:Style[1]/wms:Name)[1]/text()"/>
         <xsl:choose>
            <xsl:when test="empty($style)">
               <ctl:message>No named layers with a style.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="styled-layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <!-- select last layer in list --><ctl:with-param name="preferred-name"
                                     select="string(//wms:Layer[wms:Name and wms:Style/wms:Name = $style and position()=last()]/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="other-layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name"
                                     select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="StYlEs">
                        <xsl:value-of select="functions:encode($style)"/>,UndefinedStyle</ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$styled-layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$styled-layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$styled-layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($styled-layer-info/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($other-layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($styled-layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='StyleNotDefined'])">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:each-style">
      <ctl:param name="capabilities"/>
      <ctl:param name="style"/>
      <ctl:assertion>For {$style}, when the STYLES parameter is set to that style name, the MIME type of the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.styles</ctl:link>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="$style = ''">
               <ctl:message>No named layers with a style contained directly in the layer.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="$capabilities/wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="$capabilities/wms:Capability/wms:Layer"/>
                     <!-- select last layer in list --><ctl:with-param name="preferred-name"
                                     select="string($capabilities/descendant::wms:Layer[wms:Name and wms:Style/wms:Name = $style][last()]/wms:Name)"/>
                     <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
                     <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="$capabilities/wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="StYlEs">
                        <xsl:value-of select="functions:encode($style)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@bbox)"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:transparent-default">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request is made with no TRANSPARENT parameter and a FORMAT that supports transparency over a layer that is not opaque, then the response contains no transparent pixels.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.9">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.transparent</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name">
                  <xsl:choose>
                     <xsl:when test="wms:Capability//wms:Layer[wms:Title='cite:Lakes' and functions:boolean-as-integer(@opaque)=0]">
                        <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:value-of select="string(wms:Capability/descendant::wms:Layer[wms:Name and functions:boolean-as-integer(@opaque)=0][1]/wms:Name)"/>
                     </xsl:otherwise>
                  </xsl:choose>
               </ctl:with-param>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:count bands="A" sample="0x00"/>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/parsers:ImageParser/parsers:model/parsers:count)">
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="number($response/parsers:ImageParser/parsers:model/parsers:count) &gt; 0">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:transparent-false">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request is made with TRANSPARENT=FALSE and a FORMAT that supports transparency over a layer that is not opaque, then the response contains no transparent pixels.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.9">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.transparent</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name">
                  <xsl:choose>
                     <xsl:when test="wms:Capability//wms:Layer[wms:Title='cite:Lakes' and functions:boolean-as-integer(@opaque)=0]">
                        <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:value-of select="string(wms:Capability/descendant::wms:Layer[wms:Name and functions:boolean-as-integer(@opaque)=0][1]/wms:Name)"/>
                     </xsl:otherwise>
                  </xsl:choose>
               </ctl:with-param>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="TrAnSpArEnT">FALSE</ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:count bands="A" sample="0x00"/>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/parsers:ImageParser/parsers:model/parsers:count)">
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="number($response/parsers:ImageParser/parsers:model/parsers:count) &gt; 0">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:transparent-opaque-layer">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Clients may request TRANSPARENT=TRUE on a layer that is opaque.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.9">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.transparent</ctl:link>
      <ctl:code>
         <xsl:variable name="layer"
                       select="string(wms:Capability//wms:Layer[wms:Name and functions:boolean-as-integer(@opaque)=1][1]/wms:Name)"/>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No named opaque layers.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name" select="$layer"/>
                     <ctl:with-param name="preferred-crs"/>
                     <ctl:with-param name="preferred-bbox"/>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="TrAnSpArEnT">TRUE</ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:large-size">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a request is made for a large map (1024x768 or largest map supported), the image returned is exactly the size requested.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.8">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.width_height</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif') or starts-with(., 'image/jpeg')][1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name">
                  <xsl:choose>
                     <xsl:when test="wms:Capability//wms:Layer[wms:Title='cite:Lakes']">
                        <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:value-of select="string(wms:Capability/descendant::wms:Layer[not(number(@fixedWidth) &gt; 0) and not(number(@fixedHeight) &gt; 0)][1]/wms:Name)"/>
                     </xsl:otherwise>
                  </xsl:choose>
               </ctl:with-param>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">
                  <xsl:choose>
                     <xsl:when test="wms:Service/wms:MaxWidth">
                        <xsl:value-of select="number(wms:Service/wms:MaxWidth)"/>
                     </xsl:when>
                     <xsl:otherwise>1024</xsl:otherwise>
                  </xsl:choose>
               </ctl:with-param>
               <ctl:with-param name="preferred-height">
                  <xsl:choose>
                     <xsl:when test="wms:Service/wms:MaxHeight">
                        <xsl:value-of select="number(wms:Service/wms:MaxHeight)"/>
                     </xsl:when>
                     <xsl:otherwise>768</xsl:otherwise>
                  </xsl:choose>
               </ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="StYlEs"/>
               <parsers:ImageParser>
                  <parsers:height/>
                  <parsers:width/>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="number($response/parsers:ImageParser/parsers:width) = -1 or number($response/parsers:ImageParser/parsers:height) = -1">
               <ctl:message>Error: Could not read the image size.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:when test="not(number($response/parsers:ImageParser/parsers:width) = $layer-info/LayerInfo/@width and number($response/parsers:ImageParser/parsers:height) = $layer-info/LayerInfo/@height)">
               <ctl:message>Requested a <xsl:value-of select="$layer-info/LayerInfo/@width"/>x<xsl:value-of select="$layer-info/LayerInfo/@height"/> map, but got a <xsl:value-of select="number($response/parsers:ImageParser/parsers:width)"/>x<xsl:value-of select="number($response/parsers:ImageParser/parsers:height)"/> map.</ctl:message>
               <ctl:fail/>
            </xsl:when>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:small-size">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a request is made with WIDTH=8 and HEIGHT=5, the image returned is exactly the size requested.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.8">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.width_height</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif') or starts-with(., 'image/jpeg')][1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name">
                  <xsl:choose>
                     <xsl:when test="wms:Capability//wms:Layer[wms:Title='cite:Lakes']">
                        <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:value-of select="string(wms:Capability/descendant::wms:Layer[not(number(@fixedWidth) &gt; 0) and not(number(@fixedHeight) &gt; 0)][1]/wms:Name)"/>
                     </xsl:otherwise>
                  </xsl:choose>
               </ctl:with-param>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">8</ctl:with-param>
               <ctl:with-param name="preferred-height">5</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="StYlEs"/>
               <parsers:ImageParser>
                  <parsers:height/>
                  <parsers:width/>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="number($response/parsers:ImageParser/parsers:width) = -1 or number($response/parsers:ImageParser/parsers:height) = -1">
               <ctl:message>Error: Could not read the image size.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:when test="not(number($response/parsers:ImageParser/parsers:width) = $layer-info/LayerInfo/@width and number($response/parsers:ImageParser/parsers:height) = $layer-info/LayerInfo/@height)">
               <ctl:message>Requested a <xsl:value-of select="$layer-info/LayerInfo/@width"/>x<xsl:value-of select="$layer-info/LayerInfo/@height"/> map, but got a <xsl:value-of select="number($response/parsers:ImageParser/parsers:width)"/>x<xsl:value-of select="number($response/parsers:ImageParser/parsers:height)"/> map.</ctl:message>
               <ctl:fail/>
            </xsl:when>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getmap:layerlimit">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>If the service advertises a LayerLimit, it can handle a GetMap request that includes that many layers.</ctl:assertion>
      <ctl:comment><![CDATA[Multiple instances of the same layer are used to come up with enough layers to test this.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.3.3.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.layers</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif') or starts-with(., 'image/jpeg')][1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name">
                  <xsl:choose>
                     <xsl:when test="wms:Capability//wms:Layer[wms:Title='cite:Lakes']">
                        <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name)"/>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:value-of select="string(wms:Capability/descendant::wms:Layer[not(number(@fixedWidth) &gt; 0) and not(number(@fixedHeight) &gt; 0)][1]/wms:Name)"/>
                     </xsl:otherwise>
                  </xsl:choose>
               </ctl:with-param>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">-0.0025,-0.0025,0.0025,0.0025</ctl:with-param>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-name">
            <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
         </xsl:variable>
         <xsl:variable name="size">
            <xsl:value-of select="wms:Service/wms:LayerLimit"/>
         </xsl:variable>
         <xsl:if test="not($size='')">
            <xsl:variable name="layer-list">
               <xsl:value-of select="functions:encode($layer-name)"/>
               <xsl:for-each select="2 to $size">
                  <xsl:text>,</xsl:text>
                  <xsl:value-of select="functions:encode($layer-name)"/>
               </xsl:for-each>
            </xsl:variable>
            <xsl:variable name="response">
               <ctl:request>
                  <ctl:url>
                     <xsl:value-of select="wms:Capability//wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                  </ctl:url>
                  <ctl:method>get</ctl:method>
                  <ctl:param name="ReQuEsT">GetMap</ctl:param>
                  <ctl:param name="WiDtH">
                     <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                  </ctl:param>
                  <ctl:param name="VeRsIoN">
                     <xsl:value-of select="functions:version()"/>
                  </ctl:param>
                  <ctl:param name="BbOx">
                     <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                  </ctl:param>
                  <ctl:param name="CrS">
                     <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                  </ctl:param>
                  <ctl:param name="HeIgHt">
                     <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                  </ctl:param>
                  <ctl:param name="StYlEs"/>
                  <ctl:param name="FoRmAt">
                     <xsl:value-of select="functions:encode($image-format)"/>
                  </ctl:param>
                  <ctl:param name="LaYeRs">
                     <xsl:value-of select="$layer-list"/>
                  </ctl:param>
                  <parsers:HTTPParser>
                     <parsers:parse>
                        <parsers:NullParser/>
                     </parsers:parse>
                  </parsers:HTTPParser>
               </ctl:request>
            </xsl:variable>
            <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
               <ctl:fail/>
            </xsl:if>
         </xsl:if>
      </ctl:code>
   </ctl:test>
</ctl:package>
<ctl:package xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:test name="getfeatureinfo:getfeatureinfo">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The GetFeatureInfo request behaves properly.</ctl:assertion>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get)">
               <ctl:message>The GetFeatureInfo request is not supported.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <ctl:call-test name="getfeatureinfo:exceptions"/>
               <xsl:choose>
                  <xsl:when test="not(wms:Capability//wms:Layer[@queryable and functions:boolean-as-integer(@queryable) = 1]/wms:Name)">
                     <ctl:message>No queryable layers in capabilities XML.</ctl:message>
                  </xsl:when>
                  <xsl:otherwise>
                     <ctl:call-test name="getfeatureinfo:info_format"/>
                     <ctl:call-test name="getfeatureinfo:i-and-j"/>
                     <ctl:call-test name="getfeatureinfo:query-layers"/>
                  </xsl:otherwise>
               </xsl:choose>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:exceptions">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The EXCEPTIONS parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getfeatureinfo:exceptions-default"/>
         <ctl:call-test name="getfeatureinfo:exceptions-xml"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:info_format">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The FORMAT parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getfeatureinfo:invalid-info_format"/>
         <xsl:variable name="capabilities" select="."/>
         <ctl:for-each select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format">
            <ctl:call-test name="getfeatureinfo:each-info_format">
               <ctl:with-param name="capabilities" select="$capabilities"/>
               <ctl:with-param name="format" select="." label="each GetFeatureInfo format"
                               label-expr="concat('format &#34;', ., '&#34;')"/>
            </ctl:call-test>
         </ctl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:i-and-j">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The I and J parameters behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getfeatureinfo:invalid-i"/>
         <ctl:call-test name="getfeatureinfo:invalid-j"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:query-layers">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The QUERY_LAYERS parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="getfeatureinfo:two-query_layers"/>
         <ctl:call-test name="getfeatureinfo:three-query_layers"/>
         <ctl:call-test name="getfeatureinfo:less-query_layers"/>
         <ctl:call-test name="getfeatureinfo:invalid-query_layers"/>
         <ctl:call-test name="getfeatureinfo:query_layers-not-queryable"/>
         <xsl:variable name="capabilities" select="."/>
         <ctl:for-each select="wms:Capability//wms:Layer[wms:Name and @queryable and functions:boolean-as-integer(@queryable) = 1]/wms:Name">
            <ctl:call-test name="getfeatureinfo:each-queryable-layer">
               <ctl:with-param name="capabilities" select="$capabilities"/>
               <ctl:with-param name="layer" select="string(.)" label="each queryable layer"
                               label-expr="concat('layer &#34;', ., '&#34;')"/>
            </ctl:call-test>
         </ctl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:exceptions-default">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When an exception is raised and the EXCEPTIONS parameter is absent from the request, then the response is a valid exception with a Content-type header of text/xml.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.8">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.exceptions</ctl:link>
      <ctl:link title="WMS 1.3.0 Annex E section E.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#schemas.service_exception</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="info-format"
                       select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="StYlEs"/>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="J">100</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="QuErY_LaYeRs">UndefinedLayer</ctl:param>
               <ctl:param name="I">100</ctl:param>
               <ctl:param name="LaYeRs">UndefinedLayer</ctl:param>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="HeIgHt">200</ctl:param>
               <ctl:param name="BbOx">0,0,1,1</ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:XMLValidatingParser>
                        <parsers:schemas>
                           <parsers:schema type="url">http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd</parsers:schema>
                        </parsers:schemas>
                     </parsers:XMLValidatingParser>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="mime"
                       select="string($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'])"/>
         <xsl:if test="functions:mime-match($mime, 'text/xml') = 'false'">
            <ctl:message>Content-type header was <xsl:value-of select="$mime"/> instead of text/xml.</ctl:message>
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="not($response/response/content/ogc:ServiceExceptionReport)">
            <ctl:message>The results do not validate against the exceptions schema.</ctl:message>
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:exceptions-xml">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When an exception is raised and EXCEPTIONS=XML, then the response is a valid exception with a Content-type header of text/xml.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.8">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.exceptions</ctl:link>
      <ctl:link title="WMS 1.3.0 Annex E section E.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#schemas.service_exception</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="info-format"
                       select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="ExCePtIoNs">XML</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="QuErY_LaYeRs">UndefinedLayer</ctl:param>
               <ctl:param name="J">100</ctl:param>
               <ctl:param name="BbOx">0,0,1,1</ctl:param>
               <ctl:param name="I">100</ctl:param>
               <ctl:param name="LaYeRs">UndefinedLayer</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="HeIgHt">200</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:XMLValidatingParser>
                        <parsers:schemas>
                           <parsers:schema type="url">http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd</parsers:schema>
                        </parsers:schemas>
                     </parsers:XMLValidatingParser>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="mime"
                       select="string($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'])"/>
         <xsl:if test="functions:mime-match($mime, 'text/xml') = 'false'">
            <ctl:message>Content-type header was <xsl:value-of select="$mime"/> instead of text/xml.</ctl:message>
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="not($response/response/content/ogc:ServiceExceptionReport)">
            <ctl:message>The results do not validate against the exceptions schema.</ctl:message>
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:invalid-info_format">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetFeatureInfo request is made with an invalid INFO_FORMAT parameter, then the server returns an exception (code=InvalidFormat).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.info_format</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="I">60</ctl:param>
               <ctl:param name="J">60</ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="InFo_fOrMaT">InvalidInfoFormat</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='InvalidFormat'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:each-info_format">
      <ctl:param name="capabilities"/>
      <ctl:param name="format"/>
      <ctl:assertion>For {$format}, when the INFO_FORMAT parameter is set to that format, the MIME type of the response matches that format.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.info_format</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="$capabilities/wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="$capabilities/wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="$capabilities/wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="$capabilities/wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="I">60</ctl:param>
               <ctl:param name="J">60</ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($format)"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:invalid-i">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetFeatureInfo request is made with an invalid I parameter, then the response is an exception (code=InvalidPoint).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.7">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.i_j</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="info-format"
                       select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="I">
                  <xsl:value-of select="number($layer-info/LayerInfo/@width) + 50"/>
               </ctl:param>
               <ctl:param name="J">60</ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='InvalidPoint'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:invalid-j">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetFeatureInfo request is made with an invalid J parameter, then the response is an exception (code=InvalidPoint).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.7">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.i_j</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="info-format"
                       select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="I">60</ctl:param>
               <ctl:param name="J">
                  <xsl:value-of select="number($layer-info/LayerInfo/@height) + 50"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='InvalidPoint'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:two-query_layers">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetFeatureInfo request contains two layers, then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.query_layers</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="info-format"
                       select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
         <xsl:variable name="layer-info-1">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:NamedPlaces']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-2">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-2/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="I">60</ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="J">60</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-2/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $info-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:three-query_layers">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetFeatureInfo request contains three layers, then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.query_layers</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="info-format"
                       select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
         <xsl:variable name="layer-info-1">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:NamedPlaces']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-2">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-3">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:Forests']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-2/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-3/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="I">60</ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="J">60</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-2/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-3/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $info-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:less-query_layers">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetFeatureInfo request contains fewer layers in the QUERY_LAYERS parameter than it does in the LAYERS parameter, then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.query_layers</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="info-format"
                       select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
         <xsl:variable name="layer-info-1">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:NamedPlaces']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-2">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:Streams']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="layer-info-3">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-2/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-3/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="I">60</ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info-1/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="J">60</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info-1/LayerInfo/@name)"/>,<xsl:value-of select="functions:encode($layer-info-3/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $info-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:invalid-query_layers">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a layer requested is not contained in the Capabilities XML of the WMS, then the server issues a Service Exception (code=LayerNotDefined).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.query_layers</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="info-format"
                       select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name"
                               select="wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox">0,-0.0020,0.0040,0</ctl:with-param>
               <ctl:with-param name="preferred-width">200</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="QuErY_LaYeRs">InvalidLayer</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="I">60</ctl:param>
               <ctl:param name="J">60</ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='LayerNotDefined'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:query_layers-not-queryable">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When GetFeatureInfo is requested on a Layer that is not queryable, then the server issues a Service Exception (code=LayerNotQueryable).</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.query_layers</ctl:link>
      <ctl:link title="WMS 1.3.0 section 7.2.4.7.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_attributes.queryable</ctl:link>
      <ctl:code>
         <xsl:variable name="layer"
                       select="(//wms:Layer[functions:boolean-as-integer(@queryable) = 0][1]/wms:Name)[1]"/>
         <xsl:choose>
            <xsl:when test="empty($layer)">
               <ctl:message>No non-queryable layers found.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="image-format"
                             select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
               <xsl:variable name="info-format"
                             select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
               <xsl:variable name="layer-info">
                  <ctl:call-function name="functions:layer-info">
                     <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
                     <ctl:with-param name="preferred-name" select="string($layer)"/>
                     <ctl:with-param name="preferred-crs"/>
                     <ctl:with-param name="preferred-bbox"/>
                     <ctl:with-param name="preferred-width">100</ctl:with-param>
                     <ctl:with-param name="preferred-height">100</ctl:with-param>
                  </ctl:call-function>
               </xsl:variable>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="QuErY_LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="I">50</ctl:param>
                     <ctl:param name="J">50</ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="InFo_fOrMaT">
                        <xsl:value-of select="functions:encode($info-format)"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='LayerNotQueryable'])">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="getfeatureinfo:each-queryable-layer">
      <ctl:param name="capabilities"/>
      <ctl:param name="layer"/>
      <ctl:assertion>For {$layer}, when the QUERY_LAYERS parameter is set to that layer name, the MIME type of the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.query_layers</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="$capabilities/wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="info-format"
                       select="$capabilities/wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:queryable-layer-info">
               <ctl:with-param name="root-layer" select="$capabilities/wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="$layer"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox"/>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="$capabilities/wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="WiDtH">
                  <xsl:value-of select="$layer-info/LayerInfo/@width"/>
               </ctl:param>
               <ctl:param name="HeIgHt">
                  <xsl:value-of select="$layer-info/LayerInfo/@height"/>
               </ctl:param>
               <ctl:param name="I">50</ctl:param>
               <ctl:param name="BbOx">
                  <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="J">50</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <xsl:for-each select="$layer-info/LayerInfo/dim">
                  <ctl:param name="{@param-name}">
                     <xsl:value-of select="functions:encode(.)"/>
                  </ctl:param>
               </xsl:for-each>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $info-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
</ctl:package>
<ctl:package xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:test name="recommendations:recommendations">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>If the "Check Recommendations" option was selected, the server supports fuctionality which is recommended in the spec, but not required.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="recommendations:service-keywords"/>
         <ctl:call-test name="recommendations:service-contact-info"/>
         <ctl:call-test name="recommendations:png-getmap-format"/>
         <ctl:call-test name="recommendations:layer-abstracts"/>
         <ctl:call-test name="recommendations:layer-keywordlists"/>
         <ctl:call-test name="recommendations:layer-crs"/>
         <ctl:call-test name="recommendations:metadataurls"/>
         <ctl:call-test name="recommendations:dims-no-whitespace"/>
         <ctl:call-test name="recommendations:dims-defaults"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="recommendations:service-keywords">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The capabilities document includes a list of keywords or keyword phrases describing the server.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.general_metadata</ctl:link>
      <ctl:code>
         <xsl:if test="not(boolean(wms:Service/wms:KeywordList/wms:Keyword))">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="recommendations:service-contact-info">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The capabilities document includes contact information.</ctl:assertion>
      <ctl:comment><![CDATA[Makes sure an address, phone number, or email address is provided.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.2.4.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.general_metadata</ctl:link>
      <ctl:code>
         <xsl:if test="not(boolean(wms:Service/wms:ContactInformation[wms:ContactAddress!='' or wms:ContactVoiceTelephone!='' or wms:ContactEmailAddress!='']))">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="recommendations:png-getmap-format">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The server advertises the image/png format for the GetMap operation.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.capability_metadata</ctl:link>
      <ctl:link title="WMS 1.3.0 section 6.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.output_formats</ctl:link>
      <ctl:code>
         <xsl:if test="not(wms:Capability/wms:Request/wms:GetMap/wms:Format[. = 'image/png'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="recommendations:layer-abstracts">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Each Layer in the capabilities document contains an abstract.</ctl:assertion>
      <ctl:comment><![CDATA[Only applied to layers with a name]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.abstract_and_keywordlist</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer[wms:Name]">
            <xsl:if test="not(wms:Abstract)">
               <ctl:message>Layer <xsl:value-of select="wms:Name"/> does not contain an Abstract</ctl:message>
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="recommendations:layer-keywordlists">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Each Layer in the capabilities document contains a keyword list.</ctl:assertion>
      <ctl:comment><![CDATA[Only applied to layers with a name]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.abstract_and_keywordlist</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer[wms:Name]">
            <xsl:if test="not(wms:KeywordList)">
               <ctl:message>Layer <xsl:value-of select="wms:Name"/> does not contain a KeywordList</ctl:message>
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="recommendations:layer-crs">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>All layers in the capabilities document are available in the CRS:84 and/or EPSG:4326 CRS.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 6.7.3.1">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.cs.layer.intro</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer[wms:Name and not(ancestor-or-self::wms:Layer/wms:CRS = 'EPSG:4326' or ancestor-or-self::wms:Layer/wms:CRS = 'CRS:84')]">
            <ctl:message>Layer <xsl:value-of select="wms:Name"/> does not support CRS:84 or EPSG:4326.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="recommendations:metadataurls">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Every named Layer in the capabilities document contains a MetadataURL element.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section 7.2.4.6.11">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.response.layer_properties.metadataurl</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer[wms:Name and not(wms:MetadataURL)]">
            <ctl:message>Layer <xsl:value-of select="wms:Name"/> does not contain a MetadataURL.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="recommendations:dims-no-whitespace">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>No dimension name values in the capabilities document contain whitespace.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0, Annex C, Section C.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.declaring</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer/wms:Dimension[translate(normalize-space(@name), ' ', 'X') != @name]">
            <ctl:message>Error: Dimension "<xsl:value-of select="@name"/>" in the layer titled "<xsl:value-of select="../wms:Title"/>" contains whitespace.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="recommendations:dims-defaults">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Each dimension declaration in the capabilities document contains a default value.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0, Annex C, Section C.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.declaring</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability//wms:Layer/wms:Dimension[not(@default)]">
            <ctl:message>Error: Dimension "<xsl:value-of select="@name"/>" in the layer titled "<xsl:value-of select="../wms:Title"/>" does not have a default value.</ctl:message>
            <ctl:fail/>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
</ctl:package>
<ctl:package xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:test name="basic:basic">
      <ctl:param name="is-interactive-enabled"/>
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Basic request behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="basic:options-requirements"/>
         <ctl:call-test name="basic:getmap"/>
         <xsl:if test="$is-interactive-enabled='yes'">
            <ctl:call-test name="basic:interactive"/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:options-requirements">
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>The requirements for testing the selected options are met.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="basic:gif-or-png"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:getmap">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The GetMap request behaves properly.</ctl:assertion>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(wms:Capability//wms:Layer/wms:Name)">
               <ctl:message>Error: No Named layers in capabilities XML.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:otherwise>
               <ctl:call-test name="basic:bbox"/>
               <ctl:call-test name="basic:bgcolor"/>
               <ctl:call-test name="basic:transparent"/>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:interactive">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The tests that require user interaction behave properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="basic:basic-polygons-sanity-check"/>
         <ctl:call-test name="basic:blue-lake-sanity-check"/>
         <ctl:call-test name="basic:layer-order"/>
         <ctl:call-test name="basic:aspect-ratio"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:gif-or-png">
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>The server supports GetMap format image/gif and/or image/png.</ctl:assertion>
      <ctl:link title="Test requirements">docs/wms/1.3.0/#requirements</ctl:link>
      <ctl:code>
         <xsl:for-each select="wms:Capability/wms:Request/wms:GetMap">
            <xsl:if test="not(wms:Format[. = 'image/gif' or contains(.,'image/png')])">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:bbox">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The BBOX parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="basic:bbox-exponential"/>
         <ctl:call-test name="basic:bbox-pixel-interpretation"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:bgcolor">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The BGCOLOR parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="basic:no-bgcolor"/>
         <ctl:call-test name="basic:blue-bgcolor"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:transparent">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The TRANSPARENT parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="basic:transparent-true"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:bbox-exponential">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request uses exponential notation values for the BBOX parameter, then the response is valid.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:link title="WMS 1.3.0 section 6.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#basic_elements.numeric_and_boolean</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="streams"
                       select="string(wms:Capability//wms:Layer[wms:Title = 'cite:Streams']/wms:Name)"/>
         <xsl:variable name="lakes"
                       select="string(wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name)"/>
         <xsl:variable name="ponds"
                       select="string(wms:Capability//wms:Layer[wms:Title = 'cite:Ponds']/wms:Name)"/>
         <xsl:variable name="bridges"
                       select="string(wms:Capability//wms:Layer[wms:Title = 'cite:Bridges']/wms:Name)"/>
         <xsl:variable name="road-segments"
                       select="string(wms:Capability//wms:Layer[wms:Title = 'cite:RoadSegments']/wms:Name)"/>
         <xsl:variable name="divided-routes"
                       select="string(wms:Capability//wms:Layer[wms:Title = 'cite:DividedRoutes']/wms:Name)"/>
         <xsl:variable name="buildings"
                       select="string(wms:Capability//wms:Layer[wms:Title = 'cite:Buildings']/wms:Name)"/>
         <xsl:variable name="map-neatline"
                       select="string(wms:Capability//wms:Layer[wms:Title = 'cite:MapNeatline']/wms:Name)"/>
         <xsl:variable name="response-1">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="$streams"/>,<xsl:value-of select="$lakes"/>,<xsl:value-of select="$ponds"/>,<xsl:value-of select="$bridges"/>,<xsl:value-of select="$road-segments"/>,<xsl:value-of select="$divided-routes"/>,<xsl:value-of select="$buildings"/>,<xsl:value-of select="$map-neatline"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="WiDtH">400</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="HeIgHt">200</ctl:param>
               <ctl:param name="BbOx">-0.005,-0.0025,0.005,0.0025</ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:checksum/>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="response-2">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="HeIgHt">200</ctl:param>
               <ctl:param name="WiDtH">400</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="$streams"/>,<xsl:value-of select="$lakes"/>,<xsl:value-of select="$ponds"/>,<xsl:value-of select="$bridges"/>,<xsl:value-of select="$road-segments"/>,<xsl:value-of select="$divided-routes"/>,<xsl:value-of select="$buildings"/>,<xsl:value-of select="$map-neatline"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="BbOx">-.0005E1,-25E-4,%2B05E-3,.00025E%2B1</ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:checksum/>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response-1/parsers:ImageParser/parsers:model/parsers:checksum = $response-2/parsers:ImageParser/parsers:model/parsers:checksum)">
            <ctl:message>Error: The image produced using exponential notation in the bbox is not the same as the image produced without using exponential notation.</ctl:message>
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:bbox-pixel-interpretation">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The server interprets the bounding box as going around the "outside" of the pixels of the image rather than through the centers of the border pixels.</ctl:assertion>
      <ctl:comment><![CDATA[The test verifies that none of the border pixels in the image returned are white]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.3.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bbox</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="StYlEs"/>
               <ctl:param name="HeIgHt">7</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="BbOx">0.0016,-0.0012,0.0026,-0.0005</ctl:param>
               <ctl:param name="WiDtH">10</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="$layer"/>
               </ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="RGB">
                     <parsers:subimage x="0" y="0" width="10" height="1">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="0" y="6" width="10" height="1">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="0" y="1" width="1" height="5">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="9" y="1" width="1" height="5">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not(count($response/parsers:ImageParser/parsers:model/parsers:subimage[parsers:count = 0]) = 4)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:no-bgcolor">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request is made with no BGCOLOR parameter, then areas which are not covered contain white (0xFFFFFF) pixels.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.10">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bgcolor</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="StYlEs"/>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="BbOx">0,-0.0020,0.0040,0</ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="RGB">
                     <parsers:subimage x="0" y="0" width="25" height="100">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="150" y="0" width="50" height="50">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not(count($response/parsers:ImageParser/parsers:model/parsers:subimage[parsers:count = 2500]) = 2)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:blue-bgcolor">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request is made with a BGCOLOR parameter, then areas which are not covered are set to the value of BGCOLOR.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.10">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.bgcolor</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="BgCoLoR">0x0000FF</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">0,-0.0020,0.0040,0</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="RGB">
                     <parsers:subimage x="0" y="0" width="25" height="100">
                        <parsers:count bands="RGB" sample="0x0000ff"/>
                     </parsers:subimage>
                     <parsers:subimage x="150" y="0" width="50" height="50">
                        <parsers:count bands="RGB" sample="0x0000ff"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not(count($response/parsers:ImageParser/parsers:model/parsers:subimage[parsers:count = 2500]) = 2)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:transparent-true">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request is made with TRANSPARENT=TRUE and a FORMAT that supports transparency over a BBOX that is not completely covered, then the response contains transparent pixels.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.3.3.9">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.transparent</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="TrAnSpArEnT">TRUE</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title='cite:Lakes']/wms:Name))"/>
               </ctl:param>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="BbOx">0,-0.0020,0.0040,0</ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:count bands="A" sample="0x00"/>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/parsers:ImageParser/parsers:model/parsers:count)">
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="number($response/parsers:ImageParser/parsers:model/parsers:count) = 0">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:basic-polygons-sanity-check">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The diamond from the cite:BasicPolygons layer displays correctly.</ctl:assertion>
      <ctl:code>
         <xsl:variable name="form-values">
            <ctl:form width="700" height="500">
               <img border="1">
                  <xsl:attribute name="src">
                     <xsl:value-of select="functions:correct-url-prefix(wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href)"/>
                     <xsl:text>VERSION=</xsl:text>
                     <xsl:value-of select="functions:version()"/>
                     <xsl:text>&amp;REQUEST=GetMap</xsl:text>
                     <xsl:text>&amp;LAYERS=</xsl:text>
                     <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name))"/>
                     <xsl:text>&amp;STYLES=</xsl:text>
                     <xsl:text>&amp;CRS=CRS:84</xsl:text>
                     <xsl:text>&amp;BBOX=-1,-1,1,1</xsl:text>
                     <xsl:text>&amp;WIDTH=300</xsl:text>
                     <xsl:text>&amp;HEIGHT=300</xsl:text>
                     <xsl:text>&amp;FORMAT=</xsl:text>
                     <xsl:value-of select="functions:encode(wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif') or starts-with(., 'image/jpeg')][1])"/>
                  </xsl:attribute>
               </img>
               <p>
                  Does the image above depict a large diamond that fills the frame?
               </p>
               <p>
                  <input type="submit" name="submit" value="yes"/>
                  <input type="submit" name="submit" value="no"/>
               </p>
            </ctl:form>
         </xsl:variable>
         <xsl:if test="not($form-values/values/value[@key='submit']='yes')">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:blue-lake-sanity-check">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The layers from the Blue Lake dataset display correctly.</ctl:assertion>
      <ctl:code>
         <xsl:variable name="form-values">
            <ctl:form width="700" height="500">
               <img>
                  <xsl:attribute name="src">
                     <xsl:value-of select="functions:correct-url-prefix(wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href)"/>
                     <xsl:text>VERSION=</xsl:text>
                     <xsl:value-of select="functions:version()"/>
                     <xsl:text>&amp;REQUEST=GetMap</xsl:text>
                     <xsl:text>&amp;LAYERS=</xsl:text>
                     <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Streams']/wms:Name))"/>
                     <xsl:text>,</xsl:text>
                     <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name))"/>
                     <xsl:text>,</xsl:text>
                     <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Ponds']/wms:Name))"/>
                     <xsl:text>,</xsl:text>
                     <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Bridges']/wms:Name))"/>
                     <xsl:text>,</xsl:text>
                     <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:RoadSegments']/wms:Name))"/>
                     <xsl:text>,</xsl:text>
                     <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:DividedRoutes']/wms:Name))"/>
                     <xsl:text>,</xsl:text>
                     <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Buildings']/wms:Name))"/>
                     <xsl:text>,</xsl:text>
                     <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:MapNeatline']/wms:Name))"/>
                     <xsl:text>&amp;STYLES=</xsl:text>
                     <xsl:text>&amp;CRS=CRS:84</xsl:text>
                     <xsl:text>&amp;BBOX=-0.005,-0.0025,.005,0.0025</xsl:text>
                     <xsl:text>&amp;WIDTH=400</xsl:text>
                     <xsl:text>&amp;HEIGHT=200</xsl:text>
                     <xsl:text>&amp;FORMAT=</xsl:text>
                     <xsl:value-of select="functions:encode(wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif') or starts-with(., 'image/jpeg')][1])"/>
                  </xsl:attribute>
               </img>
               <p>
                  Does the image above depict a map of the Blue Lake vicinity with a surrounding neatline?
               </p>
               <p>
                  <input type="submit" name="submit" value="yes"/>
                  <input type="submit" name="submit" value="no"/>
               </p>
            </ctl:form>
         </xsl:variable>
         <xsl:if test="not($form-values/values/value[@key='submit']='yes')">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:layer-order">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request contains multiple layers, then the response renders the requested layers by drawing the leftmost in the list bottommost, and the next one over that.</ctl:assertion>
      <ctl:comment><![CDATA[The user will be asked to manually verify that for request #1, Goose Island, Blue Lake, and Ashton are above State Forest.  For request #2, State Forest is above Ashton, and Blue Lake and Goose Island are not visible.  Depending on the styles the implementation uses, it may not be possible to tell which feature is on top of another.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.3.3.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.layers</ctl:link>
      <ctl:code>
         <xsl:variable name="form-values">
            <ctl:form width="700" height="500">
               <table>
                  <tr>
                     <td>
                        <img>
                           <xsl:attribute name="src">
                              <xsl:value-of select="functions:correct-url-prefix(wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href)"/>
                              <xsl:text>VERSION=</xsl:text>
                              <xsl:value-of select="functions:version()"/>
                              <xsl:text>&amp;REQUEST=GetMap</xsl:text>
                              <xsl:text>&amp;LAYERS=</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Forests']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:NamedPlaces']/wms:Name))"/>
                              <xsl:text>&amp;STYLES=</xsl:text>
                              <xsl:text>&amp;CRS=CRS:84</xsl:text>
                              <xsl:text>&amp;BBOX=-0.0042,-0.0024,0.0042,0.0024</xsl:text>
                              <xsl:text>&amp;WIDTH=168</xsl:text>
                              <xsl:text>&amp;HEIGHT=96</xsl:text>
                              <xsl:text>&amp;FORMAT=</xsl:text>
                              <xsl:value-of select="functions:encode(wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif') or starts-with(., 'image/jpeg')][1])"/>
                           </xsl:attribute>
                        </img>
                     </td>
                     <td>
                        <img>
                           <xsl:attribute name="src">
                              <xsl:value-of select="functions:correct-url-prefix(wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href)"/>
                              <xsl:text>VERSION=</xsl:text>
                              <xsl:value-of select="functions:version()"/>
                              <xsl:text>&amp;REQUEST=GetMap</xsl:text>
                              <xsl:text>&amp;LAYERS=</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:NamedPlaces']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Forests']/wms:Name))"/>
                              <xsl:text>&amp;STYLES=</xsl:text>
                              <xsl:text>&amp;CRS=CRS:84</xsl:text>
                              <xsl:text>&amp;BBOX=-0.0042,-0.0024,0.0042,0.0024</xsl:text>
                              <xsl:text>&amp;WIDTH=168</xsl:text>
                              <xsl:text>&amp;HEIGHT=96</xsl:text>
                              <xsl:text>&amp;FORMAT=</xsl:text>
                              <xsl:value-of select="functions:encode(wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif') or starts-with(., 'image/jpeg')][1])"/>
                           </xsl:attribute>
                        </img>
                     </td>
                  </tr>
               </table>
               <p>
                  In the picture on the left, Goose Island, Blue Lake, and Ashton should overlay State Forest.
                  In the picture on the right, State Forest should be on top of Ashton, Blue Lake, and Goose Island.
                  Are the pictures correct?
               </p>
               <p>
                  <input type="submit" name="submit" value="yes"/>
                  <input type="submit" name="submit" value="no"/>
               </p>
            </ctl:form>
         </xsl:variable>
         <xsl:if test="not($form-values/values/value[@key='submit']='yes')">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="basic:aspect-ratio">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a GetMap request is made where the aspect ratio of the BBOX and the aspect ratio of the WIDTH/HEIGHT parameters is different, then the map returned is stretched.</ctl:assertion>
      <ctl:comment><![CDATA[The user will be asked to manually verify that the two images look the same, except that the image #2 is stretched so it is twice as tall as image #1.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section 7.3.3.8">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getmap.params.width_height</ctl:link>
      <ctl:code>
         <xsl:variable name="form-values">
            <ctl:form width="700" height="500">
               <table>
                  <tr>
                     <td>
                        <img>
                           <xsl:attribute name="src">
                              <xsl:value-of select="functions:correct-url-prefix(wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href)"/>
                              <xsl:text>VERSION=</xsl:text>
                              <xsl:value-of select="functions:version()"/>
                              <xsl:text>&amp;REQUEST=GetMap</xsl:text>
                              <xsl:text>&amp;LAYERS=</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Streams']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Ponds']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Bridges']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:RoadSegments']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:DividedRoutes']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Buildings']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:MapNeatline']/wms:Name))"/>
                              <xsl:text>&amp;STYLES=</xsl:text>
                              <xsl:text>&amp;CRS=CRS:84</xsl:text>
                              <xsl:text>&amp;BBOX=-0.005,-0.0025,0.005,0.0025</xsl:text>
                              <xsl:text>&amp;WIDTH=200</xsl:text>
                              <xsl:text>&amp;HEIGHT=100</xsl:text>
                              <xsl:text>&amp;FORMAT=</xsl:text>
                              <xsl:value-of select="functions:encode(wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif') or starts-with(., 'image/jpeg')][1])"/>
                           </xsl:attribute>
                        </img>
                     </td>
                     <td>
                        <img>
                           <xsl:attribute name="src">
                              <xsl:value-of select="functions:correct-url-prefix(wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href)"/>
                              <xsl:text>VERSION=</xsl:text>
                              <xsl:value-of select="functions:version()"/>
                              <xsl:text>&amp;REQUEST=GetMap</xsl:text>
                              <xsl:text>&amp;LAYERS=</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Streams']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Ponds']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Bridges']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:RoadSegments']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:DividedRoutes']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:Buildings']/wms:Name))"/>
                              <xsl:text>,</xsl:text>
                              <xsl:value-of select="functions:encode(string(wms:Capability//wms:Layer[wms:Title = 'cite:MapNeatline']/wms:Name))"/>
                              <xsl:text>&amp;STYLES=</xsl:text>
                              <xsl:text>&amp;CRS=CRS:84</xsl:text>
                              <xsl:text>&amp;BBOX=-0.005,-0.0025,0.005,0.0025</xsl:text>
                              <xsl:text>&amp;WIDTH=200</xsl:text>
                              <xsl:text>&amp;HEIGHT=200</xsl:text>
                              <xsl:text>&amp;FORMAT=</xsl:text>
                              <xsl:value-of select="functions:encode(wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif') or starts-with(., 'image/jpeg')][1])"/>
                           </xsl:attribute>
                        </img>
                     </td>
                  </tr>
               </table>
               <p>
                  The two pictures above should depict the same scene, but the picture on the right should be stretched so it is twice as tall as the picture on the left.
                  Are the pictures correct?
               </p>
               <p>
                  <input type="submit" name="submit" value="yes"/>
                  <input type="submit" name="submit" value="no"/>
               </p>
            </ctl:form>
         </xsl:variable>
         <xsl:if test="not($form-values/values/value[@key='submit']='yes')">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
</ctl:package>
<ctl:package xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:test name="queryable:queryable">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Queryable request behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="queryable:options-requirements"/>
         <ctl:call-test name="queryable:getfeatureinfo"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="queryable:options-requirements">
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>The requirements for testing the selected options are met.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="queryable:getfeatureinfo-supported"/>
         <ctl:call-test name="queryable:std-data-queryable"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="queryable:getfeatureinfo">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The GetFeatureInfo request behaves properly.</ctl:assertion>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="not(wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get)">
               <ctl:message>The GetFeatureInfo request is not supported.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:otherwise>
               <xsl:choose>
                  <xsl:when test="not(wms:Capability//wms:Layer[@queryable and functions:boolean-as-integer(@queryable) = 1]/wms:Name)">
                     <ctl:message>No queryable layers in capabilities XML.</ctl:message>
                     <ctl:fail/>
                  </xsl:when>
                  <xsl:otherwise>
                     <ctl:call-test name="queryable:feature_count"/>
                  </xsl:otherwise>
               </xsl:choose>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="queryable:feature_count">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>The FEATURE_COUNT parameter behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="queryable:feature_count-default"/>
         <ctl:call-test name="queryable:feature_count-1"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="queryable:feature_count-default">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the FEATURE_COUNT parameter is not specified, then less data is returned than when FEATURE_COUNT is 2.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.feature_count</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="info-format"
                       select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
         <xsl:variable name="response-1">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
               </ctl:param>
               <ctl:param name="I">50</ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="BbOx">-2,2,2,6</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="J">50</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <parsers:CDataParser/>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="response-2">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="BbOx">-2,2,2,6</ctl:param>
               <ctl:param name="FeAtUrE_CoUnT">2</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="J">50</ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
               </ctl:param>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
               </ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="I">50</ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <parsers:CDataParser/>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="string-length($response-1) &gt; string-length($response-2)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="queryable:feature_count-1">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the FEATURE_COUNT parameter is 1, then less data is returned than when FEATURE_COUNT is 2.</ctl:assertion>
      <ctl:comment/>
      <ctl:link title="WMS 1.3.0 section 7.4.3.6">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getfeatureinfo.params.feature_count</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="info-format"
                       select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:Format[1]"/>
         <xsl:variable name="response-1">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
               </ctl:param>
               <ctl:param name="I">50</ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
               </ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="BbOx">-2,2,2,6</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="J">50</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="FeAtUrE_CoUnT">1</ctl:param>
               <parsers:CDataParser/>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="response-2">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetFeatureInfo/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="BbOx">-2,2,2,6</ctl:param>
               <ctl:param name="FeAtUrE_CoUnT">2</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="J">50</ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
               </ctl:param>
               <ctl:param name="QuErY_LaYeRs">
                  <xsl:value-of select="string(wms:Capability//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
               </ctl:param>
               <ctl:param name="CrS">CRS:84</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="WiDtH">100</ctl:param>
               <ctl:param name="InFo_fOrMaT">
                  <xsl:value-of select="functions:encode($info-format)"/>
               </ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="I">50</ctl:param>
               <ctl:param name="ReQuEsT">GetFeatureInfo</ctl:param>
               <parsers:CDataParser/>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="string-length($response-1) &gt; string-length($response-2)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="queryable:getfeatureinfo-supported">
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>GetFeatureInfo requests are supported.</ctl:assertion>
      <ctl:link title="Test requirements">docs/wms/1.3.0/#requirements</ctl:link>
      <ctl:code>
         <xsl:if test="not(wms:Capability/wms:Request/wms:GetFeatureInfo)">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="queryable:std-data-queryable">
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>The CITE standard dataset layers containing polygons are queryable.</ctl:assertion>
      <ctl:link title="Test requirements">docs/wms/1.3.0/#requirements</ctl:link>
      <ctl:code>
         <xsl:variable name="root-layer" select="wms:Capability/wms:Layer"/>
         <xsl:variable name="titles">
            <title>cite:BasicPolygons</title>
            <title>cite:Forests</title>
            <title>cite:Lakes</title>
            <title>cite:NamedPlaces</title>
         </xsl:variable>
         <xsl:for-each select="$titles/title">
            <xsl:variable name="title" select="."/>
            <xsl:variable name="layer"
                          select="$root-layer/descendant-or-self::wms:Layer[wms:Title = $title]"/>
            <xsl:choose>
               <xsl:when test="not($layer/wms:Title)">
                  <ctl:message>Error: No layer titled <xsl:value-of select="$title"/> found.</ctl:message>
                  <ctl:fail/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:if test="functions:boolean-as-integer($layer/@queryable) = 0">
                     <ctl:message>Error: Layer titled <xsl:value-of select="$title"/> must be queryable.</ctl:message>
                     <ctl:fail/>
                  </xsl:if>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
</ctl:package>
<ctl:package xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:test name="raster_elevation:raster_elevation">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Raster elevation request behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="raster_elevation:options-requirements"/>
         <ctl:call-test name="raster_elevation:dims"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:options-requirements">
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>The requirements for testing the selected options are met.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="raster_elevation:raster_elevation"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:dims">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Support for dimensional data is correct.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="raster_elevation:terrain"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:raster_elevation">
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>The server supports the cite:Terrain layer with a properly declared elevation dimenson.</ctl:assertion>
      <ctl:link title="Test requirements">docs/wms/1.3.0/#requirements</ctl:link>
      <ctl:code>
         <xsl:variable name="layer"
                       select="wms:Capability/wms:Layer/descendant-or-self::wms:Layer[wms:Title = 'cite:Terrain']"/>
         <xsl:variable name="dim"
                       select="$layer/ancestor-or-self::wms:Layer/wms:Dimension[@name='elevation'][1]"/>
         <xsl:variable name="extent" select="concat(',', string($dim), ',')"/>
         <xsl:choose>
            <xsl:when test="not($layer/*)">
               <ctl:message>Error: No layer titled cite:Terrain found.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:when test="not($dim/self::wms:Dimension)">
               <ctl:message>Error: The cite:Terrain layer does not have an elevation dimension.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:otherwise>
               <xsl:if test="$dim/@units != 'CRS:88'">
                  <ctl:message>Error: The elevation dimension for the cite:Terrain layer must be defined with units="CRS:88".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="$dim/@unitSymbol != 'm'">
                  <ctl:message>Error: The elevation dimension for the cite:Terrain layer must be defined with unitSymbol="m".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="functions:boolean-as-integer($dim/@multipleValues) != 1">
                  <ctl:message>Error: The elevation dimension for the cite:Terrain layer must be defined with multipleValues="true".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="functions:boolean-as-integer($dim/@nearestValue) != 0">
                  <ctl:message>Error: The elevation dimension for the cite:Terrain layer must be defined with nearestValue="false".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="not(contains($extent, ',0/425/1,'))">
                  <ctl:message>Error: The elevation dimension for the cite:Terrain layer must be defined using extent value "0/425/1".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:terrain">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Support for a raster layer that supports the elevation dimension is correct.</ctl:assertion>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="//wms:Layer[wms:Title = 'cite:Terrain']/ancestor-or-self::wms:Layer/wms:Dimension[functions:to-lowercase(@name)='elevation']">
               <ctl:call-test name="raster_elevation:terrain-low-range"/>
               <ctl:call-test name="raster_elevation:terrain-mid-range"/>
               <ctl:call-test name="raster_elevation:terrain-high-range"/>
               <ctl:call-test name="raster_elevation:terrain-low-and-high-ranges"/>
               <ctl:call-test name="raster_elevation:terrain-range-and-value"/>
               <ctl:call-test name="raster_elevation:terrain-value"/>
               <ctl:call-test name="raster_elevation:terrain-invalid"/>
               <ctl:call-test name="raster_elevation:terrain-default"/>
               <ctl:call-test name="raster_elevation:terrain-and-other-layer"/>
            </xsl:when>
            <xsl:otherwise>
               <ctl:message>No layers titled cite:Terrain that support the elevation dimension.</ctl:message>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:terrain-low-range">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When elevations in a low range are requested, only the matching pixels are returned.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Request ELEVATION=0/200 and verify that the pixels in the "low spot" are solid and all the other pixels are transparent.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Terrain']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.5,-0.5,0.5,0.5</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">600</ctl:param>
               <ctl:param name="HeIgHt">600</ctl:param>
               <ctl:param name="TrAnSpArEnT">TRUE</ctl:param>
               <ctl:param name="ElEvAtIoN">
                  <xsl:value-of select="functions:encode('0/200')"/>
               </ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:subimage x="450" y="450" width="150" height="150">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                     <parsers:subimage x="0" y="0" width="600" height="600">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="number(parsers:subimage[1]/parsers:count) != 0">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[2]/parsers:count) != 337500">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:terrain-mid-range">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When elevations in a mid range are requested, only the matching pixels are returned.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Request ELEVATION=200/335 and verify that the pixels in the "low spot" and the "high spot" are transparent and all the other pixels are solid.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Terrain']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.5,-0.5,0.5,0.5</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">600</ctl:param>
               <ctl:param name="HeIgHt">600</ctl:param>
               <ctl:param name="TrAnSpArEnT">TRUE</ctl:param>
               <ctl:param name="ElEvAtIoN">
                  <xsl:value-of select="functions:encode('200/335')"/>
               </ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:subimage x="0" y="0" width="150" height="150">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                     <parsers:subimage x="450" y="450" width="150" height="150">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                     <parsers:subimage x="0" y="0" width="600" height="600">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="number(parsers:subimage[1]/parsers:count) != 22500">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[2]/parsers:count) != 22500">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[3]/parsers:count) != 45000">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:terrain-high-range">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When elevations in a high range are requested, only the matching pixels are returned.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Request ELEVATION=335/425 and verify that the pixels in the "low spot" are solid and all the other pixels are transparent.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Terrain']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.5,-0.5,0.5,0.5</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">600</ctl:param>
               <ctl:param name="HeIgHt">600</ctl:param>
               <ctl:param name="TrAnSpArEnT">TRUE</ctl:param>
               <ctl:param name="ElEvAtIoN">
                  <xsl:value-of select="functions:encode('335/425')"/>
               </ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:subimage x="0" y="0" width="150" height="150">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                     <parsers:subimage x="0" y="0" width="600" height="600">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="number(parsers:subimage[1]/parsers:count) != 0">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[2]/parsers:count) != 337500">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:terrain-low-and-high-ranges">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When elevations in a low range and a high range are requested, only the matching pixels are returned.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Request ELEVATION=0/200,335/425 and verify that the pixels in the "low spot" and the "high spot" are solid and all the other pixels are transparent.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Terrain']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.5,-0.5,0.5,0.5</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">600</ctl:param>
               <ctl:param name="HeIgHt">600</ctl:param>
               <ctl:param name="TrAnSpArEnT">TRUE</ctl:param>
               <ctl:param name="ElEvAtIoN">
                  <xsl:value-of select="functions:encode('0/200')"/>
                  <xsl:text>,</xsl:text>
                  <xsl:value-of select="functions:encode('335/425')"/>
               </ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:subimage x="0" y="0" width="150" height="150">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                     <parsers:subimage x="450" y="450" width="150" height="150">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                     <parsers:subimage x="0" y="0" width="600" height="600">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="number(parsers:subimage[1]/parsers:count) != 0">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[2]/parsers:count) != 0">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[3]/parsers:count) != 315000">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:terrain-range-and-value">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When elevations in an interval range and at a single value are requested, only the matching pixels are returned.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Request ELEVATION=0/200,250 and verify that all of the pixels in the "low spot" as well as some of the other pixels are not transparent.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Terrain']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.5,-0.5,0.5,0.5</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">600</ctl:param>
               <ctl:param name="HeIgHt">600</ctl:param>
               <ctl:param name="TrAnSpArEnT">TRUE</ctl:param>
               <ctl:param name="ElEvAtIoN">
                  <xsl:value-of select="functions:encode('0/200')"/>
                  <xsl:text>,</xsl:text>
                  <xsl:value-of select="functions:encode('250')"/>
               </ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:subimage x="0" y="0" width="150" height="150">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                     <parsers:subimage x="450" y="450" width="150" height="150">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                     <parsers:subimage x="0" y="0" width="600" height="600">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="number(parsers:subimage[1]/parsers:count) != 22500">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[2]/parsers:count) != 0">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="not(number(parsers:subimage[3]/parsers:count) &gt; 22500)">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:terrain-value">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When elevations at a single value are requested, only the matching pixels are returned.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Request ELEVATION=250 and verify that some pixels in the response are not transparent.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Terrain']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.5,-0.5,0.5,0.5</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">600</ctl:param>
               <ctl:param name="HeIgHt">600</ctl:param>
               <ctl:param name="TrAnSpArEnT">TRUE</ctl:param>
               <ctl:param name="ElEvAtIoN">250</ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="ARGB">
                     <parsers:subimage x="0" y="0" width="600" height="600">
                        <parsers:count bands="A" sample="0"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:variable name="count" select="number(parsers:subimage[1]/parsers:count)"/>
            <xsl:if test="not($count &gt; 45000 and $count &lt; 360000)">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:terrain-invalid">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When an elevation outside of the advertised range is requested, the response is an exception with code=InvalidDimensionValue.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Request ELEVATION=1000 and verify that the service returns an exception with code=InvalidDimensionValue.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.4.1">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.responses.incorrect</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Terrain']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.5,-0.5,0.5,0.5</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">600</ctl:param>
               <ctl:param name="HeIgHt">600</ctl:param>
               <ctl:param name="TrAnSpArEnT">TRUE</ctl:param>
               <ctl:param name="ElEvAtIoN">1000</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='InvalidDimensionValue'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:terrain-default">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the elevation parameter is missing but there is a default elevation value, the default value is used and a warning header is set.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Submit a request without an ELEVATION parameter and verify that the response is equivalent to the default value and the "default value used" warning header is returned.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.4.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.responses.default</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Terrain']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.5,-0.5,0.5,0.5</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">600</ctl:param>
               <ctl:param name="HeIgHt">600</ctl:param>
               <ctl:param name="TrAnSpArEnT">TRUE</ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:ImageParser>
                        <parsers:model value="ARGB">
                           <parsers:subimage x="0" y="0" width="600" height="600">
                              <parsers:count bands="A" sample="0"/>
                           </parsers:subimage>
                        </parsers:model>
                     </parsers:ImageParser>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:message>Content-type header is not corrrect</ctl:message>
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="not($response/response/headers/header[@name='Warning' and starts-with(functions:to-lowercase(.), '99 default value used: elevation=0/425') and starts-with(., '99 D')])">
            <ctl:message>A correct "Default value used" warning header was not set</ctl:message>
            <ctl:fail/>
         </xsl:if>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:variable name="count" select="number(parsers:subimage[1]/parsers:count)"/>
            <xsl:if test="not($count != 0)">
               <ctl:message>Image is not correct</ctl:message>
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="raster_elevation:terrain-and-other-layer">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a terrain layer that supports elevation and a layer that does not support elevation are both requested, the response is a map.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Submit a request involving both the Terrain layer and a layer that does not support the ELEVATION dimension and verify that the response is a map.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.applicability</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer1"
                       select="string(//wms:Layer[wms:Title = 'cite:BasicPolygons']/wms:Name)"/>
         <xsl:variable name="layer2" select="string(//wms:Layer[wms:Title = 'cite:Terrain']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-1,-1,1,1</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer1)"/>
                  <xsl:text>,</xsl:text>
                  <xsl:value-of select="functions:encode($layer2)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">600</ctl:param>
               <ctl:param name="HeIgHt">600</ctl:param>
               <ctl:param name="ElEvAtIoN">
                  <xsl:value-of select="functions:encode('0/425')"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
</ctl:package>
<ctl:package xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:test name="vector_elevation:vector_elevation">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Vector elevation request behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="vector_elevation:options-requirements"/>
         <ctl:call-test name="vector_elevation:dims"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="vector_elevation:options-requirements">
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>The requirements for testing the selected options are met.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="vector_elevation:vector_elevation"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="vector_elevation:dims">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Support for dimensional data is correct.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="vector_elevation:geometry"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="vector_elevation:vector_elevation">
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>The server supports the cite:Lakes layer with a properly declared elevation dimenson.</ctl:assertion>
      <ctl:link title="Test requirements">docs/wms/1.3.0/#requirements</ctl:link>
      <ctl:code>
         <xsl:variable name="layer"
                       select="wms:Capability/wms:Layer/descendant-or-self::wms:Layer[wms:Title = 'cite:Lakes']"/>
         <xsl:variable name="dim"
                       select="$layer/ancestor-or-self::wms:Layer/wms:Dimension[@name='elevation'][1]"/>
         <xsl:variable name="extent" select="concat(',', string($dim), ',')"/>
         <xsl:choose>
            <xsl:when test="not($layer/*)">
               <ctl:message>Error: No layer titled cite:Lakes found.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:when test="not($dim/self::wms:Dimension)">
               <ctl:message>Error: The cite:Lakes layer does not have an elevation dimension.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:otherwise>
               <xsl:if test="$dim/@units != 'CRS:88'">
                  <ctl:message>Error: The elevation dimension for the cite:Lakes layer must be defined with units="CRS:88".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="$dim/@unitSymbol != 'm'">
                  <ctl:message>Error: The elevation dimension for the cite:Lakes layer must be defined with unitSymbol="m".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="functions:boolean-as-integer($dim/@multipleValues) != 0">
                  <ctl:message>Error: The elevation dimension for the cite:Lakes layer must be defined with multipleValues="false".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="functions:boolean-as-integer($dim/@nearestValue) != 1">
                  <ctl:message>Error: The elevation dimension for the cite:Lakes layer must be defined with nearestValue="true".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="$dim/@default != '500'">
                  <ctl:message>Error: The elevation dimension for the cite:Lakes layer must be defined with default="500".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="not(contains($extent, ',500,') and contains($extent, ',490,') and contains($extent, ',480,'))">
                  <ctl:message>Error: The elevation dimension for the cite:Lakes layer must be defined using extent value "500,490,480".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="vector_elevation:geometry">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Support for a geometric layer that supports the elevation dimension is correct.</ctl:assertion>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="//wms:Layer[wms:Title = 'cite:Lakes']/ancestor-or-self::wms:Layer/wms:Dimension[functions:to-lowercase(@name)='elevation']">
               <ctl:call-test name="vector_elevation:geometry-low"/>
               <ctl:call-test name="vector_elevation:geometry-med"/>
               <ctl:call-test name="vector_elevation:geometry-high"/>
               <ctl:call-test name="vector_elevation:geometry-multiple-values"/>
               <ctl:call-test name="vector_elevation:geometry-nearest-value"/>
               <ctl:call-test name="vector_elevation:geometry-default-value"/>
               <ctl:call-test name="vector_elevation:geometry-and-other-layer"/>
            </xsl:when>
            <xsl:otherwise>
               <ctl:message>No layers titled cite:Lakes that support the elevation dimension.</ctl:message>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="vector_elevation:geometry-low">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the geometry at a low elevation is requested, the matching pixels are returned.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Request ELEVATION=480 and verify that the response is correct.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">0,-0.002,0.004,0</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="ElEvAtIoN">480</ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="RGB">
                     <parsers:subimage x="0" y="0" width="50" height="100">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="65" y="35" width="10" height="30">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="100" y="0" width="100" height="100">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="number(parsers:subimage[1]/parsers:count) != 5000">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[2]/parsers:count) != 0">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[3]/parsers:count) != 10000">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="vector_elevation:geometry-med">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the geometry at a medium elevation is requested, the matching pixels are returned.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Request ELEVATION=490 and verify that the response is correct.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">0,-0.002,0.004,0</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="ElEvAtIoN">490</ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="RGB">
                     <parsers:subimage x="0" y="0" width="40" height="100">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="60" y="30" width="15" height="45">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="60" y="60" width="60" height="10">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="100" y="0" width="100" height="50">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="130" y="50" width="70" height="50">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="parsers:count[1]/parsers:count != 4000">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[2]/parsers:count) != 0">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[3]/parsers:count) != 0">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[4]/parsers:count) != 5000">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[5]/parsers:count) != 3500">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="vector_elevation:geometry-high">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the geometry at a high elevation is requested, the matching pixels are returned.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Request ELEVATION=500 and verify that the response is correct.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">0,-0.002,0.004,0</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="ElEvAtIoN">500</ctl:param>
               <parsers:ImageParser>
                  <parsers:model value="RGB">
                     <parsers:subimage x="0" y="0" width="20" height="100">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="50" y="30" width="35" height="50">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="85" y="55" width="55" height="20">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                     <parsers:subimage x="170" y="0" width="30" height="100">
                        <parsers:count bands="RGB" sample="0xffffff"/>
                     </parsers:subimage>
                  </parsers:model>
               </parsers:ImageParser>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="number(parsers:subimage[1]/parsers:count) != 2000">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[2]/parsers:count) != 0">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[3]/parsers:count) != 0">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[4]/parsers:count) != 3000">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="vector_elevation:geometry-multiple-values">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the geometries for a list of elevations are requested and multiple values are not supported, the response is an exception with code=InvalidDimensionValue.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Request ELEVATION=500,480 and verify that the response is an exception with code=InvalidDimensionValue. ]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.4">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.single_vs_multiple</ctl:link>
      <ctl:link title="WMS 1.3.0 section C.4.1">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.responses.incorrect</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">0,-0.002,0.004,0</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="ElEvAtIoN">500,480</ctl:param>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="not($response/ogc:ServiceExceptionReport/ogc:ServiceException[@code='InvalidDimensionValue'])">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
   <ctl:test name="vector_elevation:geometry-nearest-value">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a request for the geometry at an unadvertised elevation value is requested and support for nearest values is advertised, the nearest value is used and a warning header is set.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Submit a request with ELEVATION=492 and verify that the response is equivalent to the 490 value and the "nearest value used" warning header is returned.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.4.3">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.responses.nearest</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">0,-0.002,0.004,0</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="ElEvAtIoN">492</ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:ImageParser>
                        <parsers:model value="RGB">
                           <parsers:subimage x="0" y="0" width="40" height="100">
                              <parsers:count bands="RGB" sample="0xffffff"/>
                           </parsers:subimage>
                           <parsers:subimage x="60" y="30" width="15" height="45">
                              <parsers:count bands="RGB" sample="0xffffff"/>
                           </parsers:subimage>
                           <parsers:subimage x="60" y="60" width="60" height="10">
                              <parsers:count bands="RGB" sample="0xffffff"/>
                           </parsers:subimage>
                           <parsers:subimage x="100" y="0" width="100" height="50">
                              <parsers:count bands="RGB" sample="0xffffff"/>
                           </parsers:subimage>
                           <parsers:subimage x="130" y="50" width="70" height="50">
                              <parsers:count bands="RGB" sample="0xffffff"/>
                           </parsers:subimage>
                        </parsers:model>
                     </parsers:ImageParser>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:message>Content-type header is not corrrect</ctl:message>
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="not($response/response/headers/header[@name='Warning' and starts-with(functions:to-lowercase(.), '99 nearest value used: elevation=490') and starts-with(., '99 N')])">
            <ctl:message>A correct "Nearest value used" warning header was not set</ctl:message>
            <ctl:fail/>
         </xsl:if>
         <xsl:for-each select="$response/response/content/parsers:ImageParser/parsers:model">
            <xsl:choose>
               <xsl:when test="parsers:count[1]/parsers:count != 4000">
                  <ctl:message>Image is not corrrect</ctl:message>
                  <ctl:fail/>
               </xsl:when>
               <xsl:when test="number(parsers:subimage[2]/parsers:count) != 0">
                  <ctl:message>Image is not corrrect</ctl:message>
                  <ctl:fail/>
               </xsl:when>
               <xsl:when test="number(parsers:subimage[3]/parsers:count) != 0">
                  <ctl:message>Image is not corrrect</ctl:message>
                  <ctl:fail/>
               </xsl:when>
               <xsl:when test="number(parsers:subimage[4]/parsers:count) != 5000">
                  <ctl:message>Image is not corrrect</ctl:message>
                  <ctl:fail/>
               </xsl:when>
               <xsl:when test="number(parsers:subimage[5]/parsers:count) != 3500">
                  <ctl:message>Image is not corrrect</ctl:message>
                  <ctl:fail/>
               </xsl:when>
            </xsl:choose>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="vector_elevation:geometry-default-value">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When the elevation parameter is missing but there is a default elevation value, the default value is used and a warning header is set.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Submit a request without an ELEVATION parameter and verify that the response is equivalent to the default value and the "default value used" warning header is returned.]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.4.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.responses.default</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">0,-0.002,0.004,0</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:ImageParser>
                        <parsers:model value="RGB">
                           <parsers:subimage x="0" y="0" width="20" height="100">
                              <parsers:count bands="RGB" sample="0xffffff"/>
                           </parsers:subimage>
                           <parsers:subimage x="50" y="30" width="35" height="50">
                              <parsers:count bands="RGB" sample="0xffffff"/>
                           </parsers:subimage>
                           <parsers:subimage x="85" y="55" width="55" height="20">
                              <parsers:count bands="RGB" sample="0xffffff"/>
                           </parsers:subimage>
                           <parsers:subimage x="170" y="0" width="30" height="100">
                              <parsers:count bands="RGB" sample="0xffffff"/>
                           </parsers:subimage>
                        </parsers:model>
                     </parsers:ImageParser>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:message>Content-type header is not corrrect</ctl:message>
            <ctl:fail/>
         </xsl:if>
         <xsl:if test="not($response/response/headers/header[@name='Warning' and starts-with(functions:to-lowercase(.), '99 default value used: elevation=500') and starts-with(., '99 D')])">
            <ctl:message>A correct "Default value used" warning header was not set</ctl:message>
            <ctl:fail/>
         </xsl:if>
         <xsl:for-each select="$response/response/content/parsers:ImageParser/parsers:model">
            <xsl:choose>
               <xsl:when test="number(parsers:subimage[1]/parsers:count) != 2000">
                  <ctl:message>Image is not corrrect</ctl:message>
                  <ctl:fail/>
               </xsl:when>
               <xsl:when test="number(parsers:subimage[2]/parsers:count) != 0">
                  <ctl:message>Image is not corrrect</ctl:message>
                  <ctl:fail/>
               </xsl:when>
               <xsl:when test="number(parsers:subimage[3]/parsers:count) != 0">
                  <ctl:message>Image is not corrrect</ctl:message>
                  <ctl:fail/>
               </xsl:when>
               <xsl:when test="number(parsers:subimage[4]/parsers:count) != 3000">
                  <ctl:message>Image is not corrrect</ctl:message>
                  <ctl:fail/>
               </xsl:when>
            </xsl:choose>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="vector_elevation:geometry-and-other-layer">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a geometry layer that supports elevation and a layer that does not support elevation are both requested, the response is a map.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Submit a request invloving both the Lakes layer and a layer that does not support the ELEVATION dimension and verify that the response is a map]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.applicability</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer1" select="string(//wms:Layer[wms:Title = 'cite:Lakes']/wms:Name)"/>
         <xsl:variable name="layer2" select="string(//wms:Layer[wms:Title = 'cite:Streams']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">0,-0.002,0.004,0</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer1)"/>
                  <xsl:text>,</xsl:text>
                  <xsl:value-of select="functions:encode($layer2)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">200</ctl:param>
               <ctl:param name="HeIgHt">100</ctl:param>
               <ctl:param name="ElEvAtIoN">480</ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
</ctl:package>
<ctl:package xmlns:functions="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/functions.xml"
             xmlns:time="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/time.xml"
             xmlns:ccf="http://www.opengis.net/cite/complex"
             xmlns:cdf="http://www.opengis.net/cite/data"
             xmlns:cgf="http://www.opengis.net/cite/geometry"
             xmlns:citef="http://www.opengis.net/cite/functions"
             xmlns:ctl="http://www.occamlab.com/ctl"
             xmlns:gml="http://www.opengis.net/gml"
             xmlns:ogc="http://www.opengis.net/ogc"
             xmlns:parsers="http://www.occamlab.com/te/parsers"
             xmlns:saxon="http://saxon.sf.net/"
             xmlns:wms="http://www.opengis.net/wms"
             xmlns:xlink="http://www.w3.org/1999/xlink"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
             xmlns:wms-1.3.0="https://cite.opengeospatial.org/wms-1.3.0/src/ctl"
             xmlns:main="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/main.xml"
             xmlns:basic_elements="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic_elements.xml"
             xmlns:getcapabilities="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getcapabilities.xml"
             xmlns:getmap="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getmap.xml"
             xmlns:getfeatureinfo="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/getfeatureinfo.xml"
             xmlns:recommendations="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/recommendations.xml"
             xmlns:dims="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/dimensions.xml"
             xmlns:interactive="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/interactive.xml"
             xmlns:basic="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/basic.xml"
             xmlns:queryable="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/queryable.xml"
             xmlns:raster_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/raster_elevation.xml"
             xmlns:vector_elevation="https://cite.opengeospatial.org/wms-1.3.0/src/ctl/vector_elevation.xml"
             xmlns:xi="http://www.w3.org/2001/XInclude">
   <ctl:parser name="time:autos-parser">
      <ctl:java class="com.occamlab.te.parsers.ImageParser" method="parseAsInitialized"
                initialized="true">
         <ctl:with-param name="instructions">
            <parsers:ImageParser>
               <parsers:model value="RGB"><!-- 1: Auto 1.1 --><parsers:subimage x="135" y="105" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 2: Auto 1.2 --><parsers:subimage x="95" y="115" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 3: Auto 1.3 --><parsers:subimage x="60" y="125" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 4: Auto 1.4 --><parsers:subimage x="45" y="135" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 5: Auto 1.5 and Auto 2.8 --><parsers:subimage x="45" y="155" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 6: Auto 1.6 --><parsers:subimage x="45" y="185" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 7: Auto 1.7 --><parsers:subimage x="45" y="225" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 8: Auto 2.5 --><parsers:subimage x="45" y="5" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 9: Auto 2.6 --><parsers:subimage x="45" y="55" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 10: Auto 2.7 --><parsers:subimage x="45" y="105" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 11: Auto 2.9 --><parsers:subimage x="45" y="205" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 12: Auto 3.9 --><parsers:subimage x="75" y="215" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 13: Auto 3.10 --><parsers:subimage x="75" y="175" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 14: Auto 3.11 --><parsers:subimage x="75" y="135" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 15: Auto 3.12 --><parsers:subimage x="75" y="95" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 16: Auto 3.13 --><parsers:subimage x="75" y="55" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 17: Auto 4.12 --><parsers:subimage x="350" y="20" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
                  <!-- 18: Auto 4.13 --><parsers:subimage x="345" y="45" width="10" height="10">
                     <parsers:count bands="RGB" sample="0xffffff"/>
                  </parsers:subimage>
               </parsers:model>
            </parsers:ImageParser>
         </ctl:with-param>
      </ctl:java>
   </ctl:parser>
   <ctl:test name="time:time">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Time request behaves properly.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="time:options-requirements"/>
         <ctl:call-test name="time:dims"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:options-requirements">
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>The requirements for testing the selected options are met.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="time:time-options-requirements"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:dims">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Support for dimensional data is correct.</ctl:assertion>
      <ctl:code>
         <ctl:call-test name="time:time-dims"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:time-options-requirements">
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>The server supports the cite:Autos layer with a properly declared time dimenson.</ctl:assertion>
      <ctl:link title="Test requirements">docs/wms/1.3.0/#requirements</ctl:link>
      <ctl:code>
         <xsl:variable name="layer"
                       select="wms:Capability/wms:Layer/descendant-or-self::wms:Layer[wms:Title = 'cite:Autos']"/>
         <xsl:variable name="dim"
                       select="$layer/ancestor-or-self::wms:Layer/wms:Dimension[@name='time'][1]"/>
         <xsl:variable name="extent" select="concat(',', string($dim), ',')"/>
         <xsl:choose>
            <xsl:when test="not($layer/*)">
               <ctl:message>Error: No layer titled cite:Autos found.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:when test="not($dim/self::wms:Dimension)">
               <ctl:message>Error: The cite:Autos layer does not have an time dimension.</ctl:message>
               <ctl:fail/>
            </xsl:when>
            <xsl:otherwise>
               <xsl:if test="$dim/@units != 'ISO8601'">
                  <ctl:message>Error: The time dimension for the cite:Autos layer must be defined with units="ISO8601".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="functions:boolean-as-integer($dim/@multipleValues) != 1">
                  <ctl:message>Error: The time dimension for the cite:Autos layer must be defined with multipleValues="true".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="functions:boolean-as-integer($dim/@nearestValue) != 1">
                  <ctl:message>Error: The time dimension for the cite:Autos layer must be defined with nearestValue="true".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="not(contains($extent, ',2000-01-01T00:00:00Z/2000-01-01T00:01:00Z/PT5S,'))">
                  <ctl:message>Error: The time dimension for the cite:Autos layer must be defined using extent value "2000-01-01T00:00:00Z/2000-01-01T00:01:00Z/PT5S".</ctl:message>
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:time-dims">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Support for a layer that supports the time dimension is correct.</ctl:assertion>
      <ctl:code>
         <xsl:choose>
            <xsl:when test="//wms:Layer[wms:Title = 'cite:Autos']/ancestor-or-self::wms:Layer/wms:Dimension[functions:to-lowercase(@name)='time']">
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">1</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">2</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">3</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">4</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">5</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">6</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">7</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">8</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">9</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">10</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">11</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">12</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-each-instant">
                  <ctl:with-param name="instant-num">13</ctl:with-param>
               </ctl:call-test>
               <ctl:call-test name="time:time-interval"/>
               <ctl:call-test name="time:time-interval-and-instant"/>
               <ctl:call-test name="time:time-interval-list"/>
               <ctl:call-test name="time:time-instant-list"/>
               <ctl:call-test name="time:time-current-instant"/>
               <ctl:call-test name="time:time-current-interval"/>
               <ctl:call-test name="time:time-default"/>
               <!--                <ctl:call-test name="time:time-missing-dim"/> --><ctl:call-test name="time:time-and-other-layer"/>
            </xsl:when>
            <xsl:otherwise>
               <ctl:message>No layers titled cite:Autos that support the time dimension.</ctl:message>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:time-each-instant">
      <ctl:param name="instant-num"/>
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>For time instant {$instant-num}, the appropriate map is returned.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Autos']/wms:Name)"/>
         <xsl:variable name="instant">
            <xsl:text>2000-01-01T00:</xsl:text>
            <xsl:choose>
               <xsl:when test="$instant-num = 13">01:</xsl:when>
               <xsl:otherwise>00:</xsl:otherwise>
            </xsl:choose>
            <xsl:value-of select="format-number((($instant-num - 1) mod 12) * 5, '00')"/>
            <xsl:text>Z</xsl:text>
         </xsl:variable>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.0042,-0.0024,0.0042,0.0024</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">420</ctl:param>
               <ctl:param name="HeIgHt">240</ctl:param>
               <ctl:param name="TiMe">
                  <xsl:value-of select="functions:encode($instant)"/>
               </ctl:param>
               <time:autos-parser/>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:choose>
               <xsl:when test="$instant-num = 1">
                  <xsl:if test="number(parsers:subimage[1]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 17">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 2">
                  <xsl:if test="number(parsers:subimage[2]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 17">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 3">
                  <xsl:if test="number(parsers:subimage[3]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 17">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 4">
                  <xsl:if test="number(parsers:subimage[4]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 17">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 5">
                  <xsl:if test="number(parsers:subimage[5]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="number(parsers:subimage[8]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 16">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 6">
                  <xsl:if test="number(parsers:subimage[6]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="number(parsers:subimage[9]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 16">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 7">
                  <xsl:if test="number(parsers:subimage[7]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="number(parsers:subimage[10]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 16">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 8">
                  <xsl:if test="number(parsers:subimage[5]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 17">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 9">
                  <xsl:if test="number(parsers:subimage[11]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="number(parsers:subimage[12]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 16">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 10">
                  <xsl:if test="number(parsers:subimage[13]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 17">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 11">
                  <xsl:if test="number(parsers:subimage[14]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 17">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 12">
                  <xsl:if test="number(parsers:subimage[15]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="number(parsers:subimage[17]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 16">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
               <xsl:when test="$instant-num = 13">
                  <xsl:if test="number(parsers:subimage[16]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="number(parsers:subimage[18]/parsers:count) = 100">
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 16">
                     <ctl:fail/>
                  </xsl:if>
               </xsl:when>
            </xsl:choose>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:time-interval">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>For a time interval, the appropriate map is returned.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Autos']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.0042,-0.0024,0.0042,0.0024</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">420</ctl:param>
               <ctl:param name="HeIgHt">240</ctl:param>
               <ctl:param name="TiMe">
                  <xsl:value-of select="functions:encode('2000-01-01T00:00:50Z/2000-01-01T00:01:00Z')"/>
               </ctl:param>
               <time:autos-parser/>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="number(parsers:subimage[14]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[15]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[16]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[17]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[18]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 13">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:time-interval-and-instant">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>For a time value consiting of a time interval and a time instant, the appropriate map is returned.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Autos']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.0042,-0.0024,0.0042,0.0024</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">420</ctl:param>
               <ctl:param name="HeIgHt">240</ctl:param>
               <ctl:param name="TiMe">
                  <xsl:value-of select="functions:encode('2000-01-01T00:00:00Z')"/>
                  <xsl:text>,</xsl:text>
                  <xsl:value-of select="functions:encode('2000-01-01T00:00:50Z/2000-01-01T00:01:00Z')"/>
               </ctl:param>
               <time:autos-parser/>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="number(parsers:subimage[1]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[14]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[15]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[16]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[17]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[18]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 12">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:time-interval-list">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>For a time value consiting of a list of time intervals, the appropriate map is returned.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Autos']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.0042,-0.0024,0.0042,0.0024</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">420</ctl:param>
               <ctl:param name="HeIgHt">240</ctl:param>
               <ctl:param name="TiMe">
                  <xsl:value-of select="functions:encode('2000-01-01T00:00:00Z/2000-01-01T00:00:10Z')"/>
                  <xsl:text>,</xsl:text>
                  <xsl:value-of select="functions:encode('2000-01-01T00:00:50Z/2000-01-01T00:01:00Z')"/>
               </ctl:param>
               <time:autos-parser/>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="number(parsers:subimage[1]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[2]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[3]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[14]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[15]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[16]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[17]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[18]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 10">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:time-instant-list">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>For a time value consiting of a list of time instants, the appropriate map is returned.</ctl:assertion>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer" select="string(//wms:Layer[wms:Title = 'cite:Autos']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.0042,-0.0024,0.0042,0.0024</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">420</ctl:param>
               <ctl:param name="HeIgHt">240</ctl:param>
               <ctl:param name="TiMe">
                  <xsl:value-of select="functions:encode('2000-01-01T00:00:00Z')"/>
                  <xsl:text>,</xsl:text>
                  <xsl:value-of select="functions:encode('2000-01-01T00:01:00Z')"/>
               </ctl:param>
               <time:autos-parser/>
            </ctl:request>
         </xsl:variable>
         <xsl:for-each select="$response/parsers:ImageParser/parsers:model">
            <xsl:if test="number(parsers:subimage[1]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[16]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="number(parsers:subimage[18]/parsers:count) = 100">
               <ctl:fail/>
            </xsl:if>
            <xsl:if test="count(parsers:subimage/parsers:count[number(.) = 100]) != 15">
               <ctl:fail/>
            </xsl:if>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:time-current-instant">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>If the time dimension supports the current keyword, a request for TIME=current returns a map.</ctl:assertion>
      <ctl:comment><![CDATA[Method: If the dimension decalaration sets the current attribute, submit a request with TIME=current and verify that the service returns a map]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="layer"
                       select="string(//wms:Layer[wms:Name and ancestor-or-self::wms:Layer/wms:Dimension[@name='time' and (@current='1' or @current='true')]][1]/wms:Name)"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="$layer"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox"/>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No Named layers that support the current keyword for the time dimension.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="TiMe">current</ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:time-current-interval">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>If the time dimension supports the current keyword and advertises an interval ending with current, a request for that interval returns a map.</ctl:assertion>
      <ctl:comment><![CDATA[Method: If the dimension decalaration sets the current attribute and advertises an interval ending with current, submit a request with TIME=current and verify that the service returns a map]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.elevation_and_time</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="dimension"
                       select="//wms:Layer/wms:Dimension[@name='time' and (@current='1' or @current='true') and contains(., '/current')][1]"/>
         <xsl:variable name="layer"
                       select="string($dimension/../descendant-or-self::wms:Layer[wms:Name][1]/wms:Name)"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="$layer"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox"/>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No Named layers that advertise an interval ending with current for the time dimension.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <ctl:param name="TiMe">
                        <xsl:value-of select="functions:encode(fn:tokenize(string($dimension), ',\s*')[contains(., '/current')][1])"/>
                     </ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:time-default">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>If the dimension decalaration includes a default value, a request without a TIME parameter returns a map and sets the "default value used" warning header.</ctl:assertion>
      <ctl:comment><![CDATA[Method: If the dimension decalaration includes a default value, submit a request without a TIME parameter and verify that the service returns a map and sets the "default value used" warning header]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.4.2">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.responses.default</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[1]"/>
         <xsl:variable name="dimension"
                       select="//wms:Layer/wms:Dimension[@name='time' and @default][1]"/>
         <xsl:variable name="layer"
                       select="string($dimension/../descendant-or-self::wms:Layer[wms:Name][1]/wms:Name)"/>
         <xsl:variable name="layer-info">
            <ctl:call-function name="functions:layer-info">
               <ctl:with-param name="root-layer" select="wms:Capability/wms:Layer"/>
               <ctl:with-param name="preferred-name" select="$layer"/>
               <ctl:with-param name="preferred-crs">CRS:84</ctl:with-param>
               <ctl:with-param name="preferred-bbox"/>
               <ctl:with-param name="preferred-width">100</ctl:with-param>
               <ctl:with-param name="preferred-height">100</ctl:with-param>
            </ctl:call-function>
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="$layer = ''">
               <ctl:message>No Named layers with a default value for the time dimension.</ctl:message>
            </xsl:when>
            <xsl:otherwise>
               <xsl:variable name="response">
                  <ctl:request>
                     <ctl:url>
                        <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
                     </ctl:url>
                     <ctl:method>get</ctl:method>
                     <ctl:param name="LaYeRs">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@name)"/>
                     </ctl:param>
                     <ctl:param name="BbOx">
                        <xsl:value-of select="$layer-info/LayerInfo/@bbox"/>
                     </ctl:param>
                     <ctl:param name="CrS">
                        <xsl:value-of select="functions:encode($layer-info/LayerInfo/@crs)"/>
                     </ctl:param>
                     <ctl:param name="WiDtH">
                        <xsl:value-of select="$layer-info/LayerInfo/@width"/>
                     </ctl:param>
                     <ctl:param name="FoRmAt">
                        <xsl:value-of select="functions:encode($image-format)"/>
                     </ctl:param>
                     <ctl:param name="HeIgHt">
                        <xsl:value-of select="$layer-info/LayerInfo/@height"/>
                     </ctl:param>
                     <ctl:param name="VeRsIoN">
                        <xsl:value-of select="functions:version()"/>
                     </ctl:param>
                     <ctl:param name="StYlEs"/>
                     <ctl:param name="ReQuEsT">GetMap</ctl:param>
                     <parsers:HTTPParser>
                        <parsers:parse>
                           <parsers:NullParser/>
                        </parsers:parse>
                     </parsers:HTTPParser>
                  </ctl:request>
               </xsl:variable>
               <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
                  <ctl:message>Content-type header is not corrrect</ctl:message>
                  <ctl:fail/>
               </xsl:if>
               <xsl:if test="not($response/response/headers/header[@name='Warning' and starts-with(., '99 D') and starts-with(functions:to-lowercase(.), '99 default value used: time=') and starts-with(substring(., 29), $dimension/@default)])">
                  <ctl:message>A correct "Default value used" warning header was not set</ctl:message>
                  <ctl:fail/>
               </xsl:if>
            </xsl:otherwise>
         </xsl:choose>
      </ctl:code>
   </ctl:test>
   <ctl:test name="time:time-and-other-layer">
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>When a layer that supports time and other layers that do not support time are requested, the response is a map.</ctl:assertion>
      <ctl:comment><![CDATA[Method: Submit a request involving both the Autos layer and a layer that does not support the TIME dimension and verify that the response is a map]]></ctl:comment>
      <ctl:link title="WMS 1.3.0 section C.3.5">http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#dims.requests.applicability</ctl:link>
      <ctl:code>
         <xsl:variable name="image-format"
                       select="wms:Capability/wms:Request/wms:GetMap/wms:Format[starts-with(., 'image/png') or starts-with(., 'image/gif')][1]"/>
         <xsl:variable name="layer1"
                       select="string(//wms:Layer[wms:Title = 'cite:DividedRoutes']/wms:Name)"/>
         <xsl:variable name="layer2"
                       select="string(//wms:Layer[wms:Title = 'cite:RoadSegments']/wms:Name)"/>
         <xsl:variable name="layer3" select="string(//wms:Layer[wms:Title = 'cite:Autos']/wms:Name)"/>
         <xsl:variable name="response">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="wms:Capability/wms:Request/wms:GetMap/wms:DCPType/wms:HTTP/wms:Get/wms:OnlineResource/@xlink:href"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
               <ctl:param name="ReQuEsT">GetMap</ctl:param>
               <ctl:param name="VeRsIoN">
                  <xsl:value-of select="functions:version()"/>
               </ctl:param>
               <ctl:param name="BbOx">-0.0042,-0.0024,0.0042,0.0024</ctl:param>
               <ctl:param name="StYlEs"/>
               <ctl:param name="FoRmAt">
                  <xsl:value-of select="functions:encode($image-format)"/>
               </ctl:param>
               <ctl:param name="LaYeRs">
                  <xsl:value-of select="functions:encode($layer1)"/>
                  <xsl:text>,</xsl:text>
                  <xsl:value-of select="functions:encode($layer2)"/>
                  <xsl:text>,</xsl:text>
                  <xsl:value-of select="functions:encode($layer3)"/>
               </ctl:param>
               <ctl:param name="CrS">
                  <xsl:value-of select="functions:encode('CRS:84')"/>
               </ctl:param>
               <ctl:param name="WiDtH">420</ctl:param>
               <ctl:param name="HeIgHt">240</ctl:param>
               <ctl:param name="TiMe">
                  <xsl:value-of select="functions:encode('2000-01-01T00:00:30Z')"/>
               </ctl:param>
               <parsers:HTTPParser>
                  <parsers:parse>
                     <parsers:NullParser/>
                  </parsers:parse>
               </parsers:HTTPParser>
            </ctl:request>
         </xsl:variable>
         <xsl:if test="functions:mime-match($response/response/headers/header[functions:to-lowercase(@name) = 'content-type'], $image-format) = 'false'">
            <ctl:fail/>
         </xsl:if>
      </ctl:code>
   </ctl:test>
</ctl:package>
   <ctl:suite name="wms-1.3.0:ets-wms13">
      <ctl:title>Web Map Service (WMS) 1.3.0</ctl:title>
      <ctl:description>Validates that a WMS 1.3.0 is compliant.</ctl:description>
      <ctl:link>docs/wms/1.3.0/</ctl:link>
      <ctl:link>data/data-wms-1.3.0.zip</ctl:link>
      <ctl:starting-test>main:main</ctl:starting-test>
      <ctl:form>
         <h3>Web Map Service 1.3.0</h3>
         <h4>Test Overview and Reference Implementations</h4>
         <p>Complete information about this test suite can be found <a href="." target="_blank">here</a>.</p>
         <p>Reference implementations can be found <a href="http://cite.opengeospatial.org/reference" target="_blank">here</a>.</p>
         <br/>
         <h4>Capabilities Setup</h4>
         <p>
               Enter a capabilities document URL below. The URL may point to a static capabilities document or a GetCapabilities request from a WMS. A typical GetCapabilities request will look as follows:
            </p>
         <pre>http://hostname/path?SERVICE=WMS&amp;REQUEST=GetCapabilities&amp;VERSION=1.3.0</pre>
         <br/>
         <blockquote>
            <table border="3" padding="3">
               <tr>
                  <td align="center">
                     <input name="capabilities-url" size="100" type="text" value=""/>
                  </td>
                  <td align="left">Capabilities URL</td>
               </tr>
            </table>
         </blockquote>
         <br/>
         <h4>UpdateSequence Values</h4>
         <p>
               The WMS specification allows servers to use an UpdateSequence value for
               maintaining cache consistency as described in 
               <a href="http://cite.opengeospatial.org/OGCTestData/wms/1.3.0/spec/wms1_3.html#wmsops.getcapabilities.params.updatesequence">Section 7.2.3.5 of the specification</a>.
               If the server advertises an UpdateSequence value and the
               Automatic option is selected below, the test suite will attempt to
               test the UpdateSequence behavior automatically. However, the
               lexical ordering of UpdateSequence values is determined by the
               server, so the tests may not always be correct. If you suspect a
               problem, select the Manual option and enter the updateSequence
               values requested below.
            </p>
         <blockquote>
            <table border="3" padding="3">
               <tr>
                  <td align="center">
                     <input checked="checked" name="updatesequence" type="radio" value="auto"/>
                  </td>
                  <td align="left">Automatic - The updateSequence tests will use automatically generated updateSequence values</td>
               </tr>
               <tr>
                  <td align="center">
                     <input name="updatesequence" type="radio" value="manual"/>
                  </td>
                  <td align="left">Manual - The updateSequence tests will use the values supplied below</td>
               </tr>
            </table>
         </blockquote>
         <p>(Fill in these boxes if the Manual option is selected above)</p>
         <blockquote>
            <table border="3" padding="3">
               <tr>
                  <td align="center">
                     <input name="high-updatesequence" size="25" type="text" value=""/>
                  </td>
                  <td align="left">A value that is lexically higher than the current updateSequence value</td>
               </tr>
               <tr>
                  <td align="center">
                     <input name="low-updatesequence" size="25" type="text" value=""/>
                  </td>
                  <td align="left">A value that is lexically lower than the current updateSequence value</td>
               </tr>
            </table>
         </blockquote>
         <br/>
         <h4>Options</h4>
         <blockquote>
            <table border="3" padding="3">
               <tr>
                  <td align="center">
                     <input name="basic" type="checkbox" value="basic" checked="checked"/>
                  </td>
                  <td align="left">BASIC - Test basic functionality that depends on the CITE dataset.  This option is required for certification.</td>
               </tr>
               <tr>
                  <td align="center">
                     <input name="queryable" type="checkbox" value="queryable" checked="checked"/>
                  </td>
                  <td align="left">QUERYABLE - Test GetFeatureInfo functionality that depends on the CITE dataset.</td>
               </tr>
               <tr>
                  <td align="center">
                     <input name="raster_elevation" type="checkbox" value="raster_elevation"/>
                  </td>
                  <td align="left">RASTER ELEVATION - Test the elevation dimension using the cite:Terrain raster dataset.</td>
               </tr>
               <tr>
                  <td align="center">
                     <input name="vector_elevation" type="checkbox" value="vector_elevation"/>
                  </td>
                  <td align="left">VECTOR ELEVATION - Test the elevation dimension using the cite:Lakes vector dataset.</td>
               </tr>
               <tr>
                  <td align="center">
                     <input name="time" type="checkbox" value="time"/>
                  </td>
                  <td align="left">TIME - Test the time dimension using the cite:Autos dataset.</td>
               </tr>
               <tr>
                  <td align="center">
                     <input name="recommended" type="checkbox" value="recommended"/>
                  </td>
                  <td align="left">RECOMMENDATIONS - Test functionality which is recommended in the specification.</td>
               </tr>
            </table>
         </blockquote>
         <br/>
         <input type="submit" value="OK"/>
      </ctl:form>
   </ctl:suite>
   <ctl:test name="main:main">
      <ctl:param name="capabilities-url"/>
      <ctl:param name="updatesequence"/>
      <ctl:param name="high-updatesequence"/>
      <ctl:param name="low-updatesequence"/>
      <ctl:param name="basic"/>
      <ctl:param name="queryable"/>
      <ctl:param name="raster_elevation"/>
      <ctl:param name="vector_elevation"/>
      <ctl:param name="time"/>
      <ctl:param name="recommended"/>
      <ctl:assertion>The implementation under test complies with the WMS 1.3.0 specification.</ctl:assertion>
      <ctl:code>
         <xsl:variable name="capabilities">
            <ctl:request>
               <ctl:url>
                  <xsl:value-of select="$capabilities-url"/>
               </ctl:url>
               <ctl:method>get</ctl:method>
            </ctl:request>
         </xsl:variable>
         <xsl:variable name="high-updatesequence">
            <xsl:choose>
               <xsl:when test="$updatesequence = 'auto'">
                  <xsl:value-of select="functions:increment-updatesequence($capabilities/wms:WMS_Capabilities/@updateSequence, 1)"/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:value-of select="$high-updatesequence"/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         <xsl:variable name="low-updatesequence">
            <xsl:choose>
               <xsl:when test="$updatesequence = 'auto'">
                  <xsl:value-of select="functions:increment-updatesequence($capabilities/wms:WMS_Capabilities/@updateSequence, -1)"/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:value-of select="$low-updatesequence"/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         <xsl:if test="not($capabilities/wms:WMS_Capabilities)">
            <ctl:message>Error: The capabilities document does not contain a root element named WMS_Capabilities in the "http://www.opengis.net/wms" namespace.</ctl:message>
            <ctl:message>Further processing suspended.</ctl:message>
            <ctl:fail/>
         </xsl:if>
         <ctl:for-each select="$capabilities/wms:WMS_Capabilities">
            <ctl:call-test name="main:data-independent">
               <ctl:with-param name="high-updatesequence" select="$high-updatesequence"/>
               <ctl:with-param name="low-updatesequence" select="$low-updatesequence"/>
            </ctl:call-test>
            <xsl:if test="$basic='basic' or $queryable='queryable'">
               <ctl:call-test name="main:data-preconditions">
                  <ctl:with-param name="raster_elevation" select="$raster_elevation"/>
                  <ctl:with-param name="time" select="$time"/>
               </ctl:call-test>
            </xsl:if>
            <xsl:if test="$basic='basic'">
               <ctl:call-test name="basic:basic">
                  <ctl:with-param name="is-interactive-enabled" select="'yes'"/>
               </ctl:call-test>
            </xsl:if>
            <xsl:if test="$queryable='queryable'">
               <ctl:call-test name="queryable:queryable"/>
            </xsl:if>
            <xsl:if test="$raster_elevation='raster_elevation'">
               <ctl:call-test name="raster_elevation:raster_elevation"/>
            </xsl:if>
            <xsl:if test="$vector_elevation='vector_elevation'">
               <ctl:call-test name="vector_elevation:vector_elevation"/>
            </xsl:if>
            <xsl:if test="$time='time'">
               <ctl:call-test name="time:time"/>
            </xsl:if>
            <xsl:if test="$recommended = 'recommended'">
               <ctl:call-test name="recommendations:recommendations"/>
            </xsl:if>
         </ctl:for-each>
      </ctl:code>
   </ctl:test>
   <ctl:test name="main:data-independent">
      <ctl:param name="high-updatesequence"/>
      <ctl:param name="low-updatesequence"/>
      <ctl:context>WMS_Capabilities element</ctl:context>
      <ctl:assertion>Dataset independent request behaves properly.</ctl:assertion>
      <ctl:code>
         <xsl:variable name="exhaustive">
            <xsl:if xmlns:te="http://www.occamlab.com/te" test="function-available('te:isWeb')">
               <xsl:if test="string(te:isWeb()) = 'false'">
                  <xsl:variable name="form-results">
                     <xsl:variable name="combinations">
                        <xsl:for-each select="//wms:Layer[wms:Name]">
                           <xsl:for-each select="ancestor-or-self::wms:Layer/wms:CRS[not(. = ../ancestor::wms:Layer/wms:CRS)]">
                              <x/>
                           </xsl:for-each>
                        </xsl:for-each>
                     </xsl:variable>
                     <ctl:form>
                        <p>
                           Do you want to exhaustively test each Layer/CRS combination?<br/>
                           There are <xsl:value-of select="count($combinations/x)"/> combinations to test.
                        </p>
                        <p>
                           <input type="submit" name="answer" value="yes"/>
                           <input type="submit" name="answer" value="no"/>
                        </p>
                     </ctl:form>
                  </xsl:variable>
                  <xsl:if test="$form-results/values/value[@key='answer']='yes'">exhaustive</xsl:if>
               </xsl:if>
            </xsl:if>
         </xsl:variable>
         <ctl:call-test name="interactive:interactive"/>
         <ctl:call-test name="basic_elements:basic_elements"/>
         <ctl:call-test name="getcapabilities:getcapabilities">
            <ctl:with-param name="high-updatesequence" select="$high-updatesequence"/>
            <ctl:with-param name="low-updatesequence" select="$low-updatesequence"/>
         </ctl:call-test>
         <ctl:call-test name="getmap:getmap">
            <ctl:with-param name="exhaustive" select="$exhaustive"/>
         </ctl:call-test>
         <ctl:call-test name="getfeatureinfo:getfeatureinfo"/>
         <ctl:call-test name="dims:dims"/>
      </ctl:code>
   </ctl:test>
   <ctl:test name="main:data-preconditions">
      <ctl:param name="raster_elevation"/>
      <ctl:param name="time"/>
      <ctl:context>Capabilities XML</ctl:context>
      <ctl:assertion>The server implements the CITE standard dataset in subsettable, resizable layers that support CRS:84.</ctl:assertion>
      <ctl:link title="Test requirements">docs/wms/1.3.0/#requirements</ctl:link>
      <ctl:code>
         <xsl:variable name="root-layer" select="wms:Capability/wms:Layer"/>
         <xsl:variable name="titles">
            <title>cite:BasicPolygons</title>
            <title>cite:Bridges</title>
            <title>cite:Buildings</title>
            <title>cite:DividedRoutes</title>
            <title>cite:Forests</title>
            <title>cite:Lakes</title>
            <title>cite:MapNeatline</title>
            <title>cite:NamedPlaces</title>
            <title>cite:Ponds</title>
            <title>cite:RoadSegments</title>
            <title>cite:Streams</title>
            <xsl:if test="$raster_elevation='raster_elevation'">
               <title>cite:Terrain</title>
            </xsl:if>
            <xsl:if test="$time='time'">
               <title>cite:Autos</title>
            </xsl:if>
         </xsl:variable>
         <xsl:for-each select="$titles/title">
            <xsl:variable name="title" select="."/>
            <xsl:variable name="layer"
                          select="$root-layer/descendant-or-self::wms:Layer[wms:Title = $title]"/>
            <xsl:choose>
               <xsl:when test="not($layer/wms:Title)">
                  <ctl:message>Error: No layer titled <xsl:value-of select="$title"/> found.</ctl:message>
                  <ctl:fail/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:if test="not($layer/ancestor-or-self::wms:Layer[wms:CRS = 'CRS:84'])">
                     <ctl:message>Error: Layer titled <xsl:value-of select="$title"/> must support CRS:84.</ctl:message>
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="functions:boolean-as-integer($layer/@noSubsets) = 1">
                     <ctl:message>Error: Layer titled <xsl:value-of select="$title"/> must allow subsets.</ctl:message>
                     <ctl:fail/>
                  </xsl:if>
                  <xsl:if test="functions:boolean-as-integer($layer/@fixedWidth) != 0">
                     <ctl:message>Error: Layer titled <xsl:value-of select="$title"/> must not have a fixed size.</ctl:message>
                     <ctl:fail/>
                  </xsl:if>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:for-each>
      </ctl:code>
   </ctl:test>
</ctl:package>