$default-lang (default: 'lv')
routes-by-lang-path
matches//route
indexed byconcat(@lang, '|', @path)
routes-by-lang
matches//route
indexed by@lang
child-routes
matches//route
indexed byconcat(generate-id(..), '|', @lang, '|', @path)
$full-path
$lang
templateroute-content
parameter$route=/context/request/@route
apply/context/request/pathin mode resolve-page
with$route=$route
matchpath[@is-root='true']mode: resolve-pagepriority: 3
$home-route←key('routes-by-lang-path', concat($lang, '|/'))
when$home-route
apply$home-route/..in mode render
otherwise
callnot-found
matchpath[@is-root='true']mode: resolve-langpriority: 3
whenkey('routes-by-lang-path', 'lv|/')
whenkey('routes-by-lang-path', 'en|/')
otherwise
$default-lang
matchpathmode: resolve-langpriority: 1
whenkey('routes-by-lang-path', concat('lv|', $full-path))
whenkey('routes-by-lang-path', concat('en|', $full-path))
otherwise
$seg1←segment[1]
when$seg1 and key('routes-by-lang-path', concat('lv|/', $seg1/@text, '/'))
when$seg1 and key('routes-by-lang-path', concat('en|/', $seg1/@text, '/'))
otherwise
$default-lang
matchpathmode: resolve-pagepriority: 1
$seg1←segment[1]
$exact-route←key('routes-by-lang-path', concat($lang, '|', $full-path))
when$exact-route
apply$exact-route/..in mode render
otherwise
$container-route←key('routes-by-lang-path', concat($lang, '|/', $seg1/@text, '/'))
$out←
if$container-route
apply$container-route/..in mode descend
with$seg=$seg1/segment[1]
with$lang=$lang
whenboolean(exsl:node-set($out)/node())
copy ofexsl:node-set($out)/node()
otherwise
callnot-found
matchpathmode: resolve-pagepriority: 0
callnot-found
match*mode: render
apply.
match*mode: descend
parameter$seg
parameter$lang
whennot($seg)
apply.in mode render
otherwise
$slug←$seg/@text
$next-element←*[route[@lang=$lang and (@path=$slug or @path=concat($slug, '/'))]]
if$next-element
apply$next-elementin mode descend
with$seg=$seg/segment[1]
with$lang=$lang
templatenot-found
html
apply/context/request/pathin mode no-route
templateget-route-path
parameter$element=.
parameter$lang=$lang
$element/route[@lang=$lang]/@pathtemplatebuild-url
parameter$element=.
parameter$lang=$lang
if$element/..
$element/route[@lang=$lang]/@pathcallbuild-url
withelement$element/..
withlang$lang