wmo-im / iwxxm

XML schema and Schematron for aviation weather data exchange
https://old.wmo.int/wiswiki/tiki-index.php%3Fpage=TT-AvXML
48 stars 22 forks source link

Schematron error when multiple elements are missing #226

Closed mgoberfield closed 3 years ago

mgoberfield commented 4 years ago

Please consider the following observation:

URKA 050030Z 16003MPS 3600 BR SCT/// BKN/// 09/09 Q1017 R22/010070 TEMPO 2000 BR BKN010

Please note the two cloud layers with missing cloud base heights.

In IWXXM XML they are reported as such:

missing

While the XML passes schema validation, a fatal error occurs with schematron validation:

Main validation file: URKA.xml Engine name: ISO Schematron Severity: fatal Description: A sequence of more than one item is not allowed as the first argument of fn:ends-with() ("http://codes.wmo.int/common/nil/not...", "http://codes.wmo.int/common/nil/not...") Start location: 1551:102

If I comment out one of the cloud layers, the schematron step completes without errors.

It is not clear to me if this related to a rule in iwxxm.sch or indicative of a more general XML rule that the validation engine is using?

(In other words, I cannot find the words 'sequence of more than one item is not allowed' in the iwxxm.sch file.)

mgoberfield commented 4 years ago

More information from java traceback:

java.io.IOException: net.sf.saxon.s9api.SaxonApiException: A sequence of more than one item is not allowed as the first argument of ends-with() ("http://codes.wmo.int/common/ni...", "http://codes.wmo.int/common/ni...") at edu.ucar.ral.crux.SchematronValidator.validate(SchematronValidator.java:103) at edu.ucar.ral.crux.Crux.validate(Crux.java:117) at edu.ucar.ral.crux.Crux.main(Crux.java:241) Caused by: net.sf.saxon.s9api.SaxonApiException: A sequence of more than one item is not allowed as the first argument of ends-with() ("http://codes.wmo.int/common/ni...", "http://codes.wmo.int/common/ni...") at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:589) at edu.ucar.ral.crux.SchematronValidator.transform(SchematronValidator.java:147) at edu.ucar.ral.crux.SchematronValidator.validate(SchematronValidator.java:97) ... 2 more Caused by: net.sf.saxon.trans.XPathException: A sequence of more than one item is not allowed as the first argument of ends-with() ("http://codes.wmo.int/common/ni...", "http://codes.wmo.int/common/ni...") at net.sf.saxon.expr.CardinalityCheckingIterator.typeError(CardinalityCheckingIterator.java:120) I get the same error from oXygenXML application.

blchoy commented 3 years ago

This involves rules METAR_SPECI.MeteorologicalAerodromeObservationReport-5, 6, 7 and 8 in which the use of end-with() cannot handle a sequence of matching nodes. The following is one of the revised rules:

   <sch:pattern id="METAR_SPECI.MeteorologicalAerodromeObservationReport-5">
      <sch:rule context="//iwxxm:METAR|//iwxxm:SPECI">
         <sch:assert test="( if( empty(iwxxm:observation//iwxxm:cloud/*) and (iwxxm:observation//iwxxm:cloud/@nilReason = 'http://codes.wmo.int/common/nil/notDetectedByAutoSystem') ) then( @automatedStation = 'true' ) else( true() ))">METAR_SPECI.MeteorologicalAerodromeObservationReport-5: When no clouds are detected by an automated station, this report must be an automated station report</sch:assert>
      </sch:rule>
   </sch:pattern>
blchoy commented 3 years ago

Fixed in Version 3.0-dev.