Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added handling of rdf:datatype. Test Example 10 working.

Ignore-this: c47d077a64eb8f795c72d51d3d48df

darcs-hash:20110130232611-1786f-5c891bec0d00aae153f1d22144156d0609e282e1.gz
  • Loading branch information...
commit d964ff3d033d16929f9a7eeef91f9e8085ea6b46 1 parent 5542b99
Alex McCausland authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/Text/RDF/RDF4H/XmlParser.hs
5 src/Text/RDF/RDF4H/XmlParser.hs
View
@@ -76,6 +76,7 @@ parsePredicatesFromChildren :: forall a. (ArrowXml a, ArrowState GParseState a)
parsePredicatesFromChildren = updateState
>>> choiceA [ second (hasAttrValue "rdf:parseType" (== "Literal")) :-> arr2A getLiteralTriple
, second (hasAttrValue "rdf:parseType" (== "Collection")) :-> arr2A getCollectionTriples
+ , second (hasAttr "rdf:datatype") :-> arr2A getTypedTriple
, second (hasAttr "rdf:resource") :-> arr2A getResourceTriple
, this :-> proc (state, predXml) -> do
p <- arr(unode . s2b) <<< getName -< predXml
@@ -109,6 +110,10 @@ getLiteralTriple :: forall a. (ArrowXml a, ArrowState GParseState a) => LParseSt
getLiteralTriple state = ((getName >>> arr (unode . s2b)) &&& (xshow ( getChildren ) >>> arr (mkTypedLiteralNode state nodeType))) >>> arr (attachSubject (stateSubject state))
where nodeType = mkFastString (s2b "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral")
+-- |Read a Triple and it's type when rdf:datatype is available
+getTypedTriple :: forall a. (ArrowXml a, ArrowState GParseState a) => LParseState -> a XmlTree Triple
+getTypedTriple state = ((getName >>> arr (unode . s2b)) &&& (getAttrValue "rdf:datatype" &&& xshow (getChildren) >>> arr (\(t, v) -> lnode (typedL (s2b v) (mkFastString (s2b t)))))) >>> arr (attachSubject (stateSubject state))
+
-- TODO
getCollectionTriples :: forall a. (ArrowXml a, ArrowState GParseState a) => LParseState -> a XmlTree Triple
getCollectionTriples state = none
Please sign in to comment.
Something went wrong with that request. Please try again.