--- a/semantics/checker.pl Wed Feb 06 16:47:03 2013 +0000
+++ b/semantics/checker.pl Wed Feb 06 17:18:29 2013 +0000
@@ -878,3 +878,14 @@
ordering_check(K),
typing(J,T),
impos_check(J,T).
+
+
+valid_document((I,Bundles)) :-
+ valid(I),
+ valid_bundles(Bundles).
+
+valid_bundles([],[]).
+valid_bundles([(ID,J)|Bundles]) :-
+ valid(J),
+ \+(member((ID,_),Bundles)),
+ valid_bundles(Bundles).
--- a/semantics/prov_xml.pl Wed Feb 06 16:47:03 2013 +0000
+++ b/semantics/prov_xml.pl Wed Feb 06 17:18:29 2013 +0000
@@ -19,11 +19,46 @@
% Read XML from Filename and
% bind J to a list of Prolog terms like
% [activity('ex:a1',_,_,[]), ... ]
-provx_load(Filename,K):-
+% Assumes a single instance with no bundle tags
+provx_load_instance(Filename,K):-
load_structure(Filename,X,[dialect(xmlns),space(remove)]),
provx(X,J),
postprocess(J,K).
+provx_load_document(Filename,K):-
+ load_structure(Filename,X,[dialect(xmlns),space(remove)]),
+ preprocess_document(X,D),
+ provx_document(D,J),
+ postprocess_document(J,K).
+
+% Split document into toplevel XML and identified bundles
+preprocess_document([element(Prov:document,_,Contents)],(X,Bundles)):-
+ ns(prov,Prov),
+ preprocess_contents(Contents,X,Bundles).
+
+preprocess_contents([],[],[]).
+preprocess_contents([element(Prov:bundle,Attrs,X)|Xs],Toplevel,[(ID,X)|Bundles]) :-
+ ns(prov,Prov),
+ attribute_value(Prov:id,Attrs,ID),
+ preprocess_contents(Xs,Toplevel,Bundles).
+
+preprocess_contents([element(NS:Tag,Attrs,X)|Xs],
+ [element(NS:Tag,Attrs,X)|Toplevel], Bundles) :-
+ Tag \= bundle,
+ preprocess_contents(Xs,Toplevel,Bundles).
+
+
+% Handle a document toplevel instance and bundles.
+provx_document((X,Xs),(J,Bundles)) :-
+ provx_expressions(X,J,[]),
+ provx_bundles(Xs,Bundles).
+
+provx_bundles([],[]).
+provx_bundles([(ID,X)|Xs],
+ [(ID,J)|Bundles]) :-
+ provx_expressions(X,J,[]),
+ provx_bundles(Xs,Bundles).
+
provx([element(Prov:document,_,Contents)|_Elements],J):-
ns(prov,Prov),
provx_expressions(Contents,J,[]).
@@ -172,3 +207,11 @@
postprocess([A|J],[A|K]) :- postprocess(J,K).
+postprocess_document((I,Bundles),(J,Bundles2)) :-
+ postprocess(I,J),
+ postprocess_bundles(Bundles,Bundles2).
+
+postprocess_bundles([],[]).
+postprocess_bundles([(ID,I)|Bundles],[(ID,J)|Bundles2]) :-
+ postprocess(I,J),
+ postprocess_bundles(Bundles,Bundles2).
--- a/semantics/prov_xml_test.pl Wed Feb 06 16:47:03 2013 +0000
+++ b/semantics/prov_xml_test.pl Wed Feb 06 17:18:29 2013 +0000
@@ -3,7 +3,7 @@
:- consult(prov_xml).
test1(J):-
- provx_load('constraint_test_provx/unification-usage-s2-PASS-c23.provx',J).
+ provx_load_document('constraint_test_provx/unification-bundle-f1-FAIL-c55-c56.provx',J).
% Test and report on directory of .provx files
% - only tests whether the mapping completes,
@@ -16,7 +16,7 @@
\+memberchk(File,['.','..']),
absolute_file_name(File,AbsFile,[relative_to(Dir)]),
exists_file(AbsFile),
- succeeds(provx_load(AbsFile,J),PassOrFail),
+ succeeds(provx_load_instance(AbsFile,J),PassOrFail),
write(PassOrFail),write('\t'),write(File),nl,nl.
test_all:-
@@ -34,7 +34,7 @@
test3(File,J,K) :- Dir='constraint_test_provx',
absolute_file_name(File,AbsFile,[relative_to(Dir)]),
- succeeds(provx_load(AbsFile,J),_),
+ succeeds(provx_load_instance(AbsFile,J),_),
normalize(J,K).
succeeds(Goal,pass):-