layout-custom-fields.xsl 12.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gts="http://www.isotc211.org/2005/gts"
  xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmx="http://www.isotc211.org/2005/gmx"
  xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink"
	xmlns:mcp="http://bluenet3.antcrc.utas.edu.au/mcp"
  xmlns:gn="http://www.fao.org/geonetwork"
  xmlns:gn-fn-core="http://geonetwork-opensource.org/xsl/functions/core"
  xmlns:gn-fn-metadata="http://geonetwork-opensource.org/xsl/functions/metadata"
  xmlns:gn-fn-iso19139="http://geonetwork-opensource.org/xsl/functions/profiles/iso19139"
  xmlns:exslt="http://exslt.org/common" exclude-result-prefixes="#all">

  <!-- Readonly elements -->
  <xsl:template mode="mode-iso19139" priority="2000" match="mcp:revisionDate">

    <xsl:call-template name="render-element">
      <xsl:with-param name="label" select="gn-fn-metadata:getLabel($schema, name(), $labels)/label"/>
      <xsl:with-param name="value" select="*"/>
      <xsl:with-param name="cls" select="local-name()"/>
      <xsl:with-param name="xpath" select="gn-fn-metadata:getXPath(.)"/>
ByronCinNZ's avatar
ByronCinNZ committed
22
      <!--<xsl:with-param name="type" select="gn-fn-metadata:getFieldType($editorConfig, name(), '')"/>-->
23 24 25 26 27 28 29 30
      <xsl:with-param name="name" select="''"/>
      <xsl:with-param name="editInfo" select="*/gn:element"/>
      <xsl:with-param name="parentEditInfo" select="gn:element"/>
      <xsl:with-param name="isDisabled" select="true()"/>
    </xsl:call-template>

  </xsl:template>

ByronCinNZ's avatar
ByronCinNZ committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
	
  <!-- Custom rendering of resource constraints section 
    * gmd:resourceConstraints is boxed element and the title 
    * of the fieldset is the creative commons license name
  -->
  <xsl:template mode="mode-iso19139" priority="33000" match="gmd:resourceConstraints">
    <xsl:param name="schema" select="'iso19139.mcp-1.4'" required="no"/>
    <xsl:param name="labels" select="$labels" required="no"/>

    <xsl:variable name="xpath" select="gn-fn-metadata:getXPath(.)"/>
    <xsl:variable name="isoType" select="if (../@gco:isoType) then ../@gco:isoType else ''"/>
		<!-- where is /root/gui/schemas/iso19139.mcp-1.4/strings? -->
    <xsl:variable name="resourceConstraintsTitle"
      select="if (mcp:MD_Commons) then 'Creative Commons License' else ''"/>

    <xsl:variable name="attributes">
      <xsl:if test="$isEditing">
        <!-- Create form for all existing attribute (not in gn namespace)
        and all non existing attributes not already present. -->
        <xsl:apply-templates mode="render-for-field-for-attribute"
          select="
          @*|
          gn:attribute[not(@name = parent::node()/@*/name())]">
          <xsl:with-param name="ref" select="gn:element/@ref"/>
          <xsl:with-param name="insertRef" select="gn:element/@ref"/>
        </xsl:apply-templates>
      </xsl:if>
    </xsl:variable>

    <xsl:call-template name="render-boxed-element">
      <xsl:with-param name="label"
        select="if ($resourceConstraintsTitle!='') 
                then $resourceConstraintsTitle 
                else gn-fn-metadata:getLabel($schema, name(), $labels, name(..), $isoType, $xpath)/label"/>
      <xsl:with-param name="editInfo" select="gn:element"/>
      <xsl:with-param name="cls" select="local-name()"/>
      <xsl:with-param name="xpath" select="$xpath"/>
      <xsl:with-param name="attributesSnippet" select="$attributes"/>
      <xsl:with-param name="subTreeSnippet">
        <xsl:apply-templates mode="mode-iso19139" select="*">
          <xsl:with-param name="schema" select="$schema"/>
          <xsl:with-param name="labels" select="$labels"/>
        </xsl:apply-templates>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>

  <!-- Creative Commons License Picker -->
  <xsl:template mode="mode-iso19139" match="mcp:MD_Commons" priority="33000">
    <xsl:param name="schema" select="'iso19139.mcp-1.4'" required="no"/>
    <xsl:param name="labels" select="$labels" required="no"/>

    <xsl:variable name="jurisdictionUrl"
      select="mcp:jurisdictionLink/gmd:URL"/>
    <xsl:variable name="licenseUrl"
      select="mcp:licenseLink/gmd:URL"/>
    <xsl:variable name="licenseImageUrl"
      select="mcp:imageLink/gmd:URL"/>
    <xsl:variable name="licenseName"
      select="mcp:licenseName/gco:CharacterString"/>


    <!-- Create custom widget: 
              * '' for item selector, 
              * 'tagsinput' for tags
              * 'tagsinput' and maxTags = 1 for only one tag
              * 'multiplelist' for multiple selection list
    -->
    <xsl:variable name="widgetMode" select="'tagsinput'"/>
    <xsl:variable name="maxTags" select="'1'"/>

		<div>
		 	<label class="col-sm-2 control-label" data-gn-field-tooltip="{$schema}|{name()}|{name(..)}|"><xsl:value-of select="gn-fn-metadata:getLabel($schema, name(), $labels)/label"/></label>
		</div>
    <!-- Create a div with the angular directive configuration
            * widgetMode: the layout to use
            * elementRef: the element ref to edit
            * jurisdictionUrl: current jurisdiction
            * namespace: current mcp namespace
            * licenseName: current license name
            * licenseUrl: current license url
            * licenseImageUrl: current license image url
     -->
    <div data-gn-commons-jurisdiction-selector="{$widgetMode}"
          data-metadata-id="{$metadataId}"
          data-element-ref="{../gn:element/@ref}"
          data-jurisdiction-url="{$jurisdictionUrl}"
          data-namespace="{namespace-uri()}"
          data-license-name="{$licenseName}"
          data-license-url="{$licenseUrl}"
          data-license-image-url="{$licenseImageUrl}">
		</div>

  </xsl:template>

