module Text.RSS1.Export
( xmlFeed
, textFeed
) where
import Prelude.Compat
import qualified Data.Text.Util as U
import Text.DublinCore.Types
import Text.RSS1.Syntax
import Text.RSS1.Utils
import Data.List.Compat
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
import Data.XML.Compat
import Data.XML.Types as XML
qualNode :: (Maybe Text, Maybe Text) -> Text -> [XML.Node] -> XML.Element
qualNode :: (Maybe Text, Maybe Text) -> Text -> [Node] -> Element
qualNode (Maybe Text, Maybe Text)
ns Text
n [Node]
cs = Element :: Name -> [(Name, [Content])] -> [Node] -> Element
Element {elementName :: Name
elementName = (Maybe Text, Maybe Text) -> Text -> Name
qualName (Maybe Text, Maybe Text)
ns Text
n, elementAttributes :: [(Name, [Content])]
elementAttributes = [], elementNodes :: [Node]
elementNodes = [Node]
cs}
qualNode' :: (Text, Text) -> Text -> [XML.Node] -> XML.Element
qualNode' :: (Text, Text) -> Text -> [Node] -> Element
qualNode' (Text
uri, Text
pre) = (Maybe Text, Maybe Text) -> Text -> [Node] -> Element
qualNode (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
uri, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
pre)
xmlFeed :: Feed -> XML.Element
xmlFeed :: Feed -> Element
xmlFeed Feed
f =
((Text, Text) -> Text -> [Node] -> Element
qualNode' (Text
rdfNS, Text
rdfPrefix) Text
"RDF" ([Node] -> Element) -> [Node] -> Element
forall a b. (a -> b) -> a -> b
$
(Element -> Node) -> [Element] -> [Node]
forall a b. (a -> b) -> [a] -> [b]
map
Element -> Node
NodeElement
([[Element]] -> [Element]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Channel -> Element
xmlChannel (Feed -> Channel
feedChannel Feed
f)]
, (Image -> Element) -> Maybe Image -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb Image -> Element
xmlImage (Feed -> Maybe Image
feedImage Feed
f)
, (Item -> Element) -> [Item] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map Item -> Element
xmlItem (Feed -> [Item]
feedItems Feed
f)
, (TextInputInfo -> Element) -> Maybe TextInputInfo -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb TextInputInfo -> Element
xmlTextInput (Feed -> Maybe TextInputInfo
feedTextInput Feed
f)
, (TaxonomyTopic -> Element) -> [TaxonomyTopic] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map TaxonomyTopic -> Element
xmlTopic (Feed -> [TaxonomyTopic]
feedTopics Feed
f)
, Feed -> [Element]
feedOther Feed
f
]))
{ elementAttributes :: [(Name, [Content])]
elementAttributes =
[(Name, [Content])] -> [(Name, [Content])]
forall a. Eq a => [a] -> [a]
nub ([(Name, [Content])] -> [(Name, [Content])])
-> [(Name, [Content])] -> [(Name, [Content])]
forall a b. (a -> b) -> a -> b
$
Name -> Text -> (Name, [Content])
mkNAttr ((Maybe Text, Maybe Text) -> Text -> Name
qualName (Maybe Text
forall a. Maybe a
Nothing, Maybe Text
forall a. Maybe a
Nothing) Text
"xmlns") Text
rss10NS (Name, [Content]) -> [(Name, [Content])] -> [(Name, [Content])]
forall a. a -> [a] -> [a]
:
Name -> Text -> (Name, [Content])
mkNAttr ((Maybe Text, Maybe Text) -> Text -> Name
qualName (Maybe Text
forall a. Maybe a
Nothing, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"xmlns") Text
rdfPrefix) Text
rdfNS (Name, [Content]) -> [(Name, [Content])] -> [(Name, [Content])]
forall a. a -> [a] -> [a]
:
Name -> Text -> (Name, [Content])
mkNAttr ((Maybe Text, Maybe Text) -> Text -> Name
qualName (Maybe Text
forall a. Maybe a
Nothing, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"xmlns") Text
synPrefix) Text
synNS (Name, [Content]) -> [(Name, [Content])] -> [(Name, [Content])]
forall a. a -> [a] -> [a]
:
Name -> Text -> (Name, [Content])
mkNAttr ((Maybe Text, Maybe Text) -> Text -> Name
qualName (Maybe Text
forall a. Maybe a
Nothing, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"xmlns") Text
taxPrefix) Text
taxNS (Name, [Content]) -> [(Name, [Content])] -> [(Name, [Content])]
forall a. a -> [a] -> [a]
:
Name -> Text -> (Name, [Content])
mkNAttr ((Maybe Text, Maybe Text) -> Text -> Name
qualName (Maybe Text
forall a. Maybe a
Nothing, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"xmlns") Text
conPrefix) Text
conNS (Name, [Content]) -> [(Name, [Content])] -> [(Name, [Content])]
forall a. a -> [a] -> [a]
:
Name -> Text -> (Name, [Content])
mkNAttr ((Maybe Text, Maybe Text) -> Text -> Name
qualName (Maybe Text
forall a. Maybe a
Nothing, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"xmlns") Text
dcPrefix) Text
dcNS (Name, [Content]) -> [(Name, [Content])] -> [(Name, [Content])]
forall a. a -> [a] -> [a]
: Feed -> [(Name, [Content])]
feedAttrs Feed
f
}
textFeed :: Feed -> Maybe TL.Text
textFeed :: Feed -> Maybe Text
textFeed = (Feed -> Element) -> Feed -> Maybe Text
forall a. (a -> Element) -> a -> Maybe Text
U.renderFeed Feed -> Element
xmlFeed
xmlChannel :: Channel -> XML.Element
xmlChannel :: Channel -> Element
xmlChannel Channel
ch =
((Maybe Text, Maybe Text) -> Text -> [Node] -> Element
qualNode (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"channel" ([Node] -> Element) -> [Node] -> Element
forall a b. (a -> b) -> a -> b
$
(Element -> Node) -> [Element] -> [Node]
forall a b. (a -> b) -> [a] -> [b]
map
Element -> Node
NodeElement
([ (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"title" (Channel -> Text
channelTitle Channel
ch)
, (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"link" (Channel -> Text
channelLink Channel
ch)
, (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"description" (Channel -> Text
channelDesc Channel
ch)
] [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
(Text -> Element) -> Maybe Text -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb Text -> Element
xmlTextInputURI (Channel -> Maybe Text
channelTextInputURI Channel
ch) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
(Text -> Element) -> Maybe Text -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb Text -> Element
xmlImageURI (Channel -> Maybe Text
channelImageURI Channel
ch) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
[Text] -> [Element]
xmlItemURIs (Channel -> [Text]
channelItemURIs Channel
ch) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
(DCItem -> Element) -> [DCItem] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map DCItem -> Element
xmlDC (Channel -> [DCItem]
channelDC Channel
ch) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
[[Element]] -> [Element]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ (UpdatePeriod -> Element) -> Maybe UpdatePeriod -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb UpdatePeriod -> Element
xmlUpdatePeriod (Channel -> Maybe UpdatePeriod
channelUpdatePeriod Channel
ch)
, (Integer -> Element) -> Maybe Integer -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb Integer -> Element
xmlUpdateFreq (Channel -> Maybe Integer
channelUpdateFreq Channel
ch)
, (Text -> Element) -> Maybe Text -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb ((Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
synNS, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
synPrefix) Text
"updateBase") (Channel -> Maybe Text
channelUpdateBase Channel
ch)
] [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
[ContentInfo] -> [Element]
xmlContentItems (Channel -> [ContentInfo]
channelContent Channel
ch) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [Text] -> [Element]
xmlTopics (Channel -> [Text]
channelTopics Channel
ch) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ Channel -> [Element]
channelOther Channel
ch))
{ elementAttributes :: [(Name, [Content])]
elementAttributes =
Name -> Text -> (Name, [Content])
mkNAttr ((Text, Text) -> Text -> Name
qualName' (Text
rdfNS, Text
rdfPrefix) Text
"about") (Channel -> Text
channelURI Channel
ch) (Name, [Content]) -> [(Name, [Content])] -> [(Name, [Content])]
forall a. a -> [a] -> [a]
: Channel -> [(Name, [Content])]
channelAttrs Channel
ch
}
xmlImageURI :: URIString -> XML.Element
xmlImageURI :: Text -> Element
xmlImageURI Text
u = (Text, Maybe Text) -> Text -> [(Name, [Content])] -> Element
xmlEmpty (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"image" [Name -> Text -> (Name, [Content])
mkNAttr (Text -> Name
rdfName Text
"resource") Text
u]
xmlImage :: Image -> XML.Element
xmlImage :: Image -> Element
xmlImage Image
i =
((Maybe Text, Maybe Text) -> Text -> [Node] -> Element
qualNode (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"image" ([Node] -> Element) -> [Node] -> Element
forall a b. (a -> b) -> a -> b
$
(Element -> Node) -> [Element] -> [Node]
forall a b. (a -> b) -> [a] -> [b]
map
Element -> Node
NodeElement
([ (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"title" (Image -> Text
imageTitle Image
i)
, (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"url" (Image -> Text
imageURL Image
i)
, (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"link" (Image -> Text
imageLink Image
i)
] [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
(DCItem -> Element) -> [DCItem] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map DCItem -> Element
xmlDC (Image -> [DCItem]
imageDC Image
i) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ Image -> [Element]
imageOther Image
i))
{elementAttributes :: [(Name, [Content])]
elementAttributes = Name -> Text -> (Name, [Content])
mkNAttr ((Text, Text) -> Text -> Name
qualName' (Text
rdfNS, Text
rdfPrefix) Text
"about") (Image -> Text
imageURI Image
i) (Name, [Content]) -> [(Name, [Content])] -> [(Name, [Content])]
forall a. a -> [a] -> [a]
: Image -> [(Name, [Content])]
imageAttrs Image
i}
xmlItemURIs :: [URIString] -> [XML.Element]
xmlItemURIs :: [Text] -> [Element]
xmlItemURIs [] = []
xmlItemURIs [Text]
xs =
[ (Maybe Text, Maybe Text) -> Text -> [Node] -> Element
qualNode
(Text -> Maybe Text
forall a. a -> Maybe a
Just Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing)
Text
"items"
[Element -> Node
NodeElement ((Text, Text) -> Text -> [Node] -> Element
qualNode' (Text
rdfNS, Text
rdfPrefix) Text
"Seq" ((Text -> Node) -> [Text] -> [Node]
forall a b. (a -> b) -> [a] -> [b]
map Text -> Node
toRes [Text]
xs))]
]
where
toRes :: Text -> Node
toRes Text
u = Element -> Node
NodeElement ((Text, Maybe Text) -> Text -> [(Name, [Content])] -> Element
xmlEmpty (Text
rdfNS, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
rdfPrefix) Text
"li" [Name -> Text -> (Name, [Content])
mkNAttr (Text -> Name
rdfName Text
"resource") Text
u])
xmlTextInputURI :: URIString -> XML.Element
xmlTextInputURI :: Text -> Element
xmlTextInputURI Text
u = (Text, Maybe Text) -> Text -> [(Name, [Content])] -> Element
xmlEmpty (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"textinput" [Name -> Text -> (Name, [Content])
mkNAttr (Text -> Name
rdfName Text
"resource") Text
u]
xmlTextInput :: TextInputInfo -> XML.Element
xmlTextInput :: TextInputInfo -> Element
xmlTextInput TextInputInfo
ti =
((Maybe Text, Maybe Text) -> Text -> [Node] -> Element
qualNode (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"textinput" ([Node] -> Element) -> [Node] -> Element
forall a b. (a -> b) -> a -> b
$
(Element -> Node) -> [Element] -> [Node]
forall a b. (a -> b) -> [a] -> [b]
map Element -> Node
NodeElement ([Element] -> [Node]) -> [Element] -> [Node]
forall a b. (a -> b) -> a -> b
$
[ (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"title" (TextInputInfo -> Text
textInputTitle TextInputInfo
ti)
, (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"description" (TextInputInfo -> Text
textInputDesc TextInputInfo
ti)
, (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"name" (TextInputInfo -> Text
textInputName TextInputInfo
ti)
, (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"link" (TextInputInfo -> Text
textInputLink TextInputInfo
ti)
] [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
(DCItem -> Element) -> [DCItem] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map DCItem -> Element
xmlDC (TextInputInfo -> [DCItem]
textInputDC TextInputInfo
ti) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ TextInputInfo -> [Element]
textInputOther TextInputInfo
ti)
{elementAttributes :: [(Name, [Content])]
elementAttributes = Name -> Text -> (Name, [Content])
mkNAttr (Text -> Name
rdfName Text
"about") (TextInputInfo -> Text
textInputURI TextInputInfo
ti) (Name, [Content]) -> [(Name, [Content])] -> [(Name, [Content])]
forall a. a -> [a] -> [a]
: TextInputInfo -> [(Name, [Content])]
textInputAttrs TextInputInfo
ti}
xmlDC :: DCItem -> XML.Element
xmlDC :: DCItem -> Element
xmlDC DCItem
dc = (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
dcNS, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
dcPrefix) (DCInfo -> Text
infoToTag (DCItem -> DCInfo
dcElt DCItem
dc)) (DCItem -> Text
dcText DCItem
dc)
xmlUpdatePeriod :: UpdatePeriod -> XML.Element
xmlUpdatePeriod :: UpdatePeriod -> Element
xmlUpdatePeriod UpdatePeriod
u = (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
synNS, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
synPrefix) Text
"updatePeriod" (UpdatePeriod -> Text
forall p. IsString p => UpdatePeriod -> p
toStr UpdatePeriod
u)
where
toStr :: UpdatePeriod -> p
toStr UpdatePeriod
ux =
case UpdatePeriod
ux of
UpdatePeriod
Update_Hourly -> p
"hourly"
UpdatePeriod
Update_Daily -> p
"daily"
UpdatePeriod
Update_Weekly -> p
"weekly"
UpdatePeriod
Update_Monthly -> p
"monthly"
UpdatePeriod
Update_Yearly -> p
"yearly"
xmlUpdateFreq :: Integer -> XML.Element
xmlUpdateFreq :: Integer -> Element
xmlUpdateFreq Integer
f = (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
synNS, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
synPrefix) Text
"updateFrequency" (String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Integer -> String
forall a. Show a => a -> String
show Integer
f)
xmlContentItems :: [ContentInfo] -> [XML.Element]
xmlContentItems :: [ContentInfo] -> [Element]
xmlContentItems [] = []
xmlContentItems [ContentInfo]
xs =
[ (Text, Text) -> Text -> [Node] -> Element
qualNode'
(Text
conNS, Text
conPrefix)
Text
"items"
[ Element -> Node
NodeElement (Element -> Node) -> Element -> Node
forall a b. (a -> b) -> a -> b
$
(Text, Text) -> Text -> [Node] -> Element
qualNode'
(Text
rdfNS, Text
rdfPrefix)
Text
"Bag"
((ContentInfo -> Node) -> [ContentInfo] -> [Node]
forall a b. (a -> b) -> [a] -> [b]
map
(\ContentInfo
e -> Element -> Node
NodeElement ((Text, Text) -> Text -> [Node] -> Element
qualNode' (Text
rdfNS, Text
rdfPrefix) Text
"li" [Element -> Node
NodeElement (ContentInfo -> Element
xmlContentInfo ContentInfo
e)]))
[ContentInfo]
xs)
]
]
xmlContentInfo :: ContentInfo -> XML.Element
xmlContentInfo :: ContentInfo -> Element
xmlContentInfo ContentInfo
ci =
((Text, Text) -> Text -> [Node] -> Element
qualNode' (Text
conNS, Text
conPrefix) Text
"item" ([Node] -> Element) -> [Node] -> Element
forall a b. (a -> b) -> a -> b
$
(Element -> Node) -> [Element] -> [Node]
forall a b. (a -> b) -> [a] -> [b]
map
Element -> Node
NodeElement
([[Element]] -> [Element]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ (Text -> Element) -> Maybe Text -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb ((Text, Text) -> Text -> Text -> Element
rdfResource (Text
conNS, Text
conPrefix) Text
"format") (ContentInfo -> Maybe Text
contentFormat ContentInfo
ci)
, (Text -> Element) -> Maybe Text -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb ((Text, Text) -> Text -> Text -> Element
rdfResource (Text
conNS, Text
conPrefix) Text
"encoding") (ContentInfo -> Maybe Text
contentEncoding ContentInfo
ci)
, (Text -> Element) -> Maybe Text -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb ([(Name, [Content])] -> Text -> Element
rdfValue []) (ContentInfo -> Maybe Text
contentValue ContentInfo
ci)
]))
{elementAttributes :: [(Name, [Content])]
elementAttributes = (Text -> (Name, [Content])) -> Maybe Text -> [(Name, [Content])]
forall a b. (a -> b) -> Maybe a -> [b]
mb (Name -> Text -> (Name, [Content])
mkNAttr (Text -> Name
rdfName Text
"about")) (ContentInfo -> Maybe Text
contentURI ContentInfo
ci)}
rdfResource :: (Text, Text) -> Text -> Text -> XML.Element
rdfResource :: (Text, Text) -> Text -> Text -> Element
rdfResource (Text
uri, Text
pre) Text
t Text
v = (Text, Maybe Text) -> Text -> [(Name, [Content])] -> Element
xmlEmpty (Text
uri, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
pre) Text
t [Name -> Text -> (Name, [Content])
mkNAttr (Text -> Name
rdfName Text
"resource") Text
v]
rdfValue :: [Attr] -> Text -> XML.Element
rdfValue :: [(Name, [Content])] -> Text -> Element
rdfValue [(Name, [Content])]
as Text
s = ((Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rdfNS, Text -> Maybe Text
forall a. a -> Maybe a
Just Text
rdfPrefix) Text
"value" Text
s) {elementAttributes :: [(Name, [Content])]
elementAttributes = [(Name, [Content])]
as}
xmlTopics :: [URIString] -> [XML.Element]
xmlTopics :: [Text] -> [Element]
xmlTopics [] = []
xmlTopics [Text]
xs =
[ (Text, Text) -> Text -> [Node] -> Element
qualNode'
(Text
taxNS, Text
taxPrefix)
Text
"topics"
[ Element -> Node
NodeElement
((Text, Text) -> Text -> [Node] -> Element
qualNode'
(Text
rdfNS, Text
rdfPrefix)
Text
"Bag"
((Text -> Node) -> [Text] -> [Node]
forall a b. (a -> b) -> [a] -> [b]
map (Element -> Node
NodeElement (Element -> Node) -> (Text -> Element) -> Text -> Node
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text, Text) -> Text -> Text -> Element
rdfResource (Text
rdfNS, Text
rdfPrefix) Text
"li") [Text]
xs))
]
]
xmlTopic :: TaxonomyTopic -> XML.Element
xmlTopic :: TaxonomyTopic -> Element
xmlTopic TaxonomyTopic
tt =
((Text, Text) -> Text -> [Node] -> Element
qualNode' (Text
taxNS, Text
taxPrefix) Text
"topic" ([Node] -> Element) -> [Node] -> Element
forall a b. (a -> b) -> a -> b
$
(Element -> Node) -> [Element] -> [Node]
forall a b. (a -> b) -> [a] -> [b]
map
Element -> Node
NodeElement
((Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"link" (TaxonomyTopic -> Text
taxonomyLink TaxonomyTopic
tt) Element -> [Element] -> [Element]
forall a. a -> [a] -> [a]
:
(Text -> Element) -> Maybe Text -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb ((Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"title") (TaxonomyTopic -> Maybe Text
taxonomyTitle TaxonomyTopic
tt) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
(Text -> Element) -> Maybe Text -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb ((Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"description") (TaxonomyTopic -> Maybe Text
taxonomyDesc TaxonomyTopic
tt) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
[Text] -> [Element]
xmlTopics (TaxonomyTopic -> [Text]
taxonomyTopics TaxonomyTopic
tt) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (DCItem -> Element) -> [DCItem] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map DCItem -> Element
xmlDC (TaxonomyTopic -> [DCItem]
taxonomyDC TaxonomyTopic
tt) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ TaxonomyTopic -> [Element]
taxonomyOther TaxonomyTopic
tt))
{elementAttributes :: [(Name, [Content])]
elementAttributes = [Name -> Text -> (Name, [Content])
mkNAttr (Text -> Name
rdfName Text
"about") (TaxonomyTopic -> Text
taxonomyURI TaxonomyTopic
tt)]}
xmlItem :: Item -> XML.Element
xmlItem :: Item -> Element
xmlItem Item
i =
((Maybe Text, Maybe Text) -> Text -> [Node] -> Element
qualNode (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"item" ([Node] -> Element) -> [Node] -> Element
forall a b. (a -> b) -> a -> b
$
(Element -> Node) -> [Element] -> [Node]
forall a b. (a -> b) -> [a] -> [b]
map
Element -> Node
NodeElement
([ (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"title" (Item -> Text
itemTitle Item
i)
, (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"link" (Item -> Text
itemLink Item
i)
] [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
(Text -> Element) -> Maybe Text -> [Element]
forall a b. (a -> b) -> Maybe a -> [b]
mb ((Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
rss10NS, Maybe Text
forall a. Maybe a
Nothing) Text
"description") (Item -> Maybe Text
itemDesc Item
i) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
(DCItem -> Element) -> [DCItem] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map DCItem -> Element
xmlDC (Item -> [DCItem]
itemDC Item
i) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++
[Text] -> [Element]
xmlTopics (Item -> [Text]
itemTopics Item
i) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (ContentInfo -> Element) -> [ContentInfo] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map ContentInfo -> Element
xmlContentInfo (Item -> [ContentInfo]
itemContent Item
i) [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ Item -> [Element]
itemOther Item
i))
{elementAttributes :: [(Name, [Content])]
elementAttributes = Name -> Text -> (Name, [Content])
mkNAttr ((Text, Text) -> Text -> Name
qualName' (Text
rdfNS, Text
rdfPrefix) Text
"about") (Item -> Text
itemURI Item
i) (Name, [Content]) -> [(Name, [Content])] -> [(Name, [Content])]
forall a. a -> [a] -> [a]
: Item -> [(Name, [Content])]
itemAttrs Item
i}
xmlLeaf :: (Text, Maybe Text) -> Text -> Text -> XML.Element
xmlLeaf :: (Text, Maybe Text) -> Text -> Text -> Element
xmlLeaf (Text
ns, Maybe Text
pre) Text
tg Text
txt =
Element :: Name -> [(Name, [Content])] -> [Node] -> Element
Element
{ elementName :: Name
elementName = (Maybe Text, Maybe Text) -> Text -> Name
qualName (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
ns, Maybe Text
pre) Text
tg
, elementAttributes :: [(Name, [Content])]
elementAttributes = []
, elementNodes :: [Node]
elementNodes = [Content -> Node
NodeContent (Content -> Node) -> Content -> Node
forall a b. (a -> b) -> a -> b
$ Text -> Content
ContentText Text
txt]
}
xmlEmpty :: (Text, Maybe Text) -> Text -> [Attr] -> XML.Element
xmlEmpty :: (Text, Maybe Text) -> Text -> [(Name, [Content])] -> Element
xmlEmpty (Text
uri, Maybe Text
pre) Text
t [(Name, [Content])]
as = ((Maybe Text, Maybe Text) -> Text -> [Node] -> Element
qualNode (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
uri, Maybe Text
pre) Text
t []) {elementAttributes :: [(Name, [Content])]
elementAttributes = [(Name, [Content])]
as}
mb :: (a -> b) -> Maybe a -> [b]
mb :: (a -> b) -> Maybe a -> [b]
mb a -> b
_ Maybe a
Nothing = []
mb a -> b
f (Just a
x) = [a -> b
f a
x]