private String resolveMapping(String curie, int delimPos, boolean safeSyntax) throws MalformedCurieException {
String localName = curie.substring(delimPos + 1);
String prefix = curie.substring(0, delimPos);
if (prefix.equals("_")) {
throw new MalformedCurieException("CURIE with invalid prefix (" + curie + ") found");
}
if (!iriMappings.containsKey(prefix)) {
if (documentContext.rdfaVersion > RDFa.VERSION_10 && RDFA11_INITIAL_CONTEXT.containsKey(prefix)) {
String nsUri = RDFA11_INITIAL_CONTEXT.get(prefix);
iriMappings.put(prefix, nsUri);
String result = nsUri + localName;
if (RIUtils.isIri(result)) {
return result;
}
throw new MalformedCurieException("Malformed CURIE (" + curie + ")");
}
if (!safeSyntax && RIUtils.isIri(curie)) {
return curie;
}
throw new MalformedCurieException("CURIE with unresolvable prefix found (" + curie + ")");
}
return iriMappings.get(prefix) + localName;
}