wiki:extractSubtemplates

Version 6 (modified by simonp, 13 years ago) ( diff )

--

Batch Operation to Extract Subtemplates

Date 2012/05/03
Contact(s) Simon Pigot
Last edited 2012/05/03
Status ready to commit
Assigned to release 2.7.x
Resources Available
Ticket # #878

Overview

With the addition of the XLink functions, fragment harvesting, subtemplate (fragments in the GeoNetwork database) support and management of directories of subtemplates, GeoNetwork can now support reusable fragments of metadata. However many sites have metadata records with common fragments of metadata that they would like to extract into directories of subtemplates. This proposal adds a batch operation for admin users that will extract fragments from a selected set of records. Common fragments are identified calculating the checksum of the text content and using this as the uuid of the fragment.

Proposal Type

  • Type: New batch function for admin users
  • App: GeoNetwork
  • Module: Batch Operations

Voting History

  • Proposed for voting on May 3, 2012

Motivations

Many sites have existing metadata records with common information eg. contact information in an ISO CI_ResponsibleParty element. With the addition of subtemplate support and maintenance functions to GeoNetwork, it should be possible to extract these common fragments of metadata as subtemplates. This proposal describes a function that does this.

Proposal

This extract subtemplates function works as follows:

  • Identify fragments of metadata that they would like to manage as reusable subtemplates. This can be done using an XPath. eg. the XPath /grg:RE_Register/grg:containedItem/gnreg:RE_RegisterItem identifies register items in an ISO19135 register record such as that describing the ANZLIC Geographic Extent Names vocabulary and shown in the following example:
<grg:containedItem>
      <gnreg:RE_RegisterItem gco:isoType="grg:RE_RegisterItem" uuid="da078149-ba39-4cb9-817d-7229e479243b">
         <grg:itemIdentifier>
            <gco:Integer>59</gco:Integer>
         </grg:itemIdentifier>
         <grg:name>
            <gco:CharacterString>AUSTRALIA EXCLUDING EXTERNAL TERRITORIES</gco:CharacterString>
         </grg:name>
         <grg:status>
            <grg:RE_ItemStatus>valid</grg:RE_ItemStatus>
         </grg:status>
         <grg:dateAccepted>
            <gco:Date>2006-10-10</gco:Date>
         </grg:dateAccepted>
         <grg:definition>
            <gco:CharacterString>AUSTRALIA EXCLUDING EXTERNAL TERRITORIES|-9|-44|154|112|Australia</gco:CharacterString>
         </grg:definition>
         .......
         <gnreg:itemExtent>
            <gmd:EX_Extent>
               <gmd:geographicElement>
                  <gmd:EX_GeographicBoundingBox>
                     <gmd:westBoundLongitude>
                        <gco:Decimal>112</gco:Decimal>
                     </gmd:westBoundLongitude>
                     <gmd:eastBoundLongitude>
                        <gco:Decimal>154</gco:Decimal>
                     </gmd:eastBoundLongitude>
                     <gmd:southBoundLatitude>
                        <gco:Decimal>-44</gco:Decimal>
                     </gmd:southBoundLatitude>
                     <gmd:northBoundLatitude>
                        <gco:Decimal>-9</gco:Decimal>
                     </gmd:northBoundLatitude>
                  </gmd:EX_GeographicBoundingBox>
               </gmd:geographicElement>
            </gmd:EX_Extent>
         </gnreg:itemExtent>
         <gnreg:itemIdentifier>
            <gco:CharacterString>http://www.ga.gov.au/anzmeta/gen/AUS</gco:CharacterString>
         </gnreg:itemIdentifier>
      </gnreg:RE_RegisterItem>
   </grg:containedItem>
  • Identify a field or fields within the fragment that will be used as the title of the subtemplate. It is important to choose a set of fields that will allow a human to identify the subtemplate when they choose to either reuse the subtemplate in a new record or edit in the subtemplate directories interface.
  • Write a small XSLT that when applied to the subtemplate, will extract the title information. As an example, here is an XSLT that when applied to an ISO19135 register item (gnreg:RE_RegisterItem), will extract the name of the register item (grg:name/gco:CharacterString) for use as the title of the subtemplate.
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 
            xmlns:gco="http://www.isotc211.org/2005/gco"
            xmlns:grg="http://www.isotc211.org/2005/grg"
            xmlns:gnreg="http://geonetwork-opensource.org/register"
            xmlns:gmd="http://www.isotc211.org/2005/gmd">

  <xsl:template match="gnreg:RE_RegisterItem">
    <title><xsl:value-of select="grg:name/gco:CharacterString"/></title>
  </xsl:template>

</xsl:stylesheet>
  • In GeoNetwork, search for and then select the records from which the subtemplates will be extracted. See the following example:

  • Choose 'Extract templates' from the 'Actions on selected set' drop down menu at the top right of the search interface.
  • Enter the XPath of the fragment, server side path name of the XSLT to extract a title for the subtemplate to be created from the fragment and a category to which the created subtemplates will be assigned. See the following example:

  • Run the command and check the logs to see whether your XPath and title extraction XSLT are doing what you expect.
  • Check the checkbox alongside the 'Yes, I really want to do this' when you're sure that everything is ok. The end result will be that the fragments of metadata specified by the XPath will be removed from the records in the selected set and saved as subtemplates and then linked into the records that use them. Here is what part of the register record example used here looks like with an XLink replacing the original gnreg:RE_RegisterItem:
   <grg:containedItem>
      <gnreg:RE_RegisterItem gco:isoType="grg:RE_RegisterItem" xlink:href="http://localhost:8080/geonetwork/src/eng/?da078149-ba39-4cb9-817d-7229e479243b">
   </grg:containedItem>

  • Check the subtemplates created in the Administration->Directories function.

Backwards Compatibility Issues

None?

Risks

Need more functions to manage the links between records and subtemplates.

Participants

  • Simon Pigot

Attachments (5)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.