<!--
				<mcp:parameterName>
          <mcp:DP_Term>
            <mcp:term>
              <gco:CharacterString>t</gco:CharacterString>
            </mcp:term>
            <mcp:type>
              <mcp:DP_TypeCode
          codeList="http://bluenet3.antcrc.utas.edu.au/mcp/resources/Codelist/gmxCodelists.xml#DP_TypeCode"
          codeListValue="shortName">shortName</mcp:DP_TypeCode>
            </mcp:type>
            <mcp:usedInDataset>
              <gco:Boolean>1</gco:Boolean>
            </mcp:usedInDataset>
            <mcp:vocabularyRelationship>
              <mcp:DP_VocabularyRelationship>
                <mcp:relationshipType>
                  <mcp:DP_RelationshipTypeCode
          codeList="http://bluenet3.antcrc.utas.edu.au/mcp/resources/Codelist/gmxCodelists.xml#DP_RelationshipTypeCode"
          codeListValue="skos:exactmatch">skos:exactmatch</mcp:DP_RelationshipTypeCode>
                </mcp:relationshipType>
                <mcp:vocabularyTermURL>
                 <gmd:URL>http://www.imos.org.au/vocabserver?code=temperature&vocab=oceanography</gmd:URL>
                </mcp:vocabularyTermURL>
                <mcp:vocabularyListURL>
                 <gmd:URL>http://www.imos.org.au/vocabserver?vocab=oceanography</gmd:URL>
                </mcp:vocabularyListURL>
                <mcp:vocabularyListVersion>
                  <gco:CharacterString>3.6</gco:CharacterString>
                </mcp:vocabularyListVersion>
              </mcp:DP_VocabularyRelationship>
            </mcp:vocabularyRelationship>
          </mcp:DP_Term>
        </mcp:parameterName>
