Metadata Select field

AttributeDescriptionRequired
label

The text shown as label in the user interface.

true

name

Unique field identifier.

Two metadatas can't have the same name. Name must be unique.

The name must start with "okp:".

It's a good practice to use metadata group name as basis for metadata field name. For example use "okg:consulting" has been used for field name "okp:consulting.select", changin "okg" to "okp". That helps to find out the metada group based on metadata field name.

Please, use only letters, numbers and underscore: "0-9a-zA-Z_".

true

type

Type value. Allowed types:

  • simple ( single choice allowed ).
  • multiple ( multiple choices allowed ).
true
table

Metadata table name.

The application can store values into a metadata table, that can be used in this query.

*
width The width of the HTML element.  
height The height of the HTML element.  
optionsQuery A metadata query used to get the selected options. *

className

A class used to get the selected options. *
suggestion

When adding metadata to documents, the application can suggest automatically some values based on document content analysis. By default the application has some implementations that can easilly be extended.

  • com.openkm.form.suggestion.DocumentContentContainsSuggestion: Gets suggestions based on document's content (use String.contains)
  • com.openkm.form.suggestion.DocumentContentTokenizerSuggestion: Gets suggestions based on document's content (Use StringTokenizer).
  • com.openkm.form.suggestion.DocumentTermsSuggestion: Gets suggestions based on document's term vectors.

For more information read Creating your own Suggestion Analyzer.

false
parentElement Parent field name value. In this case the value has a hierarchical relationship with other field values ( the parent ). false
description General description. false
readonly Set field will not be able to be modified in the user interface. By default the value is "false". false

dbColumnSize

Set the size of the database field where the value is stored.

By default, fields are stored in a database column with 128 characters size. Because your data length might be bigger than 128 characters the administrator should update the default column size.

Take a look at Metadata XML definition documentation section for a deep explanation about metadata storage in OpenKM database,

 

Child elements:

  • Option. Couples of XML <option label="label text" value="unique identifier value"/> values or <option label="label text" value="unique identifier value" parentValue="parent unique identifier value"/> in case is set a hierarchical relationship.
  • Validator. For more information see Metadata Validator element.

* There're tree options to get option values:

  • Directly defined in XML.
  • Metadata table ( table + optionsQuery ).
  • className.

One of these options must be defined, otherwise you will get an error. It can not done as a combination of several of them, only one can be choosen.

Basic select example

  • Type is equal to simple.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.7//EN"
                                 "http://www.openkm.com/dtd/property-groups-3.7.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
    <select label="select label" name="okp:consulting.select" type="simple">
      <option label="one" value="001" />
      <option label="two" value="002" />
      <option label="three" value="003" />
     </select>
  </property-group>
</property-groups>

Allow multiple choices

  • Type is equal to multiple.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.7//EN"
                                 "http://www.openkm.com/dtd/property-groups-3.7.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
    <select label="select label" name="okp:consulting.select" type="multiple">
      <option label="one" value="001" />
      <option label="two" value="002" />
      <option label="three" value="003" />
     </select>
  </property-group>
</property-groups>

Hierarchical relationship

  • The field option values of "okp:consulting.children" have parent relation with "okp:consulting.parent". It's defined by parentElement="okp:consulting.parent".
  • The option value "benefits" of field "okp:consulting.children" has a parent value "directives" from field "okp:consulting.parent".

Tree relationships:

  • directives
    • benefits
    • elegibility
    • services
  • handbook
    • basic
    • normal
    • advanced
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.7//EN"
                                 "http://www.openkm.com/dtd/property-groups-3.7.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
    <select label="Parent" name="okp:consulting.parent" type="simple">
      <option value="directives" label="Directives" />
      <option value="handbook" label="Handbook Paragraphs" />
    </select> 
    <select label="Children" name="okp:consulting.children" type="simple" parentElement="okp:consulting.parent">
      <option value="benefits" label="Benefits" parentValue="directives" />
      <option value="elegibility" label="Eligibility" parentValue="directives" />
      <option value="services" label="Services" parentValue="directives" />
      <option value="basic" label="Basic" parentValue="handbook" />
      <option value="normal" label="Advanced" parentValue="handbook" />
      <option value="advanced" label="Normal" parentValue="handbook" />
    </select>
  </property-group>
</property-groups>

Based on SQL query

We can also get these option values using a SQL query. This SQL sentence should be put on the optionsQuery attribute, but the table attribute should be empty (otherwise this query is used as a metadata query). Note that the first element returned in every row is the option value and the second one is the option label.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.7//EN"
                              "http://www.openkm.com/dtd/property-groups-3.7.dtd">
<property-groups>
  <property-group label="Location" name="okg:location">
    <select label="Country" name="okp:location.country" type="simple"
            optionsQuery="select CT_ID, CT_NAME from COUNTRY order by CT_NAME" />
  </property-group>
</property-groups>

The table used in this sample is defined as:

create table COUNTRY (
  CT_ID varchar(2),
  CT_NAME varchar(32),
  primary key(CT_ID)
);

insert into COUNTRY (CT_ID, CT_NAME) values ('es', 'Spain');
insert into COUNTRY (CT_ID, CT_NAME) values ('pt', 'Portugal');
insert into COUNTRY (CT_ID, CT_NAME) values ('it', 'Italy');

Based on className

To help getting a list from external applications or other purposes, your own class can be built to retrieve the option values from those systems .

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.7//EN"
                                 "http://www.openkm.com/dtd/property-groups-3.7.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
    <select label="select label" name="okp:consulting.select" type="simple"
            className="com.openkm.plugin.form.values.OptionSelectUserList" />
  </property-group>
</property-groups>

For more information read Creating your own Option Select Values plugin.

Suggested options

Based on the content analyzer the application can suggest some options values. At the user interface the suggested options will be shown in green.

The application has some implementations that can easily be extended.

  • com.openkm.form.suggestion.DocumentContentContainsSuggestion: Get suggestions based on document content (use String.contains)
  • com.openkm.form.suggestion.DocumentContentTokenizerSuggestion: Get suggestions based on document content (Use StringTokenizer).
  • com.openkm.form.suggestion.DocumentTermsSuggestion: Get suggestions based on document term vectors.

For more information read Creating your own Suggestion Analyzer.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.7//EN"
                                 "http://www.openkm.com/dtd/property-groups-3.7.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
    <select label="select label"  name="okp:consulting.select" type="multiple"
            suggestion="com.openkm.form.suggestion.DocumentContentContainsSuggestion">
      <option label="one" value="001" />
      <option label="two" value="002" />
      <option label="three" value="003" />
     </select>
  </property-group>
</property-groups>