summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Redland/LowLevel.hs2
-rw-r--r--Redland/MidLevel.hs10
-rw-r--r--Redland/Util.hs8
3 files changed, 12 insertions, 8 deletions
diff --git a/Redland/LowLevel.hs b/Redland/LowLevel.hs
index 7be277a..75730a6 100644
--- a/Redland/LowLevel.hs
+++ b/Redland/LowLevel.hs
@@ -195,7 +195,7 @@ foreign import ccall "librdf_node_get_literal_value_language"
foreign import ccall "librdf_node_get_literal_value_datatype_uri"
librdf_node_get_literal_value_datatype_uri
:: Ptr RedlandNode
- -> IO CString
+ -> IO (Ptr RedlandURI)
-- ^ Literal datatype URI, must be copied
foreign import ccall "librdf_node_get_literal_value_is_wf_xml"
librdf_node_get_literal_value_is_wf_xml
diff --git a/Redland/MidLevel.hs b/Redland/MidLevel.hs
index c8e9aa6..e9f1993 100644
--- a/Redland/MidLevel.hs
+++ b/Redland/MidLevel.hs
@@ -289,10 +289,14 @@ nodeGetLiteralValueLanguage node =
withForeignPtr node $
librdf_node_get_literal_value_language >=> maybeSharedCString
-nodeGetLiteralValueDatatypeURI :: ForeignPtr RedlandNode -> IO (Maybe String)
+nodeGetLiteralValueDatatypeURI :: ForeignPtr RedlandNode
+ -> IO (Maybe (ForeignPtr RedlandURI))
nodeGetLiteralValueDatatypeURI node =
- withForeignPtr node $
- librdf_node_get_literal_value_datatype_uri >=> maybeSharedCString
+ withForeignPtr node $ \node' -> do
+ oldURI <- librdf_node_get_literal_value_datatype_uri node'
+ if oldURI == nullPtr
+ then pure Nothing
+ else Just <$> initialize (librdf_new_uri_from_uri oldURI) p_librdf_free_uri
nodeGetLiteralValueIsWellFormedXML :: ForeignPtr RedlandNode -> IO Bool
nodeGetLiteralValueIsWellFormedXML node =
diff --git a/Redland/Util.hs b/Redland/Util.hs
index 600cc83..e7ac295 100644
--- a/Redland/Util.hs
+++ b/Redland/Util.hs
@@ -79,10 +79,10 @@ redlandNodeToNode rn = do
litVal <- nodeGetLiteralValue rn
litLang <- nodeGetLiteralValueLanguage rn
litType <- nodeGetLiteralValueDatatypeURI rn
- let nType = case (litLang, litType) of
- (Just l, _) -> Just $ LanguageTag l
- (_, Just t) -> Just $ XMLSchema t
- _ -> Nothing
+ nType <- case (litLang, litType) of
+ (Just l, _) -> pure $ Just $ LanguageTag l
+ (_, Just t) -> Just . XMLSchema <$> uriAsString t
+ _ -> pure Nothing
pure $ LiteralNode litVal nType
_ -> ResourceNode <$> (nodeGetURI rn >>= uriAsString)