X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FXML%2FNews.hs;h=a388415ff7109264e418d3338a68faea77654ee1;hb=6ed05f33ffaa8b000d36ab3f5ab62eed4022d27a;hp=67611e512bbcf55d85caac39b61cfe766dc3957d;hpb=4cdcdbe593c30f6434a25896951a1a4dfcc2b1ca;p=dead%2Fhtsn-import.git diff --git a/src/TSN/XML/News.hs b/src/TSN/XML/News.hs index 67611e5..a388415 100644 --- a/src/TSN/XML/News.hs +++ b/src/TSN/XML/News.hs @@ -11,8 +11,8 @@ -- root element \ that contains an entire news item. -- module TSN.XML.News ( - Message, - news_tests ) + news_tests, + pickle_message ) where import Data.Data ( Data, constrFields, dataTypeConstrs, dataTypeOf ) @@ -31,7 +31,6 @@ import Test.Tasty ( TestTree, testGroup ) import Test.Tasty.HUnit ( (@?=), testCase ) import Text.XML.HXT.Core ( PU, - XmlPickler(..), xp13Tuple, xpAttr, xpElem, @@ -114,7 +113,7 @@ data Message = xml_mid :: MsgId, xml_category :: String, xml_sport :: String, - xml_url :: String, + xml_url :: Maybe String, xml_teams :: [NewsTeam], xml_locations :: [NewsLocation], xml_sms :: String, @@ -128,7 +127,7 @@ data News = News { db_mid :: MsgId, db_sport :: String, - db_url :: String, + db_url :: Maybe String, db_sms :: String, db_editor :: Maybe String, db_text :: Maybe String, @@ -237,8 +236,6 @@ pickle_news_team = from_string :: String -> NewsTeam from_string = NewsTeam -instance XmlPickler NewsTeam where - xpickle = pickle_news_team pickle_msg_id :: PU MsgId pickle_msg_id = @@ -249,8 +246,6 @@ pickle_msg_id = from_tuple = uncurryN MsgId to_tuple m = (db_msg_id m, db_event_id m) -instance XmlPickler MsgId where - xpickle = pickle_msg_id pickle_location :: PU NewsLocation pickle_location = @@ -264,8 +259,6 @@ pickle_location = uncurryN NewsLocation to_tuple l = (city l, state l, country l) -instance XmlPickler NewsLocation where - xpickle = pickle_location pickle_message :: PU Message @@ -277,7 +270,7 @@ pickle_message = pickle_msg_id (xpElem "category" xpText) (xpElem "sport" xpText) - (xpElem "url" xpText) + (xpElem "url" $ xpOption xpText) (xpList pickle_news_team) (xpList pickle_location) (xpElem "SMS" xpText) @@ -314,9 +307,6 @@ pickle_message = to_string :: [String] -> String to_string = join "\n" -instance XmlPickler Message where - xpickle = pickle_message - -- * Tasty Tests