Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.4 kB
1
Indexable
Never
let $channel := 
                        for $ch in $sr/sr/channels/channel
                        where $ch/name = "P2"
                        return $ch

                    let $programs := 
                        for $p in $sr/sr/programs/program
                        where $p/channel = $channel/@id
                        return $p

                    let $editors :=
                        distinct-values($programs/editor)

                    let $category := 
                        for $ca in $sr/sr/categories/category
                        where $ca/@id = $programs/category
                        return $ca

                    let $editor_categories :=
                        for $e in $editors
                        return
                        <res>
                        <editor>{concat($e, ",")}</editor>
                        <categories>
                        {
                            distinct-values(
                            for $p in $programs
                            where $p/editor = $e
                            return <category>{$category[@id = $p/category]}</category>)
                        }
                        </categories>
                        </res>

                    for $editor_categorie in $editor_categories
                    return <li>{string($editor_categorie)}</li>