meta.modes: Metadata for (x)html

The module meta.modes in the directory http://gloss.bham.ac.uk/mv/html/ of the gloss distribution and web pages contains the code for presenting metadata in (X)HTML standards-compliant pages.

1 Synopsis

This module defines a huge number of shorthands for adding link or meta tags to the HTML head element, including Dublin core metadata elements and many other commonly used HTML metadata elements. It can also add links to CSS, XSL and JS files. (This behaviour controlled by parameters so can be added to a group of documents by modifying the mv.)

For Dublin Core see http://dublincore.org/documents/dcq-html/ Also uses other ad-hoc methods widely used in web.

Of particular importance are the following meta tags.

home ~URI     ; home document in a group
glossary ~URI ; glossary document in a group
contents ~URI ; contents document in a group
index ~URI    ; index document in a group
home ~URI     ; home document in a group
first ~URI    ; first document in a group     - omit if this IS the first one
next ~URI     ; next document in a group      - omit if this has no next one
previous ~URI ; previous document in a group  - omit if this IS the first one
author ~URI   ; author's home page
author  ; author's name
date    ; date of authoring

Use relative URI's if at all possible. Please see the file meta.modes for a full list of meta-tags that can be added.

The XSL file, html.xsl, in the same directory adds a "navigator bar" at the head and tail of each html file with links to some of the links present in the head.

This version is for simplified use at present. The scheme, xml:lang, hreflang, and other values for profile attributes are not supported except via general GLOSS-xml mechanisms, but they can be added.

2 The code

