Home
Categories
Dictionary
Download
Project Details
Changes Log
What Links Here
How To
Syntax
FAQ
License

Infobox template



As for wikipedia, an infobox is a fixed-format table added to the top right-hand corner of articles to consistently present a summary of some unifying aspect that the articles share. The infobox template element allows to define the type of an infobox and the properties associates with this infobox.

An infobox template must be defined in an xml file with the "infoboxDefinition" top-level XML element.

Grammar

See the infobox definition Schema.

Infobox ID

The ID of the infobox template is specified through the id attribute of the infoboxDefinition top-level XML element.

Infobox properties

The children property elements define the properties specified for this infobox. There are two kinds of properties:
  • Regular properties which can have text, URL, or image values
  • Enumeration properties which have only an enumeration of possible values
Note that it is not allowed to define a property with the key "name", because this property is defined by default for all infoboxes.

Regular infobox properties

Each regular property can have the following attributes:
  • "key": the key of the property
  • "desc": the optional description of the property which will appear in the infoboxes (by dfault the key will be used)
  • "keyRef": the optional reference to an article or anchor which will be used for the property name in infoboxes
  • "type": the optional type of the infobox, which can be:
    • "text": the default type for text properties
    • "url": the type for properties which refer to external links
    • "image": the type for properties which refer to images
  • "value" the value of the property. How this value will be parsed depend on the type of the property

The key "name" is not allowed for an infobox property definition, because this identifier is used by the infobox element named name refer to the name of the infobox which will be used in the infobox caption.

Properties values

There are two ways to define the value of a regular property:
  • Using the "value" attribute. The way this attribute will be parsed will depend on the property type:
    • the value for a text property means the text value of the property
    • the value for an url property means the URL of the external link
    • the value for an image property means the ID of the image
  • (only for text properties): specifying the content of the property with children elements


For example, for a text value, the following syntaxes are all valid:
   <property key="prop1" value="my value" />
   <property key="prop1" >a reference to <ref id="anArticle" /></property>

Enumeration properties

Each enumeration property can have the following attributes:
  • "key": the key of the property
  • "desc": the optional description of the property which will appear in the infoboxes (by dfault the key will be used)
  • "keyRef": the optional reference to an article or anchor which will be used for the property name in infoboxes
  • "defaultState": the optional default state to use if there is no state in the instance of the infobox
The enumeration property have one or several state children, each child having the following attributes:
  • "value": the mandatory value of the state
  • "desc": will be used for the name of the state instead of the value if it exists

Enumeration properties values

To use an enumeration property, you must just specify the state name in the "value" attribute.

For example:
   <enumProperty key="prop4" value="one" />
Note that if you don't specify an enumeration property value, but the propety definition has a default state, this state will be used.

Usage

Main Article: infobox element

The infobox element in articles allows to add an infobox with a specified template at the top-right corner of the associated article. The content of this element will specify the key/value pairs for the properties of the infobox, and the properties will be presented as cells of a table in their order of their definition in the template.
  • If a value is set for the "name" property, then the associated value will be used for the infobox caption
  • Every properties which have an associated value will be presented as a key/value pair in the infobox

Examples

Infobox definition and usage

For the following definition:
   <infoboxDefinition id="infobox1">
      <property key="prop1" desc="property 1" keyRef="article2" />
      <property key="prop2" desc="property 2" />
      <property key="prop3" desc="property 3" type="url" />
      <property key="prop4" desc="property 4" type="image" />
   </infoboxDefinition>
If we have the following instance:
   <article desc="article20">
      <infobox id="infobox1">
         <property key="name" value="the name" />
         <property key="prop1" value="my value" />
         <property key="prop2">The text</property>
         <property key="prop3" value="http://docs.oracle.com/javase/8/docs/api/index.html" />
         <property key="prop4" value="image1" />
      </infobox>
   a text.
   </article>
The result will be:
infobox

Another infobox definition with an enumeration property

For the following definition:
   <infoboxDefinition id="infobox1">
      <property key="prop1" desc="property 1" keyRef="article2" />
      <enumProperty key="prop2" desc="property 2">
         <state value="one" desc="the first value" />
         <state value="two" desc="the second value" />            
      </enumProperty>
   </infoboxDefinition>
We can have the following instance:
   <article desc="article20">
      <infobox id="infobox1">
         <property key="name" value="the name" />
         <property key="prop1" value="my value" />
         <property key="prop2" value="one"</property>
      </infobox>
   a text.
   </article>

Another infobox definition with an enumeration property and a default state

Infobox usage with an enumeration property and a default state

For the following definition:
   <infoboxDefinition id="infobox1">
      <property key="prop1" desc="property 1" keyRef="article2" defaultState="two" />
      <enumProperty key="prop2" desc="property 2">
         <state value="one" desc="the first value" />
         <state value="two" desc="the second value" />            
      </enumProperty>
   </infoboxDefinition>
If we have the following instance:
   <article desc="article20">
      <infobox id="infobox1">
         <property key="name" value="the name" />
         <property key="prop1" value="my value" />
      </infobox>
   a text.
   </article>
The result will be equivalent to:
   <article desc="article20">
      <infobox id="infobox1">
         <property key="name" value="the name" />
         <property key="prop1" value="my value" />
         <property key="prop2" value="two"</property>
      </infobox>
   a text.
   </article>

See also


Categories: structure | syntax

docJGenerator Copyright (c) 2016-2023 Herve Girod. All rights reserved.