Skip to content

Commit f33781f

Browse files
committed
add for <begin|end> and handle gml OLD and gml 3.2
1 parent 6041707 commit f33781f

File tree

2 files changed

+144
-8
lines changed

2 files changed

+144
-8
lines changed

schemas/iso19139/src/main/plugin/iso19139/layout/layout-custom-fields.xsl

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,128 @@
151151
152152
-->
153153

154+
<xsl:template mode="mode-iso19139"
155+
match="gml320:TimeInstant[gml320:timePosition]|gml:TimeInstant[gml:timePosition]"
156+
priority="50000">
157+
158+
<xsl:variable name="configName" select="concat(local-name(..),'Position')"/>
159+
<!-- 'temporalRangeSection' this is the name of the section (defined elsewhere)
160+
and uses to find the translated tag for the section in the UI -->
161+
<xsl:variable name="translation"
162+
select="$strings/*[name() = $configName]"/>
163+
<xsl:variable name="name"
164+
select="if ($translation != '')
165+
then $translation
166+
else $configName"/>
167+
168+
<xsl:variable name="id" select="concat('_X', gn:element/@ref, '_replace')"/>
169+
170+
<xsl:variable name="isFirst" select="position() = 1"/>
171+
<xsl:variable name="originalNode"
172+
select="gn-fn-metadata:getOriginalNode($metadata, .)"/>
173+
<xsl:variable name="del" select="./@del"/>
174+
175+
<xsl:variable name="refToDelete">
176+
<xsl:call-template name="get-ref-element-to-delete">
177+
<xsl:with-param name="node" select="$originalNode"/>
178+
<xsl:with-param name="delXpath" select="$del"/>
179+
</xsl:call-template>
180+
</xsl:variable>
181+
182+
<xsl:variable name="parent_parent" select="."/>
183+
184+
<!-- look at the actual XML's gml namespace URI
185+
if its GML 32, then that matches most of the implicit
186+
assumptions inside GN. Especially the JS, which assumes that
187+
an element with a "gml:" prefix is GML 3.2.
188+
However, this is a really bad assumption - all the iso19139 sample data
189+
has "gml:" as the old (NOT GML 3.2).
190+
Also, in this XSLT;
191+
"gml:" - version 3.2
192+
"gml320:" - OLD VERSION (!!!!!!!!)
193+
-->
194+
<xsl:variable name="element_ns_uri" select="namespace-uri()"/>
195+
<xsl:variable name="element_ns_prefix" select="prefix-from-QName(node-name(.))"/>
196+
<xsl:variable name="gml_is_32" select="$element_ns_uri = 'http://www.opengis.net/gml/3.2'"/>
197+
<xsl:variable name="timeinstance_id" select="@*[local-name() = 'id']"/>
198+
199+
<xsl:variable name="prefix_to_use">gml</xsl:variable>
200+
201+
<xsl:variable name="prefix_to_use_select">
202+
<xsl:choose>
203+
<xsl:when test="$gml_is_32">gml</xsl:when>
204+
<xsl:otherwise>gml320</xsl:otherwise>
205+
</xsl:choose>
206+
</xsl:variable>
207+
208+
209+
<xsl:variable name="label_node" select="local-name(..)"/>
210+
211+
212+
<xsl:variable name="template">
213+
<template xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gn="http://www.fao.org/geonetwork" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gmx="http://www.isotc211.org/2005/gmx" xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:xlink="http://www.w3.org/1999/xlink">
214+
<values>
215+
<key
216+
xpath="."
217+
use="gn-date-picker"
218+
tooltip="gmd:extent|gmd:EX_TemporalExtent">
219+
<xsl:attribute name="label" select="$label_node"/>
220+
221+
<directiveAttributes
222+
data-assume-gml-ns="true"
223+
>
224+
<xsl:attribute name="data-indeterminate-position" select="concat('eval#',$prefix_to_use_select,':timePosition/@indeterminatePosition')"/>
225+
<xsl:attribute name="data-tag-name" select="concat($prefix_to_use,':timePosition')"/>
226+
227+
</directiveAttributes>
228+
</key>
229+
</values>
230+
<snippet>
231+
<!-- this is more explicitly done, below -->
232+
<gml:TimeInstant>
233+
{{<xsl:copy-of select="local-name(..)"/>}}
234+
</gml:TimeInstant>
235+
</snippet>
236+
</template>
237+
</xsl:variable>
238+
239+
<xsl:variable name="keyValues">
240+
<xsl:call-template name="build-key-value-configuration">
241+
<xsl:with-param name="template" select="$template/template"/>
242+
<xsl:with-param name="currentNode" select="$parent_parent"/>
243+
<xsl:with-param name="readonly" select="'false'"/>
244+
</xsl:call-template>
245+
</xsl:variable>
246+
247+
<xsl:variable name="templateCombinedWithNode" as="node()">
248+
<template>
249+
<xsl:copy-of select="$template/template/values"/>
250+
251+
<xsl:element name="snippet" inherit-namespaces="no">
252+
<xsl:attribute name="data-remove-gn-ns-def">true</xsl:attribute>
253+
254+
<xsl:element name="gml:TimeInstant" namespace="{$element_ns_uri}" inherit-namespaces="no">
255+
<xsl:attribute namespace="{$element_ns_uri}" name="gml:id"><xsl:value-of select="$timeinstance_id"/></xsl:attribute>
256+
{{<xsl:copy-of select="local-name(..)"/>}}
257+
</xsl:element>
258+
259+
260+
</xsl:element>
261+
</template>
262+
</xsl:variable>
263+
264+
265+
<xsl:call-template name="render-element-template-field">
266+
<xsl:with-param name="name" select="$name"/>
267+
<xsl:with-param name="id" select="$id"/>
268+
<xsl:with-param name="isExisting" select="true()"/>
269+
<xsl:with-param name="template" select="$templateCombinedWithNode"/>
270+
<xsl:with-param name="keyValues" select="$keyValues"/>
271+
<xsl:with-param name="refToDelete" select="$refToDelete/gn:element"/>
272+
<xsl:with-param name="isFirst" select="$isFirst"/>
273+
</xsl:call-template>
274+
</xsl:template>
275+
154276
<!---
155277
For temporal extent, we want a more complicated control.
156278
This will allow the <beginPosition indeterminatePosition="now"></beginPosition>
@@ -163,7 +285,7 @@
163285
This is basically a stand-in for the <field name="temporalRangeSection"> and uses the same template to do the controls.
164286
-->
165287
<xsl:template mode="mode-iso19139"
166-
match="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement"
288+
match="gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement[//gml:beginPosition]"
167289
priority="30000">
168290
<xsl:variable name="xpath" select="gn-fn-metadata:getXPath(.)"/>
169291
<xsl:variable name="isoType" select="if (../@gco:isoType) then ../@gco:isoType else ''"/>
@@ -239,6 +361,7 @@
239361
</xsl:call-template>
240362
</xsl:variable>
241363

