Skip to content

fix (core): Compare objects as well in RdfCanonicalizer #1104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/use/canonicalize/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $ ./enola canonicalize --load=test/picasso.ttl
...
```

Future versions may implement full [RDF Dataset Canonicalization](https://www.w3.org/TR/rdf-canon/), see also [this Working Group](https://www.w3.org/2024/12/rch-wg-charter.html).
Future versions [may](https://github.com/enola-dev/enola/issues/1103) implement full [RDF Dataset Canonicalization](https://www.w3.org/TR/rdf-canon/), see also [this Working Group](https://www.w3.org/2024/12/rch-wg-charter.html).

## JSON

Expand Down
5 changes: 5 additions & 0 deletions java/dev/enola/rdf/io/RdfCanonicalizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@

import java.util.Comparator;

// TODO https://github.com/enola-dev/enola/issues/1103: Replace this with "real" (full) RDF-Canon.
public class RdfCanonicalizer {

// NB: This *DOES* also sort any internal blank statements!
// (Because it operates on ["flat"] RDF4j Statement - NOT the ["nested"] Thing API.)

private static final Model EMPTY_MODEL = new DynamicModel(new LinkedHashModelFactory());

private static final Comparator<? super Statement> COMPARATOR =
Expand All @@ -43,6 +47,7 @@ public int compare(Statement o1, Statement o2) {
.compare(
o1.getPredicate().stringValue(),
o2.getPredicate().stringValue())
.compare(o1.getObject().stringValue(), o2.getObject().stringValue())
.result();
}
};
Expand Down