Personal tools
You are here: Home Documentation How-tos Geonetwork v2.2 shema/template Howto
Document Actions

Geonetwork v2.2 shema/template Howto

This How-to applies to: 2.2.0

Howto create and add custom shemas to geonetwork v2.2 using xml, xsl, xsd and xpath

Before you even start thinking about creating a new schema/template for geonetwork, I strongly suggest you to read all of the tutorial about XML, Xpath, XSL and XSD on w3schools.com

xml : http://www.w3schools.com/xml/default.asp
xpath : http://www.w3schools.com/xpath/xpath_syntax.asp
xsl : http://www.w3schools.com/xsl/xsl_languages.asp
xsd : http://www.w3schools.com/schema/default.asp

Otherwise,you will probably get confused and never be able to fully understand what you’re doing (even after that, it's hard to follow this wonderfull xml/xsl logic in geonetwork).


Based on a schema, the user can create his custom templates. Schema uses a combination of XML technologies to store, edit and display metadata. This dynamic way to store and to show metadata make it very flexible and, most of all, it will be compatible with any devices like blackberries, iphone, cellphones, GPS, etc.

Back to top

1 – General structure : organisation_template.xml

Createa folder named exactly like your template « organisation » in [geonet_root]/web/xml/schemas/. Here you will store various files mandatory to any geonetwork schema.

Start by thinking and writing down the XML structure of the metadata you would like to show with your schema. Let say you want to add a schema that let geonetwork users enter information about organisations.

According to the w3c standard, all xml files must start with <?xml version="1.0"encoding="UTF-8"?>. Since this file will be place in the database and rearranged by the geonetwork’s api implementation, there is no need for the xml version declaration here. Geonetwork will add the appropriate xml version declaration when needed.

The basic XML would look like this:

<metadata>
<orgTitle>New organisation</orgTitle>
<orgAcronym/>
<orgParentInstitution/>
<orgDesc/>
<orgSuppInfo/>
<orgContactus>
<orgAddress/>
<orgPOBox/>
<orgCity/>
<orgPostalcode/>
<orgProvince/>
<orgCountry/>
<orgPhone/>
<orgFax/>
<orgWebsite/>
<orgEmail/>
</orgContactus>
<orgContactInfo>
<orgContactName/>
<orgContactRole/>
<orgContactEmail/>
<orgContactPhone/>
</orgContactInfo>
<mdFileID/>
</metadata>

Save this file as “organisation_template.xml”… you’ll need it later.

What’s written in your template tag <orgTitle> will be displayed in the dropdown list of available templates when user creates new metadata.

Back to top

2– Language specific tags : /web/geonetwork/xml/schemas/organisation/loc/XX/labels.xml

Now, create the file “organisation.xml” that will be placed in “[geonetwork_root_path]/web/geonetwork/xml/schemas/organisation/loc/en/labels.xml”. This file will display each metadata header and help information in different languages. So create as many "labels.xml” in the various localizations your geonetwork interface is available in.

The “description” tag is not always present. This is a personal decision, since most of the fields are selfexplanatory. However, all fields should be explained.

Following the example above (Section 1), it will look like this:

<?xml version="1.0" encoding="UTF-8"?>
<labels>
<element name="metadata">
<description>root entity which defines metadata about the organisation</description>
<label>Organisation's Metadata</label>
</element>
<element name="orgTitle">
<description>The organisation's name</description>
<label>Organisation's name</label>
</element>
<element name="orgAcronym">
<description>abbreviations that is formedusing the initial letters of words or word parts in a name.</description>
<label>Acronym</label>
</element>
<element name="orgParentInstitution">
<description>The institution above this organisation, if applicable</description>
<label>Parent institution</label>
</element>
<element name="orgDesc">
<description>Description of the main goal of the organisation</description>
<label>Description</label>
</element>
<element name="orgContactus">
<label>Contact us</label>
<description/>
</element>
<element name="orgAddress">
<label>Address</label>
<description/>
</element>
<element name="orgPOBox">
<label>P.O. Box</label>
<description/>
</element>
<element name="orgCity">
<label>City</label>
<description/>
</element>
<element name="orgPostalcode">
<label>Postal Code / Zip</label>
<description/>
</element>
<element name="orgProvince">
<label>Province / State</label>
<description/>
</element>
<element name="orgCountry">
<label>Country</label>
<description/>
</element>
<element name="orgPhone">
<label>Phone</label>
<description/>
</element>
<element name="orgFax">
<label>Fax</label>
<description/>
</element>
<element name="orgWebsite">
<label>Website http://</label>
<description/>
</element>
<element name="orgEmail">
<label>Email</label>
<description/>
</element>
<element name="orgSuppInfo">
<description>any other descriptive information about the organisation</description>
<label>Supplemental Information</label>
</element>
<element name="orgContactInfo">
<description>person to contact</description>
<label>Contact name</label>
</element>
<element name="orgContactName">
<label>Name</label>
<description/>
</element>
<element name="orgContactRole">
<label>Position</label>
<description/>
</element>
<element name="orgContactEmail">
<label>Email</label>
<description/>
</element>
<element name="orgContactPhone">
<label>Phone and ext.</label>
<description/>
</element>
<element name="mdFileID">
<description>unique identifier for this metadata file</description>
<label>File identifier</label>
</element>
</labels>

***I strongly suggest to write the “description” attribute right now. If you don’t, you will most likely never do it.

Back to top

3- XSD creation : /web/xml/schemas/organisation/schema.xsd

XSD stands for XML Schema Definition. You will now tell geonetwork how your xml is organized. This is also where you will tell your geonetwork’s api implementation if some element are optional, mandatory, unique or if multiple instance of them can be created. For an exhaustive list of options, visit : http://www.w3schools.com/schema/el_element.asp

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

<!-- complex type declaration -->

<xs:element name="metadata" type="metadata"/>
<xs:complexType name="metadata">
<xs:sequence>
<xs:element ref="orgTitle"/>
<xs:element ref="orgAcronym"/>
<xs:element minOccurs="0" ref="orgParentInstitution"/>
<xs:element ref="orgDesc"/>
<xs:element minOccurs="0" ref="orgSuppInfo"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="orgContactus"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="orgContactInfo" />
<xs:element ref="mdFileID"/>
</xs:sequence>
</xs:complexType>

<xs:element name="orgContactInfo" type="orgContactInfo" />
<xs:complexType name="orgContactInfo">
<xs:sequence>
<xs:element ref="orgContactName"/>
<xs:element ref="orgContactRole"/>
<xs:element ref="orgContactEmail"/>
<xs:element ref="orgContactPhone"/>
</xs:sequence>
</xs:complexType>

<xs:element name="orgContactus" type="orgContactus"/>
<xs:complexType name="orgContactus">
<xs:sequence>
<xs:element ref="orgAddress"/>
<xs:element minOccurs="0" ref="orgPOBox"/>
<xs:element ref="orgCity"/>
<xs:element ref="orgPostalcode"/>
<xs:element ref="orgProvince"/>
<xs:element ref="orgCountry"/>
<xs:element ref="orgPhone"/>
<xs:element minOccurs="0" ref="orgFax"/>
<xs:element minOccurs="0" ref="orgWebsite"/>
<xs:element minOccurs="0" ref="orgEmail"/>
</xs:sequence>
</xs:complexType>

<!-- ELEMENT DECLARATIONS -->
<xs:element name="orgTitle" type="xs:string"/>
<xs:element name="orgAcronym" type="xs:string"/>
<xs:element name="orgDesc" type="xs:string"/>
<xs:element name="orgParentInstitution" type="xs:string"/>
<xs:element name="orgAddress" type="xs:string"/>
<xs:element name="orgPOBox" type="xs:string"/>
<xs:element name="orgCity" type="xs:string"/>
<xs:element name="orgPostalcode" type="xs:string"/>
<xs:element name="orgProvince" type="xs:string"/>
<xs:element name="orgCountry" type="xs:string"/>
<xs:element name="orgPhone" type="xs:string"/>
<xs:element name="orgFax" type="xs:string"/>
<xs:element name="orgWebsite" type="xs:string"/>
<xs:element name="orgEmail" type="xs:string"/>
<xs:element name="orgContactName" type="xs:string"/>
<xs:element name="orgContactPhone" type="xs:string"/>
<xs:element name="orgContactEmail" type="xs:string"/>
<xs:element name="orgContactRole" type="xs:string"/>
<xs:element name="orgSuppInfo" type="xs:string"/>
<xs:element name="mdFileID" type="xs:string"/>
</xs:schema>

Back to top

4-Geonetwork specific stylesheet files : /web/geonetwork/xml/schemas/organisation/...

Geonetwork’s api will need few xsl files in your schema’s folder in order to perform various operations such as getting the uuid or the thumbnail. Here is a very simple version of the each files needed. You can just copy paste them. Perhaps, complex operations can be done. I suggest looking at the fgdc-std or iso19115 files for complete examples.

extract-thumbnails.xsl

<?xmlversion="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="metadata">
<thumbnail/>
</xsl:template>
</xsl:stylesheet>

extract-uuid.xsl

<?xmlversion="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="metadata">
<uuid><xsl:value-of select="mdFileID"/></uuid>
</xsl:template>
</xsl:stylesheet>

schema-suggestions.xml


<?xml version="1.0" encoding="UTF-8"?>

<fields>

</fields>

schematron_verbid.xsl

<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>

<xsl:output method="html" indent="yes"/>

<xsl:template match="/">
<pre>
<xsl:apply-templates mode="verb"/>
</pre>
</xsl:template>

<!--
Copyright 1999 David Carlisle NAG Ltd
davidc@nag.co.uk
Free use granted under GPL or MPL.

Render XML in an HTML pre element.


USAGE
=====

include this stylesheet into your main stylesheet via

<xsl:import href="verb.xsl"/>

Then a typical usage might be to render an <example> element twice,
first as literal XML, then secondly styled as normal.

One would use, in your main stylesheet:

<xsl:template match="example">
<pre>
<xsl:apply-templates mode="verb"/>
</pre>
<xsl:apply-templates/>
</xsl:template>

This would put the contents of the example element (but not `<example>')
in the HTML pre element. If you want the verbatim mode to include the
current, `example' element, modify the above to say
<xsl:apply-templates mode="verb" select="."/>

-->

<!-- verb mode -->

<!-- Does not really give verbatim copy of the file as that
information not present in the parsed document, but should
give something that renders in HTML as a well formed XML
document that would parse to give same XML tree as the original
-->

<!-- non empty elements and other nodes. -->
<xsl:template mode="verb" match="*[*]|*[text()]|*[comment()]|*[processing-instruction()]">
<a name="{generate-id(.)}"/>
<xsl:value-of select="concat('&lt;',name(.))"/>
<xsl:apply-templates mode="verb" select="@*"/>
<xsl:text>&gt;</xsl:text>
<xsl:apply-templates mode="verb"/>
<xsl:value-of select="concat('&lt;/',name(.),'&gt;')"/>
</xsl:template>

<!-- empty elements -->
<xsl:template mode="verb" match="*">
<a name="{generate-id(.)}"/>
<xsl:value-of select="concat('&lt;',name(.))"/>
<xsl:apply-templates mode="verb" select="@*"/>
<xsl:text>/&gt;</xsl:text>
</xsl:template>

<!-- attributes
Output always surrounds attribute value by "
so we need to make sure no literal " appear in the value -->
<xsl:template mode="verb" match="@*">
<a name="{generate-id(.)}"/>
<xsl:value-of select="concat(' ',name(.),'=')"/>
<xsl:text>"</xsl:text>
<xsl:call-template name="string-replace">
<xsl:with-param name="from" select="'&quot;'"/>
<xsl:with-param name="to" select="'&amp;quot;'"/>
<xsl:with-param name="string" select="."/>
</xsl:call-template>
<xsl:text>"</xsl:text>
</xsl:template>

<!-- pis -->
<xsl:template mode="verb" match="processing-instruction()">
<a name="{generate-id(.)}"/>
<xsl:value-of select="concat('&lt;?',name(.),' ',.,'?&gt;')"/>
</xsl:template>

<!-- only works if parser passes on comment nodes -->
<xsl:template mode="verb" match="comment()">
<a name="{generate-id(.)}"/>
<xsl:value-of select="concat('&lt;!--',.,'--&gt;')"/>
</xsl:template>

<!-- text elements
need to replace & and < by entity references
do > as well, just for balance -->
<xsl:template mode="verb" match="text()">
<a name="{generate-id(.)}"/>
<xsl:call-template name="string-replace">
<xsl:with-param name="to" select="'&amp;gt;'"/>
<xsl:with-param name="from" select="'&gt;'"/>
<xsl:with-param name="string">
<xsl:call-template name="string-replace">
<xsl:with-param name="to" select="'&amp;lt;'"/>
<xsl:with-param name="from" select="'&lt;'"/>
<xsl:with-param name="string">
<xsl:call-template name="string-replace">
<xsl:with-param name="to" select="'&amp;amp;'"/>
<xsl:with-param name="from" select="'&amp;'"/>
<xsl:with-param name="string" select="."/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:template>


<!-- end verb mode -->

<!-- replace all occurences of the character(s) `from'
by the string `to' in the string `string'.-->
<xsl:template name="string-replace" >
<xsl:param name="string"/>
<xsl:param name="from"/>
<xsl:param name="to"/>
<xsl:choose>
<xsl:when test="contains($string,$from)">
<xsl:value-of select="substring-before($string,$from)"/>
<xsl:value-of select="$to"/>
<xsl:call-template name="string-replace">
<xsl:with-param name="string" select="substring-after($string,$from)"/>
<xsl:with-param name="from" select="$from"/>
<xsl:with-param name="to" select="$to"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>



schematron_xml.xsl


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sch="http://www.ascc.net/xml/schematron"
xmlns:geonet="http://www.fao.org/geonetwork"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.0"
geonet:dummy-for-xmlns=""
xlink:dummy-for-xmlns="">
<xsl:output method="xml"/>
<xsl:template match="*|@*" mode="schematron-get-full-path">
<xsl:apply-templates select="parent::*" mode="schematron-get-full-path"/>
<xsl:text>/</xsl:text>
<xsl:if test="count(. | ../@*) = count(../@*)">@</xsl:if>
<xsl:value-of select="name()"/>
<xsl:text>[</xsl:text>
<xsl:value-of select="1+count(preceding-sibling::*[name()=name(current())])"/>
<xsl:text>]</xsl:text>
</xsl:template>
<xsl:template match="/">
<geonet:schematronerrors/>
</xsl:template>
<xsl:template match="text()" priority="-1"/>
</xsl:stylesheet>

schema-substitutes.xml

<?xml version="1.0" encoding="UTF-8"?>
<fields></fields>


schematron.xsl

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sch="http://www.ascc.net/xml/schematron"
xmlns:geonet="http://www.fao.org/geonetwork"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.0"
geonet:dummy-for-xmlns=""
xlink:dummy-for-xmlns="">
<xsl:output method="html"/>
<xsl:template match="*|@*" mode="schematron-get-full-path">
<xsl:apply-templates select="parent::*" mode="schematron-get-full-path"/>
<xsl:text>/</xsl:text>
<xsl:if test="count(. | ../@*) = count(../@*)">@</xsl:if>
<xsl:value-of select="name()"/>
<xsl:text>[</xsl:text>
<xsl:value-of select="1+count(preceding-sibling::*[name()=name(current())])"/>
<xsl:text>]</xsl:text>
</xsl:template>
<xsl:template match="/">
<html>
<style>
a:link { color: black}
a:visited { color: gray}
a:active { color: #FF0088}
h3 { background-color:black; color:white;
font-family:Arial Black; font-size:12pt; }
h3.linked { background-color:black; color:white;
font-family:Arial Black; font-size:12pt; }
</style>
<h2title="Schematron contact-information is at the endof this page">
<font color="#FF0080">Schematron</font> Report
</h2>
<h1 title=" ">No schematron rules defined</h1>
<div class="errors">
<ul/>
</div>
<hr color="#FF0080"/>
<p>
<font size="2">Schematron Report by David Carlisle.
<a href="http://www.ascc.net/xml/resource/schematron/schematron.html"
title="Link to the home page of theSchematron, a tree-pattern schema language">
<font color="#FF0080">The Schematron</font>
</a> by
<a href="mailto:ricko@gate.sinica.edu.tw"
title="Email to Rick Jelliffe (pronounced RIK JELIF)">Rick Jelliffe</a>,
<a href="http://www.sinica.edu.tw"title="Link to home page of Academia Sinica">Academia Sinica Computing Centre</a>.
</font>
</p>
</html>
</xsl:template>
<xsl:template match="text()" priority="-1"/>
</xsl:stylesheet>


set-uuid.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- ================================================================= -->

<xsl:template match="/root">
<xsl:apply-templates select="metadata"/>
</xsl:template>

<!-- ================================================================= -->

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<!-- ================================================================= -->

</xsl:stylesheet>


set-thumbnail.xsl

<?xmlversion="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/root">
<xsl:apply-templates select="metadata"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

unset-thumbnail.xsl

<?xmlversion="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/root">
<xsl:apply-templates select="metadata"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

update-fixed-info.xsl

<?xmlversion="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/root">
<xsl:apply-templates select="metadata"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

Back to top

5-Geonetwork’s searching stylesheet : /web/geonetwork/xml/schemas/organisation/index-fields.xsl

By default, Geonetwork’s search engine will search the “title”, “abstract”, “keywords” and “geographic box”. So you need to match at least one of those with your metadata schema. In our organisation example,there is no coverage region or keywords, but you can look at the other templates.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<Document>

<xsl:apply-templates select="/metadata/orgTitle">
<xsl:with-param name="name" select="'title'"/>
<xsl:with-param name="token" select="'true'"/>
</xsl:apply-templates>

<xsl:apply-templates select="/metadata/orgDesc">
<xsl:with-param name="name" select="'abstract'"/>
<xsl:with-param name="token" select="'true'"/>
</xsl:apply-templates>

<Field name="any" store="false" index="true" token="true">
<xsl:attribute name="string">
<xsl:apply-templates select="/metadata" mode="allText"/>
</xsl:attribute>
</Field>

<!--locally searchable fields -->
<!--defaults to true -->
<Fieldname="digital" string="true" store="false" index="true" token="false"/>
</Document>
</xsl:template>

<!-- text element, bydefault indexed, not stored nor tokenized -->
<xsl:template match="*">
<xsl:param name="name" select="name(.)"/>
<xsl:param name="store" select="'false'"/>
<xsl:param name="index" select="'true'"/>
<xsl:param name="token" select="'false'"/>
<Field name="{$name}"string="{string(.)}" store="{$store}" index="{$index}" token="{$token}"/>
</xsl:template>

<!-- codelist element, indexed, not stored nor tokenized -->
<xsl:template match="*[./*/@value]">
<xsl:param name="name" select="name(.)"/>
<Field name="{$name}" string="{*/@value}" store="false" index="true" token="false"/>
</xsl:template>

<!--allText -->
<xsl:template match="*" mode="allText">
<xsl:for-each select="@*"><xsl:value-of select="concat(string(.),' ')"/></xsl:for-each>
<xsl:choose>
<xsl:when test="*"><xsl:apply-templates select="*" mode="allText"/></xsl:when>
<xsl:otherwise><xsl:value-ofselect="concat(string(.),' ')"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

Back to top

6- Your own Schema’s Stylesheet : /web/xsl/metadata-organisation.xsl

This is the file you can end up playing with for days without knowing what you’re doing… and… on top of that… expecting to have some results. I wish no body will ever go through those days after me, this is why I’m writing this document.

This is the stylesheet that will be used by geonetwork to show the content of your metadata according to user’s request for viewing or editing it. In both case, it is possible for the user to choose between the “simple”, “advanced” or “xml” view. Depending on what the user is doing with the metadata, we need to show it different ways. There is no need for any specification in the “xml” view, since we simply show the raw metadata in it’s xml form.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:geonet="http://www.fao.org/geonetwork">

<!--
default: in simple mode just a flat list
-->
<xsl:template mode="organisation" match="*|@*">
<xsl:param name="schema"/>
<xsl:param name="edit"/>
<xsl:apply-templates mode="element" select=".">
<xsl:with-param name="schema" select="$schema"/>
<xsl:with-param name="edit" select="$edit"/>
<xsl:with-param name="flat" select="$currTab='simple'"/>
</xsl:apply-templates>
</xsl:template>

<!--
these elements should be boxed
-->
<xsl:template mode="organisation" match="orgContactInfo|orgContactus">
<xsl:param name="schema"/>
<xsl:param name="edit"/>
<xsl:apply-templates mode="complexElement" select=".">
<xsl:with-param name="schema" select="$schema"/>
<xsl:with-param name="edit" select="$edit"/>
</xsl:apply-templates>
</xsl:template>

<!--
make the following fields always not editable:
mdFileID
-->
<xsl:template mode="organisation" match="mdFileID">
<xsl:param name="schema"/>
<xsl:param name="edit"/>
<xsl:apply-templates mode="element" select=".">
<xsl:with-param name="schema" select="$schema"/>
<xsl:with-param name="edit" select="false()"/>
</xsl:apply-templates>
</xsl:template>

<!--
orgDesc, orgSuppInfo
-->
<xsl:template mode="organisation" match="orgDesc|orgSuppInfo">
<xsl:param name="schema"/>
<xsl:param name="edit"/>
<xsl:apply-templates mode="simpleElement" select=".">
<xsl:with-param name="schema" select="$schema"/>
<xsl:with-param name="edit" select="$edit"/>
<xsl:with-param name="text">
<xsl:call-template name="getElementText">
<xsl:with-param name="schema" select="$schema"/>
<xsl:with-param name="edit" select="$edit"/>
<xsl:with-param name="rows" select="5"/>
</xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>

<!--
organisation brief formatting
this formating is used to show search results
-->

<xsl:template name="organisationBrief">
<metadata>
<title><xsl:value-of select="orgTitle"/></title>
<abstract><xsl:value-of select="orgDesc"/></abstract>
<xsl:copy-of select="geonet:info"/>
</metadata>
</xsl:template>
</xsl:stylesheet>

Back to top

7- Modifying of geonetwork’s config files.

/web/WEB-INF/config.xml

- Add this line into the <gui> section :

<xml name="organisation" base="xml/schemas/organisation/loc" file="labels.xml" />

/web/xsl/metadata-edit.xsl

if you want your metadata schema to have a thumbnail, add this line under the thumbnail "<xsl:if..." element into the“edit button” template section (<xsl:template name="editButtons" …>):

But that is not sufficient, you will also need to modify the "index-fields.xsl" ( step 5), "set-thumbnail.xsl" and "unset-thumbnail.xsl" ( step 4), but Icouldn't figure out how exacly. If anybody find out how to enable thumbnail for costum template, let me know ( crayco@gmail.com ).

<!--thumbnails -->
<xsl:if test="... or ... or string(geonet:info/schema)='organisation'">
...
</xsl:if>


/web/xsl/metadata-utils.xsl

- Add this line at the top :

<xsl:include href="metadata-organisation.xsl"/>

- And this line into the <!--brief --> section:

<!-- organisation -->
<xsl:when test="$schema='organisation'">
<xsl:call-template name="organisationBrief"/>
</xsl:when>

/web/xsl/metadata.xsl

- Add these lines into the <!-- main schema switch -->

<!-- organisation -->
<xsl:when test="$schema='organisation'">
<xsl:apply-templates mode="organisation" select="." >
<xsl:with-param name="schema" select="$schema"/>
<xsl:with-param name="edit" select="$edit"/>
</xsl:apply-templates>
</xsl:when>

Back to top

8 – Database integration using GeoNetwork admin interface

Restart you Apache Server and make sure there is no error loading your schemas in your log file "C:\Program Files\Apache SoftwareFoundation\Tomcat 5.5\log\geonetwork.log". But even there is no error in the log file, that doesn't mean there is no error in the 19 files you modified. And you can't really tell until you or a user run into a bug.

Directly from your own GeoNetwork web application, login with an Administrator account.
Go to Administration.

Choose "Category Management" :
Create your own "Organisation" category

Choose "Localization" :
Localize your category

Choose "XML Metadata Insert" to insert your raw xml template into the database

- Metadata : Paste in the content of organisation_template.xml ( step 1)
- Type : "Template"
- StyleSheet : "None"
- Destination Schema : "Organisation"
- Validate : "false"
- Group : "MyGroup"
- Category : "Organisation"

Back to top

9 – Testing

Connect to your geonetwork, login as administrator, create a new metadata, choose your new schema, and create a new metadata!

by crayco last modified 2008-08-27 11:33 Creative Commons - http://creativecommons.org/licenses/by/2.5/

Creative Commons License
This work is licensed under a Creative Commons Attribution-No Derivative Works 3.0 Unported License.

Powered by Plone CMS, the Open Source Content Management System