packages feed

rdf4h 1.2.2 → 1.2.3

raw patch · 3 files changed

+7/−16 lines, 3 files

Files

rdf4h.cabal view
@@ -1,5 +1,5 @@ name:            rdf4h-version:         1.2.2+version:         1.2.3 synopsis:        A library for RDF processing in Haskell description:        'RDF for Haskell' is a library for working with RDF in Haskell.
src/Rdf4hParseMain.hs view
@@ -34,7 +34,6 @@   do (opts, args) <- getArgs >>= compilerOpts      when (Help `elem` opts)       (putStrLn (usageInfo header options) >> exitSuccess)-     when (Version `elem` opts) (putStrLn version >> exitSuccess)      when (null args)       (ioError         (userError@@ -134,7 +133,7 @@  -- The commandline arguments we accept. None are required. data Flag- = Help | Debug | Version+ = Help | Debug  | InputFormat String | InputBaseUri String  | OutputFormat String | OutputBaseUri String  deriving (Show)@@ -145,13 +144,13 @@ instance Eq Flag where   Help            == Help            = True   Debug           == Debug           = True-  Version         == Version         = True   InputFormat _   == InputFormat _   = True   InputBaseUri _  == InputBaseUri _  = True   OutputFormat _  == OutputFormat _  = True   OutputBaseUri _ == OutputBaseUri _ = True   _               == _               = False + -- The top part of the usage output. header :: String header =@@ -162,18 +161,10 @@   "    Default is INPUT-URI\n"                                               ++   "    Equivalent to -I INPUT-BASE-URI, --input-base-uri INPUT-BASE-URI\n\n" --- The current version of the executable, which for the moment is the same as--- the version for the library as a whole, as given in rdf4h.cabal.--- TODO: should get this from cabal file rather than duplicating i here.-version :: String-version = "1.0.2"- options :: [OptDescr Flag] options =  [ Option "h"  ["help"]                           (NoArg Help)   "Display this help, then exit"  , Option "d"  ["debug"]                         (NoArg Debug)   "Print debug info (like INPUT-BASE-URI used, etc.)"- , Option "v"  ["version"]                     (NoArg Version)   "Show version number\n\n"-  , Option "i"  ["input"]        (ReqArg InputFormat  "FORMAT") $ "Set input format/parser to one of:\n" ++                                                                    "  turtle      Turtle (default)\n" ++                                                                    "  ntriples    N-Triples"
src/Text/RDF/RDF4H/XmlParser.hs view
@@ -15,7 +15,7 @@ import Data.RDF.Types (RDF,RdfParser(..),Node(BNodeGen),BaseUrl(..),Triple(..),Triples,Subject,Predicate,Object,PrefixMappings(..),ParseFailure(ParseFailure),mkRdf,lnode,plainL,plainLL,typedL,unode,bnode) import qualified Data.Text as T (Text,pack,unpack) import qualified Data.Text.IO as TIO-import Text.XML.HXT.Core (ArrowXml,XmlTree,IfThen((:->)),(>.),(>>.),first,neg,(<+>),expandURI,getName,getAttrValue,getAttrValue0,getAttrl,hasAttrValue,hasAttr,constA,choiceA,getChildren,ifA,arr2A,second,hasName,isElem,xshow,listA,isA,isText,getText,this,unlistA,orElse,sattr,mkelem,xreadDoc,runSLA)+import Text.XML.HXT.Core (ArrowXml,XmlTree,IfThen((:->)),(>.),(>>.),first,neg,(<+>),expandURI,getName,getAttrValue,getAttrValue0,getAttrl,hasAttrValue,hasAttr,constA,choiceA,getChildren,ifA,arr2A,second,hasName,isElem,isWhiteSpace,xshow,listA,isA,isText,getText,this,unlistA,orElse,sattr,mkelem,xreadDoc,runSLA)  -- TODO: write QuickCheck tests for XmlParser instance for RdfParser. @@ -161,7 +161,7 @@ parsePredicatesFromChildren = updateState     >>> choiceA         [ second (hasAttrValue "rdf:parseType" (== "Literal")) :-> arr2A parseAsLiteralTriple-        , second (hasAttrValue "rdf:parseType" (== "Resource")) :-> (defaultA <+> (mkBlankNode &&& arr id >>> arr2A parseAsResource))+        , second (hasAttrValue "rdf:parseType" (== "Resource")) :-> (mkBlankNode &&& arr id >>> arr2A parseAsResource)         , second (hasAttrValue "rdf:parseType" (== "Collection")) :-> (listA (defaultA >>> arr id &&& mkBlankNode) >>> mkCollectionTriples >>> unlistA)         , second (hasAttr "rdf:datatype") :-> arr2A getTypedTriple         , second (hasAttr "rdf:resource") :-> arr2A getResourceTriple@@ -181,8 +181,8 @@ parseObjectsFromChildren :: forall a. (ArrowXml a, ArrowState GParseState a)                          => LParseState -> Predicate -> a XmlTree Triple parseObjectsFromChildren s p = choiceA-    [ isText :-> (getText >>> arr (Triple (stateSubject s) p . mkLiteralNode s))-    , isElem :-> (hasName "rdf:Description" >>> parseObjectDescription)+    [ isText :-> (neg( isWhiteSpace) >>> getText >>> arr (Triple (stateSubject s) p . mkLiteralNode s))+    , isElem :-> (parseObjectDescription)     ]   where parseObjectDescription = proc desc -> do                                       o <- mkNode s -< desc