[[TranslatedPages(outdated=The preset syntax has changed and the copy from XML files needs to be joined with normal description)]]
[[PageOutline(2-10,Table of Contents)]]
= Tagging Presets =
JOSM supports distributed tagging presets. This is a XML config file that describes a GUI for entering tags (or properties, annotations, sometimes called map features). The XML files can be placed anywhere in the web or at the users local file system. Presets can be added by the users at a central page [wiki:Presets].
== Installing presets ==
Open the [Help/Action/Preferences preferences window], click [[Image(source:trunk/images/preferences/map.png,20)]] map settings and select third tab [Help/Preferences/Map#TaggingPresets "Tagging Presets"].
----
== Develop a new preset – Example ==
[[Image(tagging_screenshot.png,align=right)]]
{{{
#!xml
-
}}}
== Develop a new preset – Add to the list of available presets ==
See [[Presets]].
== Develop a new preset – XML Format description ==
The tagging preset description is in a very simple XML format.
See the **[source:trunk/data/defaultpresets.xml defaultpresets.xml]** for an example covering all possibilities.
The full XSD schema is available at the namespace URI (http://josm.openstreetmap.de/tagging-preset-1.0) as well as [source:trunk/data/tagging-preset.xsd the source repository].
----
== Develop a new preset – XML Format description (outdated!) ==
=== Tags ===
==== The document prolog ====
''''''::
Has to be the main tag of the file. Supports following attributes
* '''xmlns="http://josm.openstreetmap.de/tagging-preset-1.0"'''
* '''author''' - the name of the author
* '''version''' - a version of the file
* '''description''' (i18n) - description what the file contains
* '''shortdescription''' (i18n) - short overview description
* '''link''' (i18n) - web link to further details
* '''icon''' - informational icon for the preset
==== Comments ====
''''''::
The document can contain embedded comments.
==== Menu creation ====
''''''::
Used to group items in sub menus. ''name'' is required, ''icon'' is optional attribute.
'''- '''::
Every item is one annotation set to select from. ''name'' is required, ''type'' is recommended, ''icon'' is optional attribute.
'''
'''::
Insert a line separator into the menu.
==== Create instructions for the user ====
''''''::
Labels are static texts for display. ''text'' is a required attribute.
''''''::
Used to group some optional elements of an item. Possibly equivalent to
''' '''::
Add some space (ie a newline) in the preset display.
''' '''::
Specify a web link for this feature or to anything else of use. The ''href'' attribute is required.
==== Attribute entry and selection dialog boxes ====
''''''::
A text edit field to enter any arbitrary string from the user. ''key'' is mandatory, ''text'', ''default'', ''match'' and ''required'' is optional
''''''::
Displays a multiple choice combo box. ''key'' and ''values'' are mandatory and ''text'', ''default'', ''editable'', ''match'' and ''required'' is optional.
If editable is true (default), combo boxes can be edited as if they were text fields (additional to the drop down menu). Non editable
combo boxes can only contain one of the specified values.
''''''::
Displays a list from which zero or more items can be chosen. ''key'' and ''values'' are mandatory, and ''text'', ''default'', ''delimiter'', ''match'' and ''required'' are optional. The selected values will be concatenated with the specified delimiter (default: semicolon) and written to the tag value. If a tag value has already been set when the preset dialog is opened, the multiselect will attempt to mark the appropriate items in the list as select. If the tag value cannot be represented by a combination of choices in the list, then the list will be disabled so that the user cannot accidentally overwrite a custom value. In contrast to the "combo" element, the "multiselect" expects the list of values, descriptions etc. to use the specified delimiter, i.e. by default you will have to use a semicolon. You can specify delimiter="," but then a comma will also be used in the tag value.
''''''::
A checkbox which the user can only select or deselect. The ''key'' attribute is mandatory. ''text'', ''default'', ''match'' and ''required'' is optional.
==== Set a key value pair ====
''''''::
This tag will always set a key to a specific value. ''key'' is required and if ''value'' is present, the key will be set. If ''value'' attribute is ommited, the key is removed. The ''match'' attribute is optional.
==== Templates ====
''''''::
To define a template of elements for later (repeated) use. The ''id'' attribute is mandatory.
''''''::
To include an earlier defined template. The ''ref'' attribute is mandatory.
=== Attributes ===
The attributes of the tags have the following meaning:
'''name="a_name"'''::
Specify a name for an item. This name will be used in the GUI to display the tagging preset.
'''name_context="context"'''::
Translation context for name attribute to separate equals words with different meaning (not required for in-file translations).
'''type="data_type"'''::
When specified, only objects of the given type will be changed at all by this tagging preset. Can be "node", "relation", "way", "closedway" or any comma separated combination of them.
'''icon="iconname"'''::
A name or link to an icon. The image will be used as icon to display in the selection list and when adding the preset to the toolbar. The icon should be quadratic in size. See [[Styles#Iconhandling]] how icons can be specified.
'''key="some_key"'''::
This specifies the property key that will be modified by the item.
'''text="Any text"'''::
The description, that will be displayed before (after in case of ) the gui element.
'''text_context="context"'''::
Translation context for text attribute to separate equals words with different meaning (not required for in-file translations).
'''default="default_value"'''::
The default value for the item. If not specified, the current value of the key is chosen as default (if applicable).
'''values="entry1,entry2,entry3"'''::
A list of entries (for the combo box and multiselect). The list has to be separated by commas (for the combo box) or by the specified delimiter (for the multiselect). If a value contains the delimiter, the delimiter may be escaped with a backslash. If a value contains a backslash, it must also be escaped with a backslash.
'''values_context="context"'''::
Translation context for name attribute to separate equals words with different meaning (not required for in-file translations).
'''display_values="Entry1,Entry2,Entry3"'''::
A list of entries that is displayed to the user. Must be the same number of entries as values and '''editable''' must be false or not specified. For the delimiter character and escaping, see the remarks at ''values''.
'''value="foobar"'''::
Specify a value to be entered in the tag.
'''value_on="foobar"'''::
Specify the true value to be entered in the tag (default is "yes").
'''value_off="foobar"'''::
Specify the false value to be entered in the tag (default is "no").
'''editable="false"'''::
The combo box is readonly, which means that the user can only select an item in the list.
'''use_last_as_default="true"'''::
For combo boxes or text fields the last value is used as default. Using "force" enforces this behaviour also for already tagged objects.
'''rows="count"'''::
Specify the number of rows in multiselect entry.
'''name_template="template", name_template_filter="search expression"'''::
Custom name formatter for osm primitives matching this preset. See [[NameTemplate]] for details.
'''match="none|key|key!|keyvalue|keyvalue!"'''::
Allows to change the matching process, i.e., determining whether the tags of an OSM object fit into this preset. If a preset fits then it is linked in the [wiki:Help/Dialog/TagsMembership Tags/Membership dialog].
* none: neutral, i.e., do not consider this item for matching
* key: positive if key matches, neutral otherwise
* key!: positive if key matches, negative otherwise
* keyvalue: positive if key and value matches, neutral otherwise
* keyvalue!: positive if key and value matches, negative otherwise
Note that for a match, at least one positive and no negative is required. Default is "keyvalue!" for and "none" for , , and .
'''id="unique identifier"'''::
the unique identifier for this chunk
'''ref="unique identifier"'''::
the unique identifier of the (already defined) template to include
To support translations, all textual elements may be used in translated form. E.g. "de.name" would represent the name in case German language support is loaded.
=== Format description from XML document (needs to be joined with above texts) ===
(delete here the parts which you have joined with above texts)
{{{
item:
name: the text to display
icon: the icon to display
- relative to the icon path
- URL's are also supported to allow remote icons (are cached locally)
type: the data types - way,node,relation,closedway (separated by comma)
name_template: define custom formatting for OSM primitives
see [[NameTemplate]]
preset_name_label: whether to insert "[preset name]" label in dialog
(defaults to "false" for backward-compatibility on external presets)
preset_link: a link to an other preset
preset_name: the exact name of the preset to link to
label: simple static text label
text: the text to display
icon: location of icon to display (optional)
icon_size: maximal size of icon (optional). If no value is given, default is 16px
optional: optional tags, short for "space" plus "label" plus "space"
text: the text to display (defaults to "Optional Attributes:")
item_separator: horizontal separator line between items (in window)
key: fixed key/value pair to be set
key: key to set
value: value to set
text: text box
key: key to set
text: fixed label to display
default: default string to display (defaults to "")
use_last_as_default: true/false/force (default is "false")
auto_increment: may contain a comma separated list of integer increments or
decrements, e.g. "-2,-1,+1,+2"; a button will be shown next
to the text field for each value, allowing the user to select
auto-increment with the given stepping. auto-increment only
happens if the user selects it. default is no auto-increment;
mutually exclusive with use_last_as_default.
length: length of input box (number of characters allowed)
alternative_autocomplete_keys: comma separated list of alternative keys to use for autocompletion
combo: combo box, with multiple choices and possible to enter free form text
key: key to set
text: fixed label to display
delimiter: character that separates values (default: comma)
values: separated list of values
values_from: to use instead of "values" if the list of values has to be obtained with a Java method
of this form: public static String[] getValues();
The value must be: "full.package.name.ClassName#methodName"
display_values: comma separated list of values to be displayed instead of the
database values, order and number must be equal to values
short_descriptions: comma separated list of texts to be displayed below each
display_value. (Only if it is not possible to describe
the entry in 2-3 words.) Instead of comma separated list
instead using values, display_values and short_descriptions, the following form is also supported:
icon: location of icon
icon_size: maximal size of icon. If tag is not setup it is taken default size of icon file
default: default string to display (defaults to "")
use_last_as_default: true/false/force (default is "false")
editable: allow to add other values as text (default is "true")
values_searchable: true/false (whether to search in combo (display_)values when searching for presets)
length: length of input box (number of characters allowed)
multiselect: list of values from which zero or more can be selected
key: key to set
text: fixed label to display
delimiter: character that separates values (default: semicolon) - this
will also be used to separate selected values in the tag.
values: delimiter-separated list of values (delimiter can be escaped with backslash)
values_from: to use instead of "values" if the list of values has to be obtained with a Java method
of this form: public static String[] getValues();
The value must be: "full.package.name.ClassName#methodName"
rows: specify the number of rows to display (default -1)
display_values: delimiter-separated list of values to be displayed instead of the
database values, order and number must be equal to values
short_descriptions: delimiter-separated list of texts to be displayed below each
display_value. (Only if it is not possible to describe
the entry in 2-3 words.) Instead of a separated list
instead using values, display_values and short_descriptions, the following form is also supported:
icon: location of icon
icon_size: maximal size of icon. If tag is not setup it is taken default size of icon file
default: default string to display (defaults to "")
use_last_as_default: true/false/force (default is "false")
values_searchable: true/false (whether to search in multiselect (display_)values when searching for presets)
checkgroup: group of checks
columns: number of columns
check: checkbox
key: key to set
text: fixed label to display
default: ticked on/off (default is "off")
value_on: the value to set when checked (default is "yes")
value_off: the value to set when unchecked (default is "no")
disable_off: whether the off value is disabled in the dialog, i.e., only unset or yes are provided
role: type to specify possible roles in relations
key: the role name used in relation
text: fixed label to display
requisite: optional/required (default is "optional")
count: how often can the role occur (if not given unlimited number is assumed)
type: the data types - way,node,relation,closedway (separated by comma)
member_expression: an expression (cf. search dialog) for objects of this role
presets: For external files should have following attributes:
author: the author of the preset
version: a version number of some sort (e.g. creation date)
description: what is your preset meant to be
shortdescription: very short description
link: a link to a helpful website (optional)
icon: an icon for the whole presets
The fields description, shortdescription and link may also be localized (e.g. de.link)
The fields "name", "text", "display_values" may also be localized (e.g. de.name).
When translations of equal words but different meanings may conflict, a translation
context should be specified. Use "name_context", "text_context" or "values_context"
for this. The context should be a meaningful short description to help translators.
In JOSM internally all "name", "text" and "display_values" are translated when
no specific translation has been given in XML file. When no "display_values"
are supplied, then "values" will be treated as "display_values" and translated instead.
}}}
=== Icon handling ===
See [wiki:Styles#Iconhandling Styles].
== See also ==
* [/Presets]
* [wiki:Help/Preferences/Map#TaggingPresets Tagging presets preferences]