Changes between Version 25 and Version 41 of Help/Validator/MapCSSTagChecker


Ignore:
Timestamp:
(multiple changes)
Author:
(multiple changes)
Comment:
(multiple changes)

Legend:

Unmodified
Added
Removed
Modified
  • Help/Validator/MapCSSTagChecker

    v25 v41  
    11[[TranslatedPages]]
    2 This tagchecker is considered to be the successor of the `tagchecker.cfg` and uses much of the [[Help/Styles/MapCSSImplementation|MapCSS implementation for stylesheets]]. The official extension for files is `*.validator.mapcss`.
     2This tagchecker is considered to be the successor of the `tagchecker.cfg` and uses much of the [wikitr:/Help/Styles/MapCSSImplementation MapCSS implementation for stylesheets]. The official extension for files is `*.validator.mapcss`.
    33
    4 The main implementation ticket was #9414.
     4Consider installing the [https://marketplace.visualstudio.com/items?itemName=whammo.mapcss-syntax MapCSS Syntax Highlighter] in VS Code to add visual highlighting for MapCSS validator syntax.
    55
    6 More complex validator tests, which can not be done with this syntax are realized as [source:trunk/src/org/openstreetmap/josm/data/validation/tests Java tests].
     6More complex validator tests, which can not be done with this syntax are realized as [source:/trunk/src/org/openstreetmap/josm/data/validation/tests Java tests].
    77
    88== Examples ==
    9 See `*.mapcss` files in source:trunk/data/validator/ for the checks included in JOSM's core or [wiki:Rules external validator rules].
     9See `*.mapcss` files in source:/trunk/resources/data/validator/ for the checks included in JOSM's core or [wikitr:/Rules external validator rules].
    1010
    1111{{{
     
    4949   fixRemove: "key";
    5050   fixChangeKey: "old=>new";
     51   fixDeleteObject: this; /* deletes the whole object! */
    5152   suggestAlternative: "any text (e.g., alternative key)";
     53
     54   /* user defined arguments must be prefixed by - */
     55   -osmoseItemClassLevel: "1210/1/1";
    5256
    5357   /* assertions for unit tests */
    5458   assertMatch: "node/way/relation key1=value1 keyN=valueN";
    5559   assertNoMatch: "node/way/relation key1=value1 keyN=valueN";
     60
     61
     62   /* assertions with spaces, use \"...\" around the value */
     63   assertNoMatch: "node amenity=recycling collection_times=\"Mo-Fr 15:00\"";
    5664}
    5765}}}
    5866
    59 * The syntax of selectors is specified in [[Help/Styles/MapCSSImplementation#Selectors|#Selectors]]
    60 * Alternatively to strings on the right hand side of those expressions, expressions are evaluated (see [[Help/Styles/MapCSSImplementation#Evalexpressions|list+syntax]])
    61   * Most useful of all is [http://josm.openstreetmap.de/doc/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.Functions.html#tr(java.lang.String...) tr()] in order to have those strings translated (CLARIFY: where translations for non-core validation rules should be maintained?)
    62 * 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 [wiki:Help/Dialog/Validator Validator Dialog].
     67* The syntax of selectors is specified in [wikitr:/Help/Styles/MapCSSImplementation#Selectors MapCSSImplementation#Selectors]
     68* Validator rules can be limited to specific countries, see [wikitr:/Help/Styles/MapCSSImplementation#Territoryselector MapCSSImplementation#Territoryselector].
     69* Alternatively to strings on the right hand side of those expressions, expressions are evaluated (see [wikitr:/Help/Styles/MapCSSImplementation#Evalexpressions list+syntax])
     70  * Most useful of all is [/doc/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.html#tr-org.openstreetmap.josm.gui.mappaint.Environment-java.lang.String...- tr()] in order to have those strings translated (CLARIFY: where translations for non-core validation rules should be maintained?)
     71* 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 [wikitr:/Help/Dialog/Validator Validator panel].
    6372* If `suggestAlternative` is/are present, those alternatives are displayed together with the test message
    64 * `assertMatch` and `assertNoMatch`: 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 ​[/jenkins/job/JOSM]. They are also executed for local validator files if the advanced option `validator.check_assert_local_rules` is set to "true" in the [Preferences/Advanced advanced preferences] (see #10206). If you enabled this option and the test fails, you will get a message in the console output which can look like: `WARNUNG: Expecting test '...' to match way ...` or `...to not match...`.
     73* `assertMatch` and `assertNoMatch`: 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 useful for more complex selectors and less for simple key-value selectors. The tests are executed in the context of unit tests and on ​[/jenkins/job/JOSM]. They are also executed for local validator files if the advanced option `validator.check_assert_local_rules` is set to "true" in the [wikitr:/Help/Preferences/Advanced advanced preferences] (see #10206). If you enabled this option and the test fails, you will get a message in the console output which can look like: `WARNING: Expecting test '...' to match way ...` or `...to not match...`.
    6574* Local validator rules do reload automatically, if they are modified and saved by an external application. (The auto reload can stop, if an syntax error in your validator file produces an exception in the console. You need to restart JOSM in this case.)
    6675
     
    7685
    7786
    78 example:
     87examples:
    7988{{{
    8089#!mapcss
     
    96105
    97106==== Grouping ====
    98 * Different tests can be grouped in the Validator dialog. Example:
     107* Different tests can be grouped in the Validator panel. Example:
    99108
    100109{{{
    101110#!mapcss
    102 node[tag("shop") = parent_tag("shop")] ∈ *[shop] {
    103   throwWarning: tr("{0} inside {1}", concat("shop=", tag("shop")), concat("shop=", tag("shop")));
    104   group: tr("{0} inside {1}", "shop", "shop");
     111node[oneway],
     112node[bridge],
     113node[sidewalk],
     114node[footway] {
     115  throwWarning: tr("{0}", "{0.tag}");
     116  group: tr("tag on a node which should be used on a way");
    105117}
    106118}}}
     
    108120results in:
    109121
    110 [[Image(testgroup.png)]]
     122[[Image(testgroup.png,link=)]]
     123
     124The same grouping text can be used on different rules, see e.g. [source:/trunk/resources/data/validator/deprecated.mapcss deprecated.mapcss] or even on different validator files.
    111125
    112126== See also ==
    113  * [wiki:/Help/Dialog/Validator Validator dialog]
    114  * [wiki:/Help/Preferences/Validator Validator preferences] and description of validator tests
     127* [wikitr:/Help/Dialog/Validator Validator dialog]
     128* [wikitr:/Help/Preferences/Validator Validator preferences] and description of validator tests
     129* The main implementation ticket was #9414.
     130
     131----
     132Back to [wikitr:/Help Main Help]