[
Lists Home |
Date Index |
Thread Index
]
Interesting to couple this with Abstract Patterns in Schematron 1.6 (the code for which
has been released in dribs: I have promised an official release this week). Abstract
patterns can be implemented as simple macros. The following Schema specifies which
are required (a real schema would have more adventurous constraints.)
<sch:schema xmlns:sch="http://www.ascc.net/xml/schematron" version="1.6">
<sch:title>Camera Details</sch:title>
<!-- THE ABSTRACT PATTERN FOR A CAMERA SPECIFICATION -->
<sch:pattern abstract="true" name="Camera">
<sch:rule context=" $Camera ">
<sch:assert test=" $ViewFinder ">A camera spec should have a view finder</sch:assert>
<sch:assert test=" $FocalLength ">A camera spec should have a focal length for its lens</sch:assert>
<sch:assert test=" $Aperture ">A camera spec should have an apperture</sch:assert>
<sch:assert test=" $ShutterSpeed ">A camera spec should have a shutter speed</sch:assert>
</sch:rule>
</sch:pattern>
<!-- ROGER'S FIRST FORMAT -->
<sch:pattern name="SLR-format" is-a="Camera"
see="http://www.xfront.com/avoiding-syntactic-rigor-mortis.html">
<sch:param name="Camera" value="SLR" />
<sch:param name="ViewFinder" value="ViewFinder" />
<sch:param name="FocalLength" value="optics/Lens/focal-length" />
<sch:param name="Aperture" value="optics/Lens/f-stop" />
<sch:param name="ShutterSpeed" value="shutter-speed" />
</sch:pattern>
<!-- ROGER'S SECOND FORMAT -->
<sch:pattern name="Alternative-Format" is-a="Camera"
see="http://www.xfront.com/avoiding-syntactic-rigor-mortis.html">
<sch:param name="Camera" value="Camera" />
<sch:param name="ViewFinder" value="ViewFinder" />
<sch:param name="FocalLength" value="optics/Lens/size" />
<sch:param name="Aperture" value="optics/Lens/aperture" />
<sch:param name="ShutterSpeed" value="shutter-speed" />
</sch:pattern>
<!-- AND ANOTHER FORMAT -->
<sch:pattern name="SLR-table-format">
<sch:param name="Camera" value="camera-table/data/row" />
<sch:param name="ViewFinder" value="*[position()=../names/name[.="ViewFinder"]/position()" />
<sch:param name="FocalLength" value="*[position()=../names/name[.="LensSize"]/position()" " />
<sch:param name="Aperture" value="*[position()=../names/name[.="LensApperture"]/position()" " />
<sch:param name="ShutterSpeed" value="*[position()=../names/name[.="ShutterSpeed"]/position()" " />
</sch:pattern>
</sch:schema>
What is that last entry? It copes with tabular data that looks like this:
<camera-table>
<names>
<name>Model</name><name>ViewFinder</name><name>LensSize</name>
<name>LensAperture</name><name>ShutterSpeed</name>
</names>
<data>
<row><d>Olympus-OM-10</d><d>twin mirror</d><d>75-300mm zoom</</d>
<d>4.0-4.5</d><d>1/2000 sec. to 10 sec.</</d></row>
<row><d>Olympodes-OMS-10</d><d>twin mirror</d><d>76-290mm zoom</</d>
<d>4.0-4.5</d><d>1/100 sec. to 1 sec.</</d></row>
...
</data>
</camera-table>
If I have the (untested) XPaths right, it is even independent of the number of
columns or their order. Open.
I haven't followed OWL: it would be interesting to figure out how Schematron
and OWL stand in relation to each other. Schematron is interested in patterns
(i.e. views of structures, especially non-hierarchical structures) though it does
allow some labelling of nodes.
Cheers
Rick Jelliffe
|