MatchesXsAnyUri🔗
Check that
text
conforms to the pattern of an xs:anyURI
.
Code
scheme = (
'[a-zA-Z][a-zA-Z0-9+\\-.]*'
)
ucschar = (
'[\\xa0-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\uffef\\U00010000-\\U0001fffd\\U00020000-\\U0002fffd\\U00030000-\\U0003fffd\\U00040000-\\U0004fffd\\U00050000-\\U0005fffd\\U00060000-\\U0006fffd\\U00070000-\\U0007fffd\\U00080000-\\U0008fffd\\U00090000-\\U0009fffd\\U000a0000-\\U000afffd\\U000b0000-\\U000bfffd\\U000c0000-\\U000cfffd\\U000d0000-\\U000dfffd\\U000e1000-\\U000efffd]'
)
iunreserved = (
f'([a-zA-Z0-9\\-._~]|{ucschar})'
)
pctEncoded = (
'%[0-9A-Fa-f][0-9A-Fa-f]'
)
subDelims = (
"[!$&'()*+,;=]"
)
iuserinfo = (
f'({iunreserved}|{pctEncoded}|{subDelims}|:)*'
)
h16 = (
'[0-9A-Fa-f]{1,4}'
)
decOctet = (
'([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])'
)
ipv4address = (
f'{decOctet}\\.{decOctet}\\.{decOctet}\\.{decOctet}'
)
ls32 = (
f'({h16}:{h16}|{ipv4address})'
)
ipv6address = (
f'(({h16}:){{6}}{ls32}|::({h16}:){{5}}{ls32}|({h16})?::({h16}:){{4}}{ls32}|(({h16}:)?{h16})?::({h16}:){{3}}{ls32}|(({h16}:){{2}}{h16})?::({h16}:){{2}}{ls32}|(({h16}:){{3}}{h16})?::{h16}:{ls32}|(({h16}:){{4}}{h16})?::{ls32}|(({h16}:){{5}}{h16})?::{h16}|(({h16}:){{6}}{h16})?::)'
)
unreserved = (
'[a-zA-Z0-9\\-._~]'
)
ipvfuture = (
f'[vV][0-9A-Fa-f]+\\.({unreserved}|{subDelims}|:)+'
)
ipLiteral = (
f'\\[({ipv6address}|{ipvfuture})\\]'
)
iregName = (
f'({iunreserved}|{pctEncoded}|{subDelims})*'
)
ihost = (
f'({ipLiteral}|{ipv4address}|{iregName})'
)
port = '[0-9]*'
iauthority = (
f'({iuserinfo}@)?{ihost}(:{port})?'
)
ipchar = (
f'({iunreserved}|{pctEncoded}|{subDelims}|[:@])'
)
isegment = (
f'({ipchar})*'
)
ipathAbempty = (
f'(/{isegment})*'
)
isegmentNz = (
f'({ipchar})+'
)
ipathAbsolute = (
f'/({isegmentNz}(/{isegment})*)?'
)
ipathRootless = (
f'{isegmentNz}(/{isegment})*'
)
ipathEmpty = (
f'({ipchar}){{0}}'
)
ihierPart = (
f'(//{iauthority}{ipathAbempty}|{ipathAbsolute}|{ipathRootless}|{ipathEmpty})'
)
iprivate = (
'[\\ue000-\\uf8ff\\U000f0000-\\U000ffffd\\U00100000-\\U0010fffd]'
)
iquery = (
f'({ipchar}|{iprivate}|[/?])*'
)
ifragment = (
f'({ipchar}|[/?])*'
)
isegmentNzNc = (
f'({iunreserved}|{pctEncoded}|{subDelims}|@)+'
)
ipathNoscheme = (
f'{isegmentNzNc}(/{isegment})*'
)
irelativePart = (
f'(//{iauthority}{ipathAbempty}|{ipathAbsolute}|{ipathNoscheme}|{ipathEmpty})'
)
irelativeRef = (
f'{irelativePart}(\\?{iquery})?(\\#{ifragment})?'
)
iri = (
f'{scheme}:{ihierPart}(\\?{iquery})?(\\#{ifragment})?'
)
iriReference = (
f'({iri}|{irelativeRef})'
)
pattern = (
f'^{iriReference}$'
)
return match(
pattern,
text
) is not None