<rule context="para">Two important points:
<assert test="@name">element para misses attribute name.</assert>
</rule>
<creator scheme="province">Brussel</creator>http://www.site.be/cv/province.xml returns:
<cv>The question is to test if "Brussel" is an allowed value.
<cvvalue>Antwerpen</cvvalue>
<cvvalue>Limburg</cvvalue>
<cvvalue>Vlaams-Brabant</cvvalue>
<cvvalue>Oost-Vlaanderen</cvvalue>
<cvvalue>West-Vlaanderen</cvvalue>
</cv>
<rule context="*[@scheme]">
<let name="basepath" value="string('http://www.site.be/cv/')"/>
<let name="cv" value="@scheme"/>
<let name="path" value="concat($basepath, $cv, '.xml')"/>
<assert test=". = document($path)/cv/cvvalue"> Used value "<value-of select="."/>" doesn't appear in cv. "
<value-of select="$path"/>".</assert>
</rule>
The same technique is described in a recent blog entry from Rick Jelliffe on O'Reilly, Validating Code Lists with Schematron.
<rule context="*[namespace-uri(.) = 'http://purl.org/dc/terms/' and local-name(.)=As you can see the context defines a whole list of elements from the dublin core namespace that need to be tested in the same way.
('conformsTo','hasFormat','hasPart','hasVersion','isFormatOf',
'isPartOf','isReferencedBy','isReplacedBy','isRequiredBy','isVersionOf','references',
'relation','replaces','requires','source','tableOfContents')]">
<assert test="string-length(.) > 1 or string-length(string(@resourceIdentifier)) > 1">
The element with name <name path="."/> needs to have content,
or needs to have a value for attribute @resourceIdentifier.
One of both needs to be filled in. </assert>
</rule>
<rule context="element(*, dcterms:InformationObject)">If a new element is added using the same datatype I need to add it to the rule context if using the non-schema-aware version; with the schema-aware version I can relax.
<assert test="string-length(.) > 1 or string-length(string(@resourceIdentifier)) > 1">
The element with name <name path="."/> needs to have content,
or needs to have a value for attribute @resourceIdentifier.
One of both needs to be filled in. </assert>
</rule>
Comments