Project

General

Profile

1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!--
3
Description: parses a EBRIM response from a Catalog Query and returns
4
             an OWS Context document.
5
             This stylesheet assumes the Service node follows the
6
             IntrinsicObject (Layer) node.
7
Author:      camerons
8
Licence:     LGPL as specified in http://www.gnu.org/copyleft/lesser.html .
9

    
10
$Id:$
11
$Name:  $
12
-->
13

    
14
<xsl:stylesheet version="1.0" 
15
    xmlns:wmc="http://www.opengis.net/context" 
16
    xmlns:wms="http://www.opengis.net/wms"
17
    xmlns:ogc="http://www.opengis.net/ogc"
18
    xmlns:ows="http://www.opengis.net/ows"
19
    xmlns:csw="http://www.opengis.net/cat/csw"
20
    xmlns:gml="http://www.opengis.net/gml"
21
    xmlns:rim="urn:oasis:names:tc:ebxml-regrep:rim:xsd:2.5"
22
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23
    xmlns:wfs="http://www.opengis.net/wfs" 
24
    xmlns:sld="http://www.opengis.net/sld"
25
    xmlns:owscat="http://www.ec.gc.ca/owscat"
26
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
27
    xmlns:xlink="http://www.w3.org/1999/xlink">
28

    
29
  <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes"/>
30
  <xsl:strip-space elements="*"/>
31

    
32
  <!-- The coordinates of the DHTML Layer on the HTML page -->
33
  <xsl:param name="modelId"/>
34
  <xsl:param name="widgetId"/>
35
  <xsl:param name="id"></xsl:param>
36
  
37
  <!-- Match Root -->
38
  <xsl:template match="/">
39
    <wmc:OWSContext>
40
		  <wmc:General>
41
		    <wmc:Window width="600" height="300"/>
42
		    <ows:BoundingBox crs="EPSG:4326">
43
		      <ows:LowerCorner>-180 -90</ows:LowerCorner>
44
		      <ows:UpperCorner>180 90</ows:UpperCorner>
45
		    </ows:BoundingBox>
46
		    <wmc:Title xml:lang="en">Mapbuilder Generated Context</wmc:Title>
47
		  </wmc:General>
48
      <wmc:ResourceList>
49
        <xsl:apply-templates/>
50
      </wmc:ResourceList>
51
    </wmc:OWSContext>
52
  </xsl:template>
53

    
54
  <!-- Match Layer (ExtrinsicObject -->
55
  <xsl:template match="rim:ExtrinsicObject">
56

    
57
    <!-- When layer is WFS: FeatureType -->
58
    <!-- When layer is WMS: Layer       -->
59
    <!-- else (fallback)  : Layer       -->
60
    <xsl:variable name="element_name">
61
      <xsl:variable name="pos" select="position()"/>
62
      <xsl:variable name="servicetype" select="../rim:Service[(($pos+1) div 2)]/rim:Slot[@name='Service Type']/rim:ValueList/rim:Value"/>
63
      <xsl:choose>
64
        <xsl:when test="($servicetype = 'WFS') or ($servicetype = 'OGC:WFS')">FeatureType</xsl:when>
65
        <xsl:when test="($servicetype = 'WMS') or ($servicetype = 'OGC:WMS')">Layer</xsl:when>
66
        <xsl:otherwise>Layer</xsl:otherwise>
67
      </xsl:choose>
68
    </xsl:variable>
69

    
70
    <xsl:variable name="queryable" select="./rim:Slot[@name='Queryable']/rim:ValueList/rim:Value/text()"/>
71

    
72
    <!-- If a layer is a 'Theme', then don't return anything, since it is'nt a queryable layer.
73
         A theme is a meta layer for grouping (WMS) layers
74
    -->
75
    <xsl:if test="@objectType != 'Theme'">
76
      <xsl:element name="wmc:{$element_name}">
77
          <xsl:attribute name="queryable">1</xsl:attribute>
78
          <xsl:attribute name="hidden">0</xsl:attribute>
79
          <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
80
          <!-- insert service -->
81
          <!--xsl:apply-templates select="//rim:Service[position()=(position()+1)]"/-->
82
          <xsl:call-template name="Service">
83
            <xsl:with-param name="pos" select="position()"/>
84
          </xsl:call-template>
85
          <wmc:Name>
86
            <xsl:value-of select="rim:Name/rim:LocalizedString/@value"/>
87
          </wmc:Name>
88
          <wmc:Title>
89
            <xsl:value-of select="rim:Slot[@name='Title']//rim:Value"/>
90
          </wmc:Title>
91
          <wmc:Abstract>
92
            <xsl:value-of select="rim:Description/rim:LocalizedString/@value"/>
93
          </wmc:Abstract>
94
      </xsl:element>
95
    </xsl:if>
96
  </xsl:template>
97

    
98
  <!-- Match Service -->
99
  <!-- xsl:template match="rim:Service[position()={$pos}]"-->
100
  <xsl:template name="Service">
101
    <xsl:param name="pos"/>
102
  
103
    <xsl:for-each select="../rim:Service[(($pos+1) div 2)]">
104
	    <wmc:Server>
105
	      <xsl:attribute name="id">
106
	        <xsl:value-of select="@id"/>
107
	      </xsl:attribute>
108
	      <xsl:attribute name="service">
109
	        <xsl:value-of select="rim:Slot[@name='Service Type']//rim:Value"/>
110
	      </xsl:attribute>
111
	      <xsl:attribute name="version">
112
	        <xsl:value-of select="@userVersion"/>
113
	      </xsl:attribute>
114
	      <xsl:attribute name="title">
115
	        <xsl:value-of select="rim:Slot[@name='Title']//rim:Value"/>
116
	      </xsl:attribute>
117
	      <!-- TBD: How do we extract method=POST/GET? -->
118
	      <wmc:OnlineResource method="POST" xlink:type="simple">
119
	        <xsl:attribute name="xlink:href">
120
	          <xsl:value-of select=".//@accessURI"/><!-- works for cubewerx -->
121
	        </xsl:attribute>
122
	      </wmc:OnlineResource>
123
	    </wmc:Server>
124
    </xsl:for-each>
125

    
126
  </xsl:template>
127
  
128
  <xsl:template match="text()|@*"/>
129
  
130
</xsl:stylesheet>
(14-14/19)