rsrsss/xquery/opml/feeds.xqy

28 lines
1.1 KiB
Plaintext

xquery version "3.0" encoding "utf-8";
import module namespace rsrsss = "https://envs.net/~lucidiot/rsrsss/rsrsss-functions" at "../functions.xqy";
rsrsss:make-opml(
"RSRSSS curated feeds",
for $item in /rss/channel/item[category[@domain='https://envs.net/~lucidiot/rsrsss/' and (text()='Feed' or text()='OPML')] and link]
return element outline {
attribute type {
if (exists($item/category[@domain='https://envs.net/~lucidiot/rsrsss/' and (text()='OPML')]))
then 'include'
else 'rss'
},
attribute text {$item/title},
attribute title {$item/title},
attribute xmlUrl {$item/link},
if (exists($item/description)) then attribute description {normalize-space($item/description)} else (),
if (exists($item/pubDate)) then attribute created {$item/pubDate} else (),
let $categories := string-join(
$item/category[@domain='https://envs.net/~lucidiot/rsrsss/' and (text()!='OPML' and text()!='Feed')]/text()
! concat('/', .),
','
)
return if (string-length($categories) > 0)
then attribute category {$categories}
else ()
}
)