3 SPDX-FileCopyrightText: 2025 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: CC0-1.0
6 <!DOCTYPE DatatypeProperty SYSTEM "../../DTD">
7 <DatatypeProperty functional="yes" status="testing">
8 <label xml:lang="en">local notation</label>
9 <comment xml:lang="en">
11 An integer, string, or time·stamp which identifies and orders a thing within a given context.
14 String values can either be valid <resource name="xsd:NCName"/>¦s or else have the form of a <resource name="xsd:gYearMonth"/> or <resource name="xsd:date"/> with no time·zone component.
15 These possibilities were selected to ensure that the lexical forms of each type are disjoint.
18 Because this property is functional, a <resource name="Proxy"/> must be used when local notation depends on a particular context.
21 Correctly ordering things by local notation involves two steps.
22 First, the local notation must be split into a tuple of two parts :—
27 If it is a string which begins with an underscore and contains another underscore which is followed by a period :—
32 Let <var>base</var> be the portion of the string which follows the initial underscore and precedes the first successive underscore‐period sequence.
37 Let <var>mod</var> be the portion of the string which follows that same underscore‐period sequence.
42 If <var>mod</var> is not itself a valid canonical representation for some local notation, then the first value of the tuple is the original string, and the second value is the empty string.
47 Otherwise, if <var>base</var> is a valid <resource name="xsd:NCName"/> or else has the form of a <resource name="xsd:gYearMonth"/> or <resource name="xsd:date"/> with no time·zone component, then the tuple is {<var>base</var>, <var>mod</var>}.
52 Otherwise, if <var>base</var> is the canonical representation of some <resource name="xsd:integer"/> <var>int</var>, then the tuple is {<var>int</var>, <var>mod</var>}.
57 Otherwise, make the following modifications to <var>base</var> :—
62 Replace all underscores in <var>base</var> with plusses.
67 If <var>base</var> contains <code>T</code>, replace the first two periods in <var>base</var> which follow <code>T</code> (if present) with colons.
72 If <var>base</var> ends in a digit, replace the final remaining period in <var>base</var> (if present) with a colon.
77 If, after making the above substitutions, <var>base</var> is the canonical representation of some <resource name="xsd:dateTimeStamp"/> <var>time</var>, then the tuple is {<var>time</var>, <var>mod</var>}.
82 Otherwise, the first value of the tuple is the original string, and the second value is the empty string.
89 Otherwise, the first value of the tuple is the original string, and the second value is the empty string.
94 Then, the values of the tuples can be sorted according to the following rules, with the first part taking priority over the second :—
99 Empty strings are always sorted first.
104 Integers are sorted by numeric value and come after empty strings.
109 Time·stamps and strings which match <resource name="xsd:gYearMonth"/> or <resource name="xsd:date"/> come after integers, and are sorted according to their corresponding “time on timeline” values, with the following modifications :—
114 For <resource name="xsd:gYearMonth"/> values, the missing day component is treated as the first rather than the last day of the month
119 When the “time on timeline” value is the same, <resource name="xsd:gYearMonth"/> sorts before <resource name="xsd:date"/>, and <resource name="xsd:date"/> sorts before <resource name="xsd:dateTimeStamp"/>.
124 When the “time on timeline” value is the same for two <resource name="xsd:dateTimeStamp"/> values, they are sorted based on their timezone offsets in ascending order.
131 Strings which match <resource name="xsd:NCName"/> follow the above, and are sorted lexically by code·point value.
136 The above algorithm effectively establishes a special microsyntax in which <code>_base_.mod</code> will always sort after <code>base</code>, regardless of <code>base</code>¦s type.
137 When <code>base</code> is a <resource name="xsd:dateTimeStamp"/>, a few reversible modifications need to be made in order to satisfy the <resource name="xsd:NCName"/> syntax :—
142 Any colons in the time component or time·zone offset must be replaced with periods.
147 A plus in the time·zone offset, if present, must be replaced with an underscore.
153 <resource name="dcterms:identifier"/>
158 <resource name="xsd:integer"/>
159 <resource name="xsd:NCName"/>
162 <resource name="xsd:string"/>
165 <pattern>[0-9]{4}(-[0-9]{2}){1,2}</pattern>
168 <resource name="xsd:dateTimeStamp"/>