364+
242365
<xsl:variable name="templateCombinedWithNode" as="node()">
243366
<template>
244367
<xsl:copy-of select="$template/template/values"/>
@@ -268,8 +391,8 @@
268391
<!-- ===================================================================== -->
269392

270393
<xsl:template mode="mode-iso19139"
271-
match="gml:beginPosition|gml:endPosition|gml:timePosition|
272-
gml320:beginPosition|gml320:endPosition|gml320:timePosition"
394+
match="gml:beginPosition|gml:endPosition|
395+
gml320:beginPosition|gml320:endPosition"
273396
priority="200">
274397

275398
<xsl:variable name="xpath" select="gn-fn-metadata:getXPath(.)"/>

web-ui/src/main/resources/catalog/components/edit/datepicker/DatePickerDirective.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
elementRef: "@",
6666
id: "@",
6767
tagName: "@",
68+
assumeGmlNs: "@",
6869
indeterminatePosition: "@",
6970
required: "@",
7071
hideTime: "@",
@@ -279,14 +280,26 @@
279280
scope.dateTime = "";
280281
}
281282

283+
//if we don't know what this namespace is (findNamespaceUri returns undefined),
284+
//then we don't add it!
285+
var elementNSDef = "";
286+
var namespaceURI = gnSchemaManagerService.findNamespaceUri(
287+
namespace,
288+
gnCurrentEdit.schema
289+
);
290+
if (namespaceURI !== undefined) {
291+
elementNSDef = " xmlns:" + namespace + '="' + namespaceURI + '"';
292+
}
293+
294+
//if data-assume-gml-ns is set, then don't put in the NS declaration
295+
if (scope.assumeGmlNs === "true" && namespace === "gml") {
296+
elementNSDef = "";
297+
}
298+
282299
scope.xmlSnippet =
283300
"<" +
284301
tag +
285-
" xmlns:" +
286-
namespace +
287-
'="' +
288-
gnSchemaManagerService.findNamespaceUri(namespace, gnCurrentEdit.schema) +
289-
'"' +
302+
elementNSDef +
290303
attribute +
291304
">" +
292305
scope.dateTime +

0 commit comments

Comments
 (0)