XPath can be used to return all elements of with specific language
//ns:div[@xml:lang="lat"]
//
Selects nodes that match the selection no matter where they are.ns:
Is used to specify the HisTEI namespace.div
Selects all div elements.@xml:lang
Specifies the the requirement to have an attribute named xml:lang (language).="lat"
Specifies language as Latin.XQuery expression to filter the results by criteria such as date
for $i in //ns:div[@xml:lang="lat"]
where $i/ancestor::ns:div//ns:date[@when="1501-10-20"]
return $i
for $i in //ns:div[@xml:lang="lat"]
Starts a loop which iterates trough each result from the Search for element query.where $i/ancestor::ns:div//ns:date[@when="1501-10-20"]
the elements can be filtered by specifing criteria. In this instance the date being "1501-10-20"return $i
if a element matches the date 1501-10-20, it will shown as result on the result page.Search through time period by using regular expressions
for $i in //ns:div[@xml:lang="lat"]
where $i/ancestor::ns:div//ns:date[@when >"1501-1-1"][@when <"1502-12-31"]
return $i
XQuery expression which counts the number of words in Scots and Latin
for $lang in ("lat", "sco")
return (
concat("Words annotated as ", $lang, ": ",
count(for $j in (
for $i in //ns:div[@xml:lang = $lang ][@xml:id >"ARO-5-0730-01"][@xml:id <"ARO-5-0730-03"]//*
return if (not($i/@xml:lang) or $i/@xml:lang = $lang) then (
tokenize( normalize-space( string-join( $i/text(), ' ') ), ' ' )
) else ()
)
where matches($j, '[0-9a-zA-Z]')
return $j
)
+
count(for $j in (
for $i in //ns:div[@xml:lang != $lang][@xml:id >"ARO-5-0730-01"][@xml:id <"ARO-5-0730-03"]//*
return if ($i/@xml:lang = $lang) then (
tokenize( normalize-space( string-join( $i/text(), ' ') ), ' ' )
) else ()
)
where matches($j, '[0-9a-zA-Z]')
return $j
)
)
)
for $lang in ("lat", "sco")
We perform the same opertaion for both languages codes "lat" (Latin) and "sco" (Scots)[@xml:id >"ARO-5-0730-01"][@xml:id <"ARO-5-0730-03"]
Search for pages with xml:id between ARO-5-0730-01 and ARO-5-0730-03