I am new to xml and I am having difficulties in understanding what is happening in the below statement. The Schematron file is from https://schemas.wmo.int/iwxxm/3.0.0/rule/iwxxm.sch
<sch:rule context="//*[contains(name(),'MeteorologicalAerodromeTrendForecast')]/iwxxm:weather">
<sch:assert test="@xlink:href = document('codes.wmo.int-49-2-AerodromePresentOrForecastWeather.rdf')/rdf:RDF/*/skos:member/*/@*[local-name()='about'] or @nilReason">
MeteorologicalAerodromeTrendForecast iwxxm:weather elements should be a member of http://codes.wmo.int/49-2/AerodromePresentOrForecastWeather
</sch:assert>
</sch:rule>
I understand that there is a rule to check the element iwxxm:weather, but i am unable to understand the test condition. Can anyone explain it to me please? For what value, the test will pass.
The test is failing at a line in the xml which is
<iwxxm:MeteorologicalAerodromeForecast gml:id="uuid.c42e9861-aed6-449f-b4cd-4789e96464d5" cloudAndVisibilityOK="false">
          <iwxxm:prevailingVisibility uom="m">350</iwxxm:prevailingVisibility>
          <iwxxm:surfaceWind>
            <iwxxm:AerodromeSurfaceWindForecast variableWindDirection="false">
              <iwxxm:meanWindDirection uom="deg">240</iwxxm:meanWindDirection>
              <iwxxm:meanWindSpeed uom="[kn_i]">8</iwxxm:meanWindSpeed>
            </iwxxm:AerodromeSurfaceWindForecast>
          </iwxxm:surfaceWind>
 Here ---->         <iwxxm:weather xlink:href="http://codes.wmo.int/49-2/AerodromePresentOrForecastWeather/_RA"/> 
          <iwxxm:cloud>
Thanks
Schematron is a rule-based validation language for making assertions about the presence or absence of patterns in XML trees. It is a structural schema language expressed in XML using a small number of elements and XPath.
The Schematron assertion is verifying that one of the following two conditions are met:
the xlink:href attribute value of the iwxxm:weather context element is equal to that of the about attribute from a particular RDF document:
document() function is used to access an external XML document. In this case, it is the codes.wmo.int-49-2-AerodromePresentOrForecastWeather.rdf RDF document. about (doesn't matter if it is bound to a namespace or not) skos:member element rdf:RDF document element.For instance, if the RDF document looked like this:
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
           xmlns:skos="http://www.w3.org/2004/02/skos/core#">
  <foo>
    <skos:member>
      <bar skos:about="http://codes.wmo.int/49-2/AerodromePresentOrForecastWeather/_RA"/>
    </skos:member>
  </foo>
</rdf:RDF>
iwxxm:weather context element has a nilReason attributeFor instance, if the element were to look like this:
<iwxxm:weather nilReason="true" /> 
                        given the target node:
<iwxxm:weather xlink:href="http://codes.wmo.int/49-2/AerodromePresentOrForecastWeather/_RA"/>
and the assertion test:
@xlink:href = document('codes.wmo.int-49-2-AerodromePresentOrForecastWeather.rdf')/rdf:RDF/*/skos:member/*/@*[local-name()='about'] or @nilReason
it compares the value of iwxxm:weather/@xlink:href and document('codes.wmo.int-49-2-AerodromePresentOrForecastWeather.rdf')/rdf:RDF/*/skos:member/*/@*[local-name()='about'], since this is an assertion, it returns true if the compared values do not match OR iwxxm:weather does not have an attribute @nilReason.
It will pass if iwxxm:weather/@xlink:href and document('codes.wmo.int-49-2-AerodromePresentOrForecastWeather.rdf')/rdf:RDF/*/skos:member/*/@*[local-name()='about'] is an equal match or iwxxm:weather should have an attribute @nilReason.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With