X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;ds=sidebyside;f=src%2FMain.hs;h=448577773dd8af187611d521f1db444916f532f3;hb=04f468994697d4d983a09a8e612948b23a973848;hp=e1f40267889c9e4a8a4609cb0a7e7bf9c3b47b95;hpb=cdd0f36ab4aa8aadc416f6b9cbe6117c26d2ddf2;p=dead%2Fhtsn-import.git diff --git a/src/Main.hs b/src/Main.hs index e1f4026..4485777 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -23,7 +23,6 @@ import System.IO.Error ( catchIOError ) import Text.XML.HXT.Core ( ArrowXml, IOStateArrow, - SysConfigList, XmlPickler, XmlTree, (>>>), @@ -31,16 +30,10 @@ import Text.XML.HXT.Core ( getAttrl, getText, hasName, - no, readDocument, runX, unpickleDoc, - withPreserveComment, - withRemoveWS, - withSubstDTDEntities, - withValidate, - xpickle, - yes ) + xpickle ) import Backend ( Backend(..) ) import CommandLine ( get_args ) @@ -61,22 +54,8 @@ import qualified TSN.InjuriesDetail as InjuriesDetail ( Listing ( player_listings ), Message ( listings ), PlayerListing ) - - - --- | A list of options passed to 'readDocument' when we parse an XML --- document. We don't validate because the DTDs from TSN are --- wrong. As a result, we don't want to keep useless DTDs --- areound. Thus we disable 'withSubstDTDEntities' which, when --- combined with "withValidate no", prevents HXT from trying to read --- the DTD at all. --- -parse_opts :: SysConfigList -parse_opts = - [ withPreserveComment no, - withRemoveWS yes, - withSubstDTDEntities no, - withValidate no ] +import qualified TSN.News as News ( Message ) +import Xml ( parse_opts ) -- | We put the 'Configuration' and 'XmlTree' arguments last so that @@ -113,6 +92,13 @@ import_generic dummy g cfg xml +-- | Import TSN.News from an 'XmlTree'. +import_news :: Configuration -> XmlTree -> IO (Maybe Int) +import_news = + import_generic + (undefined :: News.Message) + id + -- | Import TSN.Injuries from an 'XmlTree'. import_injuries :: Configuration -> XmlTree -> IO (Maybe Int) import_injuries = @@ -176,6 +162,7 @@ import_file cfg path = do import_with_dtd (dtd,xml) | dtd == "injuriesxml.dtd" = import_injuries cfg xml | dtd == "Injuries_Detail_XML.dtd" = import_injuries_detail cfg xml + | dtd == "newsxml.dtd" = import_news cfg xml | otherwise = do report_info $ "Unrecognized DTD in " ++ path ++ ": " ++ dtd ++ "." return Nothing