[[TranslatedPages(revision=198,outdated=incomplete translation)]]
[[PageOutline(2-10,Table of Contents)]]
''如果你想了解预设的安装步骤,请参阅[[JOSMImage(dialogs/propertiesdialog)]] [wikitr:/Help/Preferences/TaggingPresetPreference 标记预设]中的注册。[wikitr:/Help/Preferences/TaggingPresetPreference 标签预设]中的[[JOSMImage(preference)]]注册。[wikitr:/Help/Action/Preferences 偏好设置]'' \\
''如果你想使用预设或需要完整的预设参考,请参阅[wikitr:/Presets 预设]''
----
== 标签预设 ==
JOSM 支持分布式标签预设。这是一个 XML 配置文件,描述了输入标签(或属性、注释,有时也称为地图特征)的图形用户界面。
这些预设可以放置在网络或用户本地文件系统的任何地方。JOSM 可以配置为使用自定义的本地或远程预设。
== 开发新预设 ==
标记预设说明采用非常简单的 XML 格式。详见 [#XML below]。
请参阅**[source:/trunk/resources/data/defaultpresets.xml defaultpresets.xml]**,其中的示例涵盖了下面列出的大部分可能性。
示例:
[[Image(Change 1 object.png,right,link=,margin-left=15)]]
{{{
#!preset
}}}
\\
[[Image(Change 1 object.png,right,link=,margin-left=15)]]
== XML 格式描述 ==#XML
完整的 XSD 模式可从命名空间 URI (https://josm.openstreetmap.de/tagging-preset-1.0) 以及 [source:/trunk/resources/data/tagging-preset.xsd 源存储库] 获取。
=== 标签 ===
==== 文档序言 ====
::
必须是文件的主标签。支持以下属性
**xmlns=“http://josm.openstreetmap.de/tagging-preset-1.0”**
**author** - 预设的作者姓名
**version** - 文件的版本号。要对本维基中管理的预设进行自动版本调整,必须使用两个内部变量:`[[修订]]`(维基页面的最新版本号)和`[[日期]]`(最后一次编辑的日期),例如`version=“1.[[修订]]_[[日期]]”。
**description** (i18n) - 文件内容描述
**shortdescription** (i18n) - 非常简短的概述,即预设的 "名称
**link** (i18n) - 更多详细信息的网络链接(可选)
* 图标*** - 整个预设的图标
**baselanguage** - 当基础语言不是英语时,请在此处指定(使用非英语预设文本将阻止自动翻译,一旦实现(#11392))。
(i18n)表示值也可以本地化(例如 `de.description`)。
\\
==== Comments ====
::
The document can contain embedded comments.
\\
==== Preset group 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=""` and `preset_name_label=""` are recommended, `icon=""`, `name_template=""` and `match_expression=""` are optional attributes.
::
Insert a line separator into the menu.
\\
==== Preset window layout ====
::
Labels are static texts for display. `text=""` is a required attribute, `icon=""` and `icon_size=""` are optional.
::
Add some space (i.e. a newline).
::
Used to group some optional elements of an item. The `text=""` attribute is optional. If used without `text=""` then this is equivalent to ``
::
Add a horizontal separator line between items.
::
Specify a web link for this feature or to anything else of use. Either the `wiki=""` (referring to an OSM wiki page, e.g. `"Tag:leisure=park"`) or the `href=""` (full URL) attribute is required. When the `wiki=""` attribute is used the link points to the wiki page of the language JOSM is set to. If it doesn't exist the English page is shown. If using `wiki=""`, the OSM wiki page must not be URL encoded, e.g., it must not be `"Tag:leisure%3Dpark"` and must instead be `"Tag:leisure=park"`.
::
To group checks. The `columns=""` attribute is required.
::
This is required around `` and adds the heading ("Available roles role count elements") to the table which is generated by several ``.
::
To specify possible roles of members in relations. The `key=""` attribute is required, `text=""`, `requisite=""`, `count=""`, `type=""`, `member_expression=""` and `regexp=""` are optional.
::
Adds a link to an other preset with a label on top. The `preset_name=""` attribute is required, `text=""` to override the label (default is `"Edit also …"`) and `text_context=""` are optional. A sequence of `` without `text=""` or a identical `text=""` value are grouped below one label. \\
**Watch out** for presets with identical **`name=""`** as it is not predictable to which preset the link will lead to, see #12716. \\
Having the same tag in both presets does not work, see #18992. \\
Using `` in presets opened from [wikitr:/Help/Dialog/RelationEditor relation editor] produces exceptions, see #20044.
\\
==== Set a fixed 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 omitted, the key is removed. The `match=""` attribute is optional.
\\
==== Attribute entry and selection dialog boxes ====#EntrySelectionBoxes
::
A text edit field to enter any arbitrary string from the user. `key=""` is mandatory, `text=""`, `default=""`, `use_last_as_default=""`, `auto_increment=""`, `length=""`, `alternative_autocomplete_keys=""`, `match=""`, `icon=""` and `icon_size=""` (both since r17605) are optional.
::
Displays a multiple choice combo box. `key=""` and `values=""` are mandatory, `text=""`, `default=""`, `editable=""`, `delimiter=""`, `values_from=""`, `display_values=""`, `short_descriptions=""`, `use_last_as_default=""`, `values_searchable=""`, `length=""`, `values_no_i18n=""`, `values_sort=""`, `match=""`, `icon=""` and `icon_size=""` (both since r17605) are 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.\\
If the key is `colour` or `colour:*` or `*:colour`, a color preview and color picker is added on the right (see #8352).
[=#multiselect]
::
Displays a list from which zero or more items can be chosen. `key=""` and `values=""` are mandatory, and `text=""`, `default=""`, `delimiter=""`, `values_from=""`, `rows=""`, `display_values=""`, `short_descriptions=""`, `use_last_as_default=""`, `values_searchable=""`, `values_no_i18n=""`, `values_sort=""`, `match=""`, `icon=""` and `icon_size=""` (both since r17605) 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 `` 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 `` element, the `` 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.
::
Used in `` and ``. More information see `short_descriptions=""`, [#short_description below]. The attributes are `value=""`, `display_value=""`, `short_description=""`, `icon=""` and `icon_size=""`.
::
A checkbox which the user can select, deselect or set as unset. The `key=""` attribute is mandatory. `text=""`, `default=""`, `match=""`, `value_on=""` , `value_off=""`, `disable_off=""`, `icon=""` and `icon_size=""` (both since r15437) are 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 work with this tagging preset. Can be `"node"`, `"way"`, `"closedway"`, `"multipolygon"`, `"relation"` or any comma separated combination of them. Note that `"multipolygon"` is not included in `"relation"`, so if the preset should apply for multipolygons and other relation types, you need to specify both: `"multipolygon,relation"`. Also used in the `` tag to specify which object types are allowed for a specific relation member.
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. Icons can also be used in ``, ``, plus all [#EntrySelectionBoxes attribute entry and selection dialog boxes] (since r17605, before it was only `` and ``). It is placed in front of `` The icon should be quadratic in size. See [wikitr:/Styles#Iconhandling Icon handling] how icons can be specified.
icon_size="a number"::
The maximal size of an icon in px. If no value is given, default is 16 for `` and the default icon size for `` (in `` and ``).
key="some_key"::
This specifies the property key that will be modified by the item. In case of `` it is the role name used in a relation.
text="Any text"::
The description, that will be displayed before the gui element, (in case of `` after the gui element and the optional icon). Also used for `