Skip to content

Commit

Permalink
Fix #347
Browse files Browse the repository at this point in the history
  • Loading branch information
filip26 committed Jul 15, 2024
1 parent c3b8c9d commit 8868747
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,23 @@ public void expand() throws JsonLdError {
activeContext.runtime().tick();

// 13.2.
String expandedProperty = activeContext
final String expandedProperty = activeContext
.uriExpansion()
.documentRelative(false)
.vocab(true)
.expand(key);

// 13.3.
// if the term is undefined and
if (expandedProperty == null || (!expandedProperty.contains(":") && !Keywords.contains(expandedProperty))) {
continue;
switch (activeContext.runtime().getUndefinedTermPolicy()) {
case Fail:
throw new JsonLdError(JsonLdErrorCode.UNDEFINED_TERM,
"An undefined term has been found [" + key + "]. Change policy to Ignore or Warn or define the term in a context");
case Warn:
LOGGER.log(Level.WARNING, "An undefined term has been found [{0}]", key);
case Ignore:
continue;
}
}

JsonValue value = element.get(key);
Expand All @@ -163,7 +171,6 @@ public void expand() throws JsonLdError {
// 13.4.2
if (result.containsKey(expandedProperty)
&& Keywords.noneMatch(expandedProperty, Keywords.INCLUDED, Keywords.TYPE)) {

throw new JsonLdError(JsonLdErrorCode.COLLIDING_KEYWORDS,
"Two properties which expand to the same keyword have been detected. A property '" + key + "'"
+ " expands to '" + expandedProperty + "'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.apicatalog.jsonld.JsonLdError;
import com.apicatalog.jsonld.JsonLdOptions;
import com.apicatalog.jsonld.JsonLdOptions.ProcessingPolicy;
import com.apicatalog.jsonld.JsonLdVersion;
import com.apicatalog.jsonld.context.cache.Cache;
import com.apicatalog.jsonld.document.Document;
Expand Down Expand Up @@ -79,4 +80,8 @@ public boolean isRdfStar() {
public boolean isNumericId() {
return options.isNumericId();
}

public ProcessingPolicy getUndefinedTermPolicy() {
return options.getUndefinedTermsPolicy();
}
}
4 changes: 2 additions & 2 deletions src/test/resources/com/apicatalog/jsonld/test/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
"expect": "undefined-term-2-out.json",
"option": {
"expandContext": "undefined-term-context.json",
"undefintedTermPolicy": "Ignore"
"undefinedTermPolicy": "Warn"
}
},
{
Expand All @@ -276,7 +276,7 @@
"expect": "undefined-term-3-out.json",
"option": {
"expandContext": "undefined-term-context.json",
"undefintedTermPolicy": "Fail"
"undefinedTermPolicy": "Fail"
}
}
]
Expand Down

0 comments on commit 8868747

Please sign in to comment.