Understanding schematron validation
Asked Answered
P

2

6

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

Peachey answered 19/2, 2020 at 8:1 Comment(2)
change contains(name(),'MeteorologicalAerodromeTrendForecast') to contains(local-name(),'MeteorologicalAerodromeTrendForecast').Brown
The Schematron file is from schemas.wmo.int/iwxxm/3.0.0/rule/iwxxm.sch and I cannot change the file. I am validating my file against this schematron file and getting these errors.Peachey
I
3

The Schematron assertion is verifying that one of the following two conditions are met:

  1. the xlink:href attribute value of the iwxxm:weather context element is equal to that of the about attribute from a particular RDF document:

    • The 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.
    • Then it applies an XPath to select the attribute that has a local-name of about (doesn't matter if it is bound to a namespace or not)
    • that is attached to an element (doesn't matter what the name of the element is)
    • that is the child of a skos:member element
    • that is the child of an element (doesn't matter what the name of the element is)
    • that is the child of the 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>
  1. or the iwxxm:weather context element has a nilReason attribute

For instance, if the element were to look like this:

<iwxxm:weather nilReason="true" /> 
Ichthyosaur answered 3/3, 2020 at 0:36 Comment(0)
B
3

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.

Brown answered 26/2, 2020 at 7:1 Comment(2)
can you please explain the xpath expression document('codes.wmo.int-49-2-AerodromePresentOrForecastWeather.rdf')/rdf:RDF/*/skos:member/*/@*[local-name()='about']Peachey
document('codes.wmo.int-49-2-AerodromePresentOrForecastWeather.rdf') gets the resource, then traverses the contents up to /rdf:RDF/*/skos:member/*/@*[local-name()='about']Brown
I
3

The Schematron assertion is verifying that one of the following two conditions are met:

  1. the xlink:href attribute value of the iwxxm:weather context element is equal to that of the about attribute from a particular RDF document:

    • The 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.
    • Then it applies an XPath to select the attribute that has a local-name of about (doesn't matter if it is bound to a namespace or not)
    • that is attached to an element (doesn't matter what the name of the element is)
    • that is the child of a skos:member element
    • that is the child of an element (doesn't matter what the name of the element is)
    • that is the child of the 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>
  1. or the iwxxm:weather context element has a nilReason attribute

For instance, if the element were to look like this:

<iwxxm:weather nilReason="true" /> 
Ichthyosaur answered 3/3, 2020 at 0:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.