- tsn_db_field_namer -- Used in a test.
- )
-import TSN.DbImport ( DbImport(..), ImportResult(..) )
-import Xml ( ToFromXml(..), pickle_unpickle )
-
-
-
--- | The database type for teams as they show up in the news. We need
--- this separate from its XML representation because of the
--- DefaultKey pointing to a message. We don't know how to create one
--- of those unless we've just inserted a message into the database,
--- so it screws up pickling.
-data NewsTeam =
- NewsTeam {
- nt_news_id :: DefaultKey Message, -- ^ foreign key.
- db_team_name :: String }
-deriving instance Eq NewsTeam -- Standalone instances necessary for
-deriving instance Show NewsTeam -- Groundhog types with DefaultKeys
-
--- | The XML type for teams as they show up in the news. See
--- 'NewsTeam' for why there are two types.
-data NewsTeamXml =
- NewsTeamXml {
- xml_team_name :: String }
- deriving (Eq, Show)
-
--- | Specify how to convert between the two representations NewsTeam
--- (database) and NewsTeamXml (XML).
-instance ToFromXml NewsTeam where
- type Xml NewsTeam = NewsTeamXml
- type Container NewsTeam = Message
- -- Use a record wildcard here so GHC doesn't complain that we never
- -- used our named fields.
- to_xml (NewsTeam {..}) = NewsTeamXml db_team_name
- -- We can't create a DefaultKey Message...
- from_xml = error "Called from_xml on a NewsTeam."
- -- unless we're handed one.
- from_xml_fk key = (NewsTeam key) . xml_team_name
-
-
--- | The database type for locations as they show up in the news. We
--- need this separate from its XML representation because of the
--- DefaultKey pointing to a message. We don't know how to create one
--- of those unless we've just inserted a message into the database,
--- so it screws up pickling.
-data NewsLocation =
- NewsLocation {
- loc_news_id :: DefaultKey Message, -- ^ foreign key.
- db_city ::String,
- db_state :: String,
- db_country :: String }
-deriving instance Eq NewsLocation -- Standalone instances necessary for
-deriving instance Show NewsLocation -- Groundhog types with DefaultKeys
-
--- | The XML type for locations as they show up in the news. See
--- 'NewsLocation' for why there are two types.
-data NewsLocationXml =
- NewsLocationXml {
- xml_city :: String,
- xml_state :: String,
- xml_country :: String }
- deriving (Eq, Show)
-
-
--- | Specify how to convert between the two representations
--- NewsLocation (database) and NewsLocationXml (XML).
-instance ToFromXml NewsLocation where
- type Xml NewsLocation = NewsLocationXml
- type Container NewsLocation = Message
- -- Use a record wildcard here so GHC doesn't complain that we never
- -- used our named fields.
- to_xml (NewsLocation {..}) = NewsLocationXml db_city db_state db_country
- -- We can't create a DefaultKey Message...
- from_xml = error "Called from_xml on a NewsLocation."
- -- unless we're given one.
- from_xml_fk key (NewsLocationXml x y z) = NewsLocation key x y z
-
-
--- | The msg_id child of <message> contains an event_id attribute; we
--- embed it into the 'Message' type. We (pointlessly) use the "db_"
--- prefix here so that the two names collide on "id" when Groundhog
--- is creating its fields using our field namer.
+ tsn_db_field_namer ) -- Used in a test
+import TSN.Database ( insert_or_select )
+import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
+import TSN.Location ( Location(..), pickle_location )
+import TSN.Picklers ( xp_attr_option, xp_time_stamp )
+import TSN.Team ( Team(..) )
+import TSN.XmlImport ( XmlImport(..) )
+import Xml (
+ FromXml(..),
+ ToDb(..),
+ pickle_unpickle,
+ unpickleable,
+ unsafe_read_invalid_document,
+ unsafe_unpickle )
+
+
+-- | The DTD to which this module corresponds. Used to invoke dbimport.
+--
+dtd :: String
+dtd = "newsxml.dtd"
+
+
+--
+-- DB/XML Data types
+--
+
+-- * News/Message
+
+-- | The msg_id child of \<message\> contains an event_id attribute; we
+-- embed it into the 'News' type. We (pointlessly) use the \"db_\"
+-- prefix here so that the two names don't collide on \"id\" when
+-- Groundhog is creating its fields using our field namer.
+--
+-- The leading underscores prevent unused field warnings.
+--