wiki:Help/Validator/MapCSSTagChecker

Version 5 (modified by Klumbumbus, 11 years ago) ( diff )

+outdated

This page needs a bit more explanation (especially for assertMatch and assertNoMatch).

This tagchecker is considered to be the successor of the tagchecker.cfg and uses much of the MapCSS implementation for stylesheets. The official extension for files is *.validator.mapcss.

The main implementation ticket was #9414.

Syntax

selector {
   /* exactly one of */
   throwError: "message";
   throwWarning: "message";
   throwOther: "message";

   /* arbitrarily many of */
   fixAdd: "key=val";
   fixRemove: "key";
   fixChangeKey: "old=>new";
   suggestAlternative: "any text (e.g., alternative key)";

   /* assertions for unit tests */
   assertMatch: "node/way/relation key1=value1 keyN=valueN";
   assertNoMatch: "node/way/relation key1=value1 keyN=valueN";
}

Some more details:

  • The syntax of selectors is specified in #Selectors
  • Alternatively to strings on the right hand side of those expressions, expressions are evaluated (see list+syntax)
    • Most useful of all is tr() in order to have those strings translated (see below for an example; {0}, {1}, … are placeholders for additional arguments)
  • In addition, the placeholders {i.key}, {i.value}, {i.tag} are evaluated which refer to the corresponding i-th match condition
  • If at least one fixAdd/fixRemove/fixChangeKey is specified, those changes are executed when fixing presets matching this test
  • If suggestAlternative is/are present, those alternatives are displayed together with the test message

Examples

See *.mapcss files in source:trunk/data/validator/ for the checks included in JOSM's core.

*[barrier=wire_fence] {
  throwWarning: tr("{0} is deprecated", "{0.tag}"); /* "{0.tag}" evaluates to "barrier=wire_fence" */
  fixAdd: "barrier=fence";
  fixAdd: "fence_type=chain_link";
  assertMatch: "way barrier=wire_fence";
  assertNoMatch: "way barrier=fence";
}

See also

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.