Changes between Version 25 and Version 41 of Help/Validator/MapCSSTagChecker
- Timestamp:
- (multiple changes)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Help/Validator/MapCSSTagChecker
v25 v41 1 1 [[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`.2 This 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`. 3 3 4 The main implementation ticket was #9414.4 Consider 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. 5 5 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].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]. 7 7 8 8 == Examples == 9 See `*.mapcss` files in source: trunk/data/validator/ for the checks included in JOSM's core or [wiki:Rules external validator rules].9 See `*.mapcss` files in source:/trunk/resources/data/validator/ for the checks included in JOSM's core or [wikitr:/Rules external validator rules]. 10 10 11 11 {{{ … … 49 49 fixRemove: "key"; 50 50 fixChangeKey: "old=>new"; 51 fixDeleteObject: this; /* deletes the whole object! */ 51 52 suggestAlternative: "any text (e.g., alternative key)"; 53 54 /* user defined arguments must be prefixed by - */ 55 -osmoseItemClassLevel: "1210/1/1"; 52 56 53 57 /* assertions for unit tests */ 54 58 assertMatch: "node/way/relation key1=value1 keyN=valueN"; 55 59 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\""; 56 64 } 57 65 }}} 58 66 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]. 63 72 * 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 useful l 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...`. 65 74 * 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.) 66 75 … … 76 85 77 86 78 example :87 examples: 79 88 {{{ 80 89 #!mapcss … … 96 105 97 106 ==== Grouping ==== 98 * Different tests can be grouped in the Validator dialog. Example:107 * Different tests can be grouped in the Validator panel. Example: 99 108 100 109 {{{ 101 110 #!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"); 111 node[oneway], 112 node[bridge], 113 node[sidewalk], 114 node[footway] { 115 throwWarning: tr("{0}", "{0.tag}"); 116 group: tr("tag on a node which should be used on a way"); 105 117 } 106 118 }}} … … 108 120 results in: 109 121 110 [[Image(testgroup.png)]] 122 [[Image(testgroup.png,link=)]] 123 124 The 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. 111 125 112 126 == 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 ---- 132 Back to [wikitr:/Help Main Help]