Validate, compare, sort, parse, and serialize Semantic Versioning (SemVer)
2.0.0 version strings, using XQuery.
SemVer rules are applied strictly, raising errors when version strings do
not conform to the spec.
version | 2.1.0 |
author | Joe Wicentowski |
semver:coerce($version as xs:string?) as map(*)
Coerce a non-SemVer version string into SemVer version string and parse it as such
$version? | $version? |
semver:compare($v1 as xs:string, $v2 as xs:string) as xs:integer
Compare two versions (strictly)
$v1 | $v1 |
$v2 | $v2 |
semver:compare($v1 as xs:string, $v2 as xs:string, $coerce as xs:boolean) as xs:integer
Compare two versions (with an option to coerce invalid SemVer strings)
$v1 | $v1 |
$v2 | $v2 |
$coerce | $coerce |
semver:eq($v1 as xs:string, $v2 as xs:string) as xs:boolean
Test if v1 is equal to v2
$v1 | $v1 |
$v2 | $v2 |
semver:ge($v1 as xs:string, $v2 as xs:string) as xs:boolean
Test if v1 is the same or higher version than v2 (strictly)
$v1 | $v1 |
$v2 | $v2 |
semver:ge($v1 as xs:string, $v2 as xs:string, $coerce as xs:boolean) as xs:boolean
Test if v1 is the same or higher version than v2
$v1 | $v1 |
$v2 | $v2 |
$coerce | $coerce |
semver:gt($v1 as xs:string, $v2 as xs:string) as xs:boolean
Test if v1 is a higher version than v2 (strictly)
$v1 | $v1 |
$v2 | $v2 |
semver:gt($v1 as xs:string, $v2 as xs:string, $coerce as xs:boolean) as xs:boolean
Test if v1 is a higher version than v2 (with an option to coerce invalid SemVer strings)
$v1 | $v1 |
$v2 | $v2 |
$coerce | $coerce |
semver:le($v1 as xs:string, $v2 as xs:string) as xs:boolean
Test if v1 is a lower version or the same version as v2 (strictly)
$v1 | $v1 |
$v2 | $v2 |
semver:le($v1 as xs:string, $v2 as xs:string, $coerce as xs:boolean) as xs:boolean
Test if v1 is a lower version or the same version as v2 (with an option to coerce invalid SemVer strings)
$v1 | $v1 |
$v2 | $v2 |
$coerce | $coerce |
semver:lt($v1 as xs:string, $v2 as xs:string) as xs:boolean
Test if v1 is a lower version than v2 (strictly)
$v1 | $v1 |
$v2 | $v2 |
semver:lt($v1 as xs:string, $v2 as xs:string, $coerce as xs:boolean) as xs:boolean
Test if v1 is a lower version than v2 (with an option to coerce invalid SemVer strings)
$v1 | $v1 |
$v2 | $v2 |
$coerce | $coerce |
semver:ne($v1 as xs:string, $v2 as xs:string) as xs:boolean
Test if v1 is not equal to v2 (strictly)
$v1 | $v1 |
$v2 | $v2 |
semver:ne($v1 as xs:string, $v2 as xs:string, $coerce as xs:boolean) as xs:boolean
Test if v1 is not equal to v2 (with an option to coerce invalid SemVer strings)
$v1 | $v1 |
$v2 | $v2 |
$coerce | $coerce |
semver:parse($version as xs:string) as map(*)
Parse a SemVer version string (strictly)
$version | $version |
semver:parse($version as xs:string, $coerce as xs:boolean) as map(*)
Parse a SemVer version string (with an option to coerce invalid SemVer strings)
$version | $version |
$coerce | $coerce |
semver:serialize($version as map(*)) as item()*
Serialize a parsed SemVer string
$version | $version |
semver:serialize($major as xs:integer, $minor as xs:integer, $patch as xs:integer, $pre-release as xs:anyAtomicType*, $build-metadata as xs:anyAtomicType*) as item()*
Serialize a SemVer string
$major | $major |
$minor | $minor |
$patch | $patch |
$pre-release* | $pre-release* |
$build-metadata* | $build-metadata* |
semver:sort($versions as xs:string+) as xs:string+
Sort SemVer strings (strictly)
$versions+ | $versions+ |
semver:sort($versions as xs:string+, $coerce as xs:boolean) as xs:string+
Sort SemVer strings (with an option to coerce invalid SemVer strings)
$versions+ | $versions+ |
$coerce | $coerce |
semver:validate($version as xs:string) as xs:boolean
Validate whether a SemVer string conforms to the spec
$version | $version |