File: 2018-12-06T21%3A31%3A23%2B01%3A00~451879d.patch

package info (click to toggle)
rdf2rml 0~20250711%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,988 kB
  • sloc: perl: 1,212; sql: 430; makefile: 174; sh: 56; ansic: 21
file content (52 lines) | stat: -rw-r--r-- 2,140 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
commit 451879dddff64a3d0f5884886025c50519da1527
Author: Jonas Smedegaard <dr@jones.dk>
Date:   Thu Dec 6 21:31:23 2018 +0100

    Fix create deterministic output.

--- a/bin/rdfpuml.pl
+++ b/bin/rdfpuml.pl
@@ -180,7 +180,10 @@
 replace_inlines();
 collect_predicate_arrows();
 
-for my $s ($model->subjects(undef,undef)) {
+for my $s (
+  sort { RDF::Trine::Node::compare( $a, $b ) }
+  $model->subjects(undef,undef)
+) {
   my $s1 = puml_node($s);
   my $noReify = print_types ($s, $s1); # types come first
   print_relations ($s, $s1, $noReify);
@@ -210,7 +213,9 @@
 sub print_types {
   my ($s, $s1) = @_;
   # Collect types that should be inlined (others handled in print_relations).
-  my @types = grep is_inline_type($_), $model->objects ($s, U("rdf:type"), undef, type=>'resource');
+  my @types = grep is_inline_type($_),
+    sort { RDF::Trine::Node::compare( $a, $b ) }
+    $model->objects ($s, U("rdf:type"), undef, type=>'resource');
   @types = map puml_qname($_), @types;
 
   # puml:NoReify is a marker class that shows the resource should not be reified. Omit from class list, return as boolean result
@@ -222,12 +227,17 @@
 
 sub print_relations {
   my ($s, $s1, $noReify) = @_;
-  for my $o ($model->objects ($s, undef, undef, type=>'resource'),
-             $model->objects ($s, undef, undef, type=>'blank')) {
+  for my $o (
+    sort { RDF::Trine::Node::compare( $a, $b ) }
+    $model->objects ($s, undef, undef, type=>'resource'),
+    $model->objects ($s, undef, undef, type=>'blank')
+  ) {
     # Collect relations between the nodes $s and $o.
     # If rdf:type, allow only $o that shouldn't be inlined (see print_types)
     my @predicates = grep !m{rdf:type} || !is_inline_type($o),
-      map puml_predicate($_), $model->predicates ($s, $o);
+      map puml_predicate($_),
+      sort { RDF::Trine::Node::compare( $a, $b ) }
+      $model->predicates ($s, $o);
     # TODO: also collect inverse relations? Then be careful for reifications!
     # TODO: remove actually reified predicates (see reification()), not potentially reifiable ($NOREL)
     @predicates = grep !m{$NOREL}o, @predicates if !$noReify;