!declare-prefix @prefix[meta] @uri[http://gloss.bham.ac.uk/mv/html/meta] {
!declare-prefix @prefix[html] @uri[http://gloss.bham.ac.uk/mv/html/plain] {
!declare-prefix @prefix[xml] @uri[http://gloss.bham.ac.uk/mv/xml/xml] {

!init-parameter @name[meta:xsl] @value[]  ; e.g. html.xsl
!init-parameter @name[meta:css] @value[]  ; e.g. html.css
!init-parameter @name[meta:js] @value[]   ; e.g. html.js
!init-parameter @name[meta:icon] @value[] ; e.g. favicon.ico
!init-parameter @name[meta:profile] @value[http$://dublincore.org/documents/dcq-html/] 
!init-parameter @name[meta:object] @value[]   ; include a special OBJECT element (e.g. for mathplayer)
!init-parameter @name[meta:objectid] @value[]
!init-parameter @name[meta:objectclasid] @value[]
!init-parameter @name[meta:importnamespace] @value[]

Mode meta inserts a link or a meta tag with data ${meta:name}, ${meta:content}

!mode @name[meta:meta] @accept[uri|\[] @type[process]
  !uri
    !element @name[link]
      !attribute @name[rel] [$\{meta:name\}]
      !attribute @name[href] [$v]
      !if @test[$\{meta:type\}]
        !attribute @name[type] [$\{meta:type\}]
      !process-tokens @mode[xml:attribute-list]
    !text 

    !return 
  !punc
    !execute @mode[xml:get-attr]
      !set-parameter @name[xml:attr-param] @value[meta:content]
    !element @name[meta]
      !attribute @name[name] [$\{meta:name\}]
      !attribute @name[content] [$\{meta:content\}]
      !process-tokens @mode[xml:attribute-list]
    !text 

    !return
 

Mode text-only is as for meta, but only accepts text data for meta tag by default this mode just includes the meta:meta mode.

!mode @name[meta:text-only] @accept[\[|] @type[process]
  !include @mode[meta:meta]
  !default !error [Text is required here]
 

Mode link-only is as for meta, but only accepts an href for link tag by default this mode just includes the meta:meta mode.

!mode @name[meta:link-only] @accept[uri|] @type[process]
  !include @mode[meta:meta]
  !default !error [A URI is required here]

The head mode controls the basic structure of the head element parameter meta:profile defines the profile. Allowed metadata includes dublincore and other ad-hoc formats. Perhaps this default needs reviewing. (Possible TO DO.) This section also allows css, icon, js, xsl stylsheets/scripts to be added to the page via parameters.

!mode @name[meta:head-start] @accept[] @use-indentation[false] @type[execute]
  !hook @mode[html:head-content] @action[preprocess]
  !default
    !if @test[$\{meta:head-done\}] !return
    !set-parameter @name[meta:head-done] @value[yes]
    !attribute @name[profile] [$\{meta:profile\}]
    !element @name[link] 
      !attribute @name[rel] [schema.DC] 
      !attribute @name[href] [http$://purl.org/dc/elements/1.1/]
    !text 

    !element @name[link]
      !attribute @name[rel] [schema.DCTERMS]
      !attribute @name[href] [http$://purl.org/dc/terms/]
    !text 

    !if @test[$\{meta:xsl\}]
      !element @name[link]
        !attribute @name[rel] [stylesheet]
        !attribute @name[type] [application/xml]
        !attribute @name[href] [$\{meta:xsl\}] 
        !attribute @name[title] [XSL Stylesheet]
      !text 

    !if @test[$\{meta:css\}]
      !element @name[link]
        !attribute @name[rel] [stylesheet]
        !attribute @name[type] [text/css]
        !attribute @name[href] [$\{meta:css\}] 
        !attribute @name[title] [CSS Stylesheet]
      !text 

    !if @test[$\{meta:js\}]
      !element @name[script]
        !attribute @name[type] [text/javascript]
        !attribute @name[src] [$\{meta:js\}] 
        !comment[ preventing it being an empty tag ]
      !text 

    !if @test[$\{meta:icon\}]
      !element @name[link]
        !attribute @name[rel] [shortcut icon]
        !attribute @name[type] [image/x-icon]
        !attribute @name[href] [$\{meta:icon\}] 
      !text 

    !if @test[$\{meta:object\}]
      !element @name[object]
        !attribute @name[id] [$\{meta:object-id\}]
        !attribute @name[classid] [$\{meta:object-classid\}]
        !comment[comment required to prevent this becoming an empty tag]
    !if @test[$\{meta:object\}]
      !processing-instruction @target[import] [namespace="$\{meta:import-namespace\}" implementation="#$\{meta:import-id\}"]
    !text 

    !process-tokens @mode[meta:add-to-head]
    !process-tokens @mode[html:head-content] @hook[preprocess]
    !return

Additional head-content to hook onto:

!mode @name[meta:add-to-head] @accept[] @use-indentation[false] @type[process]
  !default
    !return

The head-content mode adds the new functionality.

!mode @name[meta:head-content] @template[html:head-content] @type[process]
  !hook @mode[html:head-content] @action[process]

We start with a small number of important tags that appear in DC and in other important general ways, so that when given they will be issued twice.

"title" maps to the head's title element and to DC.title, and is also used to create an h1 element straight after body.

It requires a basic text argument, is in: "title[text of title]" and maps to both the html title tag and the DC.title data.

  title 
    !process-tokens @mode[xml:process-attr]
      !set-parameter @name[xml:attr-param] @value[meta:content]
    !element @name[title] [$\{meta:content\}]
    !text 

    !element @name[meta]
      !attribute @name[name][DC.title]
      !attribute @name[content][$\{meta:content\}]
    !text 


"description" is key to many search engines, and despite a DC version of the tag, we use the one most search engines read. See also "descr" below.

  description
    !process-tokens @mode[xml:process-attr]
      !set-parameter @name[xml:attr-param] @value[meta:content]
    !element @name[meta]
      !attribute @name[name][description]
      !attribute @name[content][$\{meta:content\}]
    !text 


Dublin Core elements.

standard DC metadata; these may use the meta @name[...] @content[...] or the link @rel[...] @href[...] format and receive a basic-text or URI argument.

  contributor !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  coverage !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  creator !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  date !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  descr !process-tokens @mode[meta:meta] ${meta:name}="DC.description" ; DC version of description
  format !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  identifier !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  language !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  publisher !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  relation !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  rights !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  source !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  subject !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  type !process-tokens @mode[meta:meta] ${meta:name}="DC.$n"
  abstr !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.abstract" ; DC version of abstract
  accessRights !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  accrualMethod !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  accrualPeriodicity !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  accrualPolicy !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  alternative !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  audience !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  available !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  bibliographicCitation !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  conformsTo !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  created !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  dateAccepted !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  dateCopyrighted !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  dateSubmitted !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  educationLevel !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  extent !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  hasFormat !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  hasPart !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  hasVersion !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  instructionalMethod !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  isFormatOf !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  isPartOf !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  isReferencedBy !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  isReplacedBy !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  isRequiredBy !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  issued !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  isVersionOf !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  license !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n" ; UGGH: spelling!!!!
  mediator !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  medium !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  modified !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  provenance !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  references !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  replaces !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  requires !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  rightsHolder !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  spatial !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  tableOfContents !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  temporal !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"
  valid !process-tokens @mode[meta:meta] ${meta:name}="DCTERMS.$n"

Other ad-hoc metadata.

Here are some ad-hoc metadata formats that are regularly used See for example http://vancouver-webpages.com/META I've added a few of my own. I recommend only a few where the semantics are clear and the word used clearly represents the relationship of the linked document or metadata to **this**document* (not the content of this document, author of this doc, or anything else). Where ?? is given below, the word is unclear to me or not relevant in the metadata section of a document's head.

See alsoe the document source at this point for possible extras that have been considered but not included yet.

  abstract !process-tokens @mode[meta:meta] ${meta:name}="$n" ; abstract to this document or group of documents
  annotation !process-tokens @mode[meta:meta] ${meta:name}="$n" ; annotation to this document
  author !process-tokens @mode[meta:meta] ${meta:name}="$n" ; author's homepage or name
  begin !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; synonym for start, first
  bibliography !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; bibliography for group of pages
  child !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; synonym for subdocument
  citation ${meta:name}="$n" ; a citation from this document/page to other work
  contents !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; table of contents for group of pages
  copyright ${meta:name}="$n" ; copyright statement
  disclaimer ${meta:name}="$n" ; legal disclaimer
  editor ${meta:name}="$n" ; link to or name of editor
  last !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; last document of a group, synonym for end
  first !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; first element in sequence, synonym for start, begin
  footnote ${meta:name}="$n" ; footnote to this document/page
  glossary !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; glossary for group of pages
  help !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; help document for group of pages
  history ${meta:name}="$n" ; list of document versions or similar
  home !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; home document for group of pages
  icon !process-tokens @mode[meta:link-only] ${meta:type}="image/x-icon" ${meta:name}="shortcut icon" ; standard icon data
  index !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; index to group of documents
  keywords !process-tokens @mode[meta:text-only] ${meta:name}="$n"
  last !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; last element in sequence, synonym for end 
  maintainer ${meta:name}="$n" ; mantainer of this document
  navigator !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; navigational aid for group of documents
  next !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; next document in sequence
  parent !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; parent document in group
  previous !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; previous document in sequence, synonym of last
  reply !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; link to reply to this document
  robots !process-tokens @mode[meta:text-only] ${meta:name}="$n" ; standard robots metadata standard
  schema ${meta:name}="$n" ; define metadata schema
  sibling !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; itentifies sibling document
  stylesheet !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; stylesheet
  subdocument !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; child document in group, synonym for child
  supercedes !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; link to previous version of this document
  trademark ${meta:name}="$n" ; trademark notice
  translation !process-tokens @mode[meta:link-only] ${meta:name}="$n" ; translation into another language

Others will be considered, more permissive variations of the above too.

Of course, hand-coded "link" "meta" and other head elements are allowed too in the normal GLOSS-xml style.

  !include @mode[html:head-content] @hook[process]

}; declare xml prefix
}; declare html prefix
}; declare meta prefix

This file is part of the GLOSS system, Copyright Richard Kaye http://gloss.bham.ac.uk/. Usage permitted under the GPL. No Warranty.

This page is copyright. Web page design and creation by GLOSS.