-->
	
  <!-- Custom rendering of mcp:parameterName|mcp:parameterUnits section 
    * mcp:parameterName|mcp:parameterUnits is boxed element and the title 
    of the fieldset is mcp:parameterName (thesaurus title) or 
    mcp:parameterUnits (thesaurus title)
    * if the thesaurus is available in the catalog, display
    the advanced editor which provides easy selection of 
    keywords.
  
  -->


  <xsl:template mode="mode-iso19139" priority="9999999" match="mcp:parameterName|mcp:parameterUnits">
    <xsl:param name="schema" select="$schema" required="no"/>
    <xsl:param name="labels" select="$labels" required="no"/>

    <xsl:variable name="xpath" select="gn-fn-metadata:getXPath(.)"/>
    <xsl:variable name="isoType" select="if (../@gco:isoType) then ../@gco:isoType else ''"/>
    <xsl:variable name="thesaurusUrl"
      select="mcp:DP_Term/mcp:vocabularyRelationship/mcp:DP_VocabularyRelationship/mcp:vocabularyListURL/gmd:URL"/>

    <xsl:variable name="isThesaurusAvailable"
      select="count($listOfThesaurus/thesaurus[url=$thesaurusUrl]) > 0"/>

		<xsl:variable name="thesaurusTitle" select="if ($isThesaurusAvailable) then
									$listOfThesaurus/thesaurus[url=$thesaurusUrl]/title
									else 'Thesaurus Not Available'"/>

    <xsl:variable name="attributes">
      <xsl:if test="$isEditing">
        <!-- Create form for all existing attribute (not in gn namespace)
        and all non existing attributes not already present. -->
        <xsl:apply-templates mode="render-for-field-for-attribute"
          select="
          @*|
          gn:attribute[not(@name = parent::node()/@*/name())]">
          <xsl:with-param name="ref" select="gn:element/@ref"/>
          <xsl:with-param name="insertRef" select="gn:element/@ref"/>
        </xsl:apply-templates>
      </xsl:if>
    </xsl:variable>

    <xsl:call-template name="render-boxed-element">
      <xsl:with-param name="label"
        select="concat(gn-fn-metadata:getLabel($schema, name(), $labels, name(..), $isoType, $xpath)/label,' (',$thesaurusTitle,')')"/>
      <xsl:with-param name="editInfo" select="gn:element"/>
      <xsl:with-param name="cls" select="local-name()"/>
      <xsl:with-param name="xpath" select="$xpath"/>
      <xsl:with-param name="attributesSnippet" select="$attributes"/>
      <xsl:with-param name="subTreeSnippet">
        <xsl:apply-templates mode="mode-iso19139" select="*">
          <xsl:with-param name="schema" select="$schema"/>
          <xsl:with-param name="labels" select="$labels"/>
        </xsl:apply-templates>
      </xsl:with-param>
    </xsl:call-template>

  </xsl:template>

	<!-- Offer a thesaurus picker for mcp:DP_Term -->

  <xsl:template mode="mode-iso19139" match="mcp:DP_Term" priority="9999999">

    <xsl:variable name="thesaurusUrl"
      select="mcp:vocabularyRelationship/mcp:DP_VocabularyRelationship/mcp:vocabularyListURL/gmd:URL"/>

    <xsl:variable name="isThesaurusAvailable"
      select="count($listOfThesaurus/thesaurus[url=$thesaurusUrl]) > 0"/>
    <xsl:choose>
      <xsl:when test="$isThesaurusAvailable">

        <!-- The thesaurus key is in the list of thesauri based on its url -->
        <xsl:variable name="thesaurusInternalKey"
          select="$listOfThesaurus/thesaurus[url=$thesaurusUrl]/key"/>
        <xsl:variable name="thesaurusKey"
                      select="if (starts-with($thesaurusInternalKey, 'geonetwork.thesaurus.'))
                      then substring-after($thesaurusInternalKey, 'geonetwork.thesaurus.')
                      else $thesaurusInternalKey"/>

        <xsl:variable name="params" select="string-join(mcp:term/*[1], '`')"/>

        <!-- Define the list of transformation mode available. -->
        <xsl:variable name="transformations">to-mcp-dataparameterterm</xsl:variable>

        <!-- Get current transformation mode (could be based on XML fragment 
             analysis but not in this case - only one mode) -->
				<!-- default if no keywords (ie. new block) is to-mcp-dataparameterterm -->
        <xsl:variable name="transformation" select="'to-mcp-dataparameterterm'"/> 

        <!-- Create custom widget: 
              * '' for item selector, 
              * 'tagsinput' for tags
              * 'tagsinput' and maxTags = 1 for only one tag
              * 'multiplelist' for multiple selection list
        -->
        <xsl:variable name="widgetMode" select="'tagsinput'"/>
        <xsl:variable name="maxTags" select="'1'"/>

        <!-- Create a div with the directive configuration
            * widgetMod: the layout to use
            * elementRef: the element ref to edit
            * elementName: the element name
            * thesaurusName: the thesaurus title to use
            * thesaurusKey: the thesaurus identifier
            * keywords: list of keywords in the element
            * transformations: list of transformations
            * transformation: current transformation
          -->
        <div data-gn-keyword-selector="{$widgetMode}"
          data-metadata-id="{$metadataId}"
          data-element-ref="{concat('_X', ../gn:element/@ref)}"
          data-thesaurus-title="{$thesaurusKey}"
          data-thesaurus-key="{$thesaurusKey}"
          data-keywords="{$params}" data-transformations="{$transformations}"
          data-current-transformation="{$transformation}"
          data-max-tags="{$maxTags}">
        </div>

      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates mode="mode-iso19139" select="*"/>
      </xsl:otherwise>
    </xsl:choose>

  </xsl:template>

287
</xsl:stylesheet>