Version 8 (modified by 10 years ago) ( diff ) | ,
---|
TranslatedPages)
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)
- Most useful of all is tr() in order to have those strings translated (see below for an example;
- In addition, the placeholders
{i.key}
,{i.value}
,{i.tag}
are evaluated which refer to the corresponding i-th match condition throwWarning: tr("{0}={1} is deprecated", "{0.key}", "{0.value}");
is the same likethrowWarning: tr("{0} is deprecated", "{0.tag}");
- If at least one
fixAdd
/fixRemove
/fixChangeKey
is specified, those changes are executed for objects matching this test when you press the fix button in the Validator Dialog. - If
suggestAlternative
is/are present, those alternatives are displayed together with the test message assertMatch
andassertNoMatch
: You can give there examples, which should (assertMatch) or should not (assertNoMatch) match the used selector. So this is a test if the selector works correct for the given example. Normally this is only usefull for more complex selectors and less for simple key-value selectors. The tests are executed in the context of unit tests and on http://donvip.fr/jenkins/job/JOSM/. They are also executed for local validator files if the advanced optionvalidator.check_assert_local_rules
is set to "true" in the advanced preferences. If the test fails, you will get a message in the console output which can sound like:WARNUNG: Expecting test '...' to not match way ...
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
- Validator dialog
- Validator preferences and description of validator tests
- Some examples howto use validator
Attachments (1)
- testgroup.png (13.3 KB ) - added by 8 years ago.
Download all attachments as: .zip
Note:
See TracWiki
for help on using the wiki.