Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 115 additions & 1 deletion shacl12-core/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5367,6 +5367,119 @@ <h3>sh:codeIdentifier</h3>
Similar requirements exist for API generators, for example in Java, JavaScript or Python.
</p>
</section>
<section id="unit">
<h3>sh:unit</h3>
<p>
Shapes may have <a>values</a> for the property <code>sh:unit</code> to indicate a unit of
measure, currency or similar information about the <a>value nodes</a>.
The values of <code>sh:unit</code> can be either <a>literals</a> with <a>datatype</a> `xsd:string`
or `rdf:langString` or `rdf:dirLangString`, or <a>IRIs</a>.
SHACL 1.2 does not prescribe specific values for <code>sh:unit</code> because, at the time of writing (2026),
there was no official W3C standard to represent them uniformly, and multiple standards exist outside of the W3C.
</p>
<p>
For SHACL 1.2, the following recommendations are given:
</p>
<ul>
<li>
For units of measure a value of <code>sh:unit</code> may be an <code>xsd:string</code>
<a>literal</a> that exactly matches a code defined in <a href="http://ucum.org">UCUM</a>;
for example, <code>sh:unit "cm"</code>.
</li>
<li>
For currencies, a value of <code>sh:unit</code> may be an <code>xsd:string</code> <a>literal</a>
that exactly matches a code defined in <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO 4217</a>;
for example, <code>sh:unit "AUD"</code>.
</li>
<li>
A value of <code>sh:unit</code> may be an <a>IRI</a> defined by the
<a href="https://qudt.org/">QUDT</a> or a similar units vocabulary;
for example <code>sh:unit qudt:CentiM</code>.
</li>
<li>
In addition to these canonical values, there may be additional language-tagged literals
with abbreviations or display names that are commonly used in the selected language(s);
for example, <code>"Zoll"@de</code> in addition to <code>"in"</code> for inches.
</li>
</ul>
<p>
While these syntax rules are intentionally left flexible, specific applications may enforce more specific rules;
for example, by declaring a <code>sh:class qudt:Unit</code> constraint on the <code>sh:unit</code> property.
</p>
<p>
User interface tools based on SHACL can use the values of <code>sh:unit</code> to render values.
Depending on a user's locale such tools may even automatically convert between units,
or even allow data entry in units different than those that the actual values will be stored as.
</p>
<aside class="example" title="Example unit declarations in property shapes">
<div class="shapes-graph">
<div class="turtle">
ex:Fridge
a sh:ShapeClass ;
sh:property ex:Fridge-height ;
sh:property ex:Fridge-price ;
.
ex:Fridge-height
a sh:PropertyShape ;
sh:path ex:height ;
sh:datatype xsd:decimal ;
sh:unit "cm" ;
.
ex:Fridge-price
a sh:PropertyShape ;
sh:path ex:price ;
sh:datatype xsd:decimal ;
sh:unit "EUR" ;
.
</div>
</div>
<div class="data-graph">
<div class="turtle">
ex:SomeFridge
a ex:Fridge ;
ex:height 180.5 ;
ex:price 999.95 ;
.
</div>
</div>
<p>
For this example, a user interface may render the height as
</p>
<code>180.5 cm</code>
<p>
or, for US-based visitors, as
</p>
<code>180.5 cm (71 in)</code>
</aside>
<p class="note">
While SHACL Core does not specify specific semantics for <code>sh:unit</code>, some
SHACL-based extensions may use units for other purposes, including validation.
For example, a shape could be defined that enforces a <code>sh:minInclusive 0</code>
constraint on any literal for which the property declares <code>sh:unit "K"</code>.
</p>
<p>
The following variation of the example above uses a <a>node shape</a> to encapsulate
a reusable definition of "price in Euros" that includes the unit but also constraints
such as the minimum value.
</p>
<aside class="example" title="A node shape with a unit declaration">
<div class="shapes-graph">
<div class="turtle">
ex:PriceEUR
a sh:NodeShape ;
sh:datatype xsd:decimal ;
sh:minInclusive "0"^^xsd:decimal ;
sh:unit "EUR" ;
.
ex:Fridge-price
a sh:PropertyShape ;
sh:path ex:price ;
sh:node ex:PriceEUR ;
.
</div>
</div>
</aside>
</section>
<section id="order">
<h3>sh:order</h3>
<p>
Expand Down Expand Up @@ -5657,7 +5770,8 @@ <h2>Changes between the original SHACL Core and SHACL 1.2 Core</h2>
<li>Generalized <a href="#order"></a> to also allow xsd:integers; see <a href="https://github.com/w3c/data-shapes/issues/479">Issue 479</a></li>
<li>Added new <a href="#conformanceDisallows"><code>sh:conformanceDisallows</code> property</a> to the validation report; see <a href="https://github.com/w3c/data-shapes/issues/453">Issue 453</a></li>
<li>Added annotation property <a href="#codeIdentifier"></a>; see <a href="https://github.com/w3c/data-shapes/issues/559">Issue 559</a></li>
<li>Added the target types <a href="#targetWhere"><code>sh:targetWhere</code></a> and <a href="#explicit-shape-target"><code>sh:shape</code></a>, see <a href="https://github.com/w3c/data-shapes/issues/517">Issue 517</a></li>
<li>Added the target types <a href="#targetWhere"></a> and <a href="#explicit-shape-target"></a>, see <a href="https://github.com/w3c/data-shapes/issues/517">Issue 517</a></li>
<li>Added support for units and currencies <a href="#unit"></a>, see <a href="https://github.com/w3c/data-shapes/issues/709">Issue 709</a></li>
</ul>
</section>
</body>
Expand Down
7 changes: 7 additions & 0 deletions shacl12-vocabularies/shacl.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,13 @@ sh:order
# range: xsd:decimal or xsd:integer ;
rdfs:isDefinedBy sh: .

sh:unit
a rdf:Property ;
rdfs:label "unit"@en ;
rdfs:comment "The code of a unit that the (literal) value nodes should be interpreted with. Recommended values are plain strings from the UCUM and ISO 4217 standards for units of measure and currencies respectively, or unit URIs from QUDT or a similar ontology."@en ;
rdfs:domain sh:Shape ;
rdfs:isDefinedBy sh: .

sh:PropertyGroup
a rdfs:Class ;
rdfs:label "Property group"@en ;
Expand Down