rdf-mt/commit
Added XMLLiteral support
author | Jan Wielemaker |
---|---|
Tue Dec 17 15:50:22 2013 +0100 | |
committer | Jan Wielemaker |
Tue Dec 17 15:50:22 2013 +0100 | |
commit | 9299e39f6f11ce05aa7c419de9e4506a1c9d87b4 |
tree | f59f5a12342f1966d43024966a7a7ef44113e0c6 |
parent | cf0bd88b99ae493fbe157d2987887bf21c0de327 |
Diff style: patch stat
diff --git a/lib/rdf_mt/graph_consistency.pl b/lib/rdf_mt/graph_consistency.pl index bb134e0..0efbb9c 100644 --- a/lib/rdf_mt/graph_consistency.pl +++ b/lib/rdf_mt/graph_consistency.pl @@ -36,6 +36,8 @@ ]). :- use_module(library(apply)). :- use_module(library(xsdp_types)). +:- use_module(library(memfile)). +:- use_module(library(sgml)). :- use_module(library(semweb/rdf_db)). @@ -75,7 +77,11 @@ invalid_datatype_assertion(S, rdfs:subClassOf, O) :- xsd_datatype(O), \+ xsd_subtype_of(S, O). -term_expansion(xsd_datatype(_), Clauses) :- +term_expansion(xsd_datatype(_), + [ xsd_datatype(LangString) + | Clauses + ]) :- + rdf_equal(rdf:langString, LangString), findall(xsd_datatype(DataType), ( xsdp_type(Type), rdf_global_id(xsd:Type, DataType) @@ -128,6 +134,10 @@ literal_value2(type(Type, String), boolean(Value), Props) :- \+ get_dict(boolean, Props, false), rdf_equal(Type, xsd:boolean), !, bool(String, Value). +literal_value2(type(XMLLiteral, String), xml(DOM), Props) :- + rdf_equal(rdf:'XMLLiteral', XMLLiteral), + \+ get_dict('XMLLiteral', Props, false), !, + atom_xml_dom(String, DOM). literal_value2(type(Type, String), type(Type, String), _) :- !. literal_value2(lang(Lang,String), lang(CanonicalLang, String), _) :- !, downcase_atom(Lang, CanonicalLang). @@ -164,6 +174,23 @@ bool(true, true). bool('0', false). bool('1', true). +%% atom_xml_dom(+String, -XMLDom) is semidet. +% +% Run XML parser on String. Fails if there are errors in the +% string. + +atom_xml_dom(String, DOM) :- + setup_call_cleanup( + atom_to_memory_file(String, MF), + setup_call_cleanup( + open_memory_file(MF, read, In), + catch(load_xml(In, DOM, + [ max_errors(0) + ]), + _, (nodebug, fail)), % BUG: Should not start debug mode + close(In)), + free_memory_file(MF)). + %% graph_value_space(+Graph, -ValueSpacedGraph, Props) is semidet. %