use of org.apache.jena.shacl.validation.ReportItem in project jena by apache.
the class ShNode method validate.
@Override
public ReportItem validate(ValidationContext vCxt, Graph data, Node node) {
ValidationContext vCxt2 = ValidationContext.create(vCxt);
ValidationProc.execValidateShape(vCxt2, data, other, node);
boolean innerConforms = vCxt2.generateReport().conforms();
if (innerConforms)
return null;
String msg = toString() + " at focusNode " + displayStr(node);
return new ReportItem(msg, node);
}
use of org.apache.jena.shacl.validation.ReportItem in project jena by apache.
the class ShOr method validate.
@Override
public ReportItem validate(ValidationContext vCxt, Graph data, Node node) {
for (Shape sh : others) {
ValidationContext vCxt2 = ValidationContext.create(vCxt);
ValidationProc.execValidateShape(vCxt2, data, sh, node);
boolean innerConforms = vCxt2.generateReport().conforms();
if (innerConforms)
return null;
}
String msg = toString() + " at focusNode " + displayStr(node);
return new ReportItem(msg, node);
}
use of org.apache.jena.shacl.validation.ReportItem in project jena by apache.
the class StrLanguageIn method validate.
@Override
public ReportItem validate(ValidationContext vCxt, Node n) {
if (!n.isLiteral())
return new ReportItem(toString() + ": Not a literal", n);
String langTag = n.getLiteralLanguage();
if (langTag == null || langTag.isEmpty()) {
if (vCxt.isStrict()) {
if (Util.isSimpleString(n))
return new ReportItem(toString() + ": xsd:string (no language tag)", n);
else
return new ReportItem(toString() + ": No language tag", n);
}
if (!Util.isSimpleString(n))
return new ReportItem(toString() + ": Not an rdf:langString or xsd:string", n);
// Allow "" to mean xsd:string "none".
if (langs.contains(langTag))
return null;
return new ReportItem(toString() + ": No matching language tag", n);
}
for (String langPattern : langs) {
boolean b = NodeFunctions.langMatches(langTag, langPattern);
if (b)
return null;
}
String msg = toString() + ": No matching language tag " + langTag;
return new ReportItem(msg, n);
}
use of org.apache.jena.shacl.validation.ReportItem in project jena by apache.
the class ValueRangeConstraint method validate.
@Override
public final ReportItem validate(ValidationContext vCxt, Node n) {
NodeValue nv = NodeValue.makeNode(n);
ValueSpaceClassification vs = NodeValue.classifyValueOp(nodeValue, nv);
try {
int r = NodeValue.compare(nodeValue, nv);
if (r == Expr.CMP_INDETERMINATE)
return new ReportItem(toString() + " indeterminant to " + n, n);
boolean b = test(r);
if (b)
return null;
return new ReportItem(getErrorMessage(n), n);
} catch (ExprNotComparableException ex) {
return new ReportItem(toString() + " can't compare to " + n, n);
}
}
use of org.apache.jena.shacl.validation.ReportItem in project jena by apache.
the class DatatypeConstraint method validate.
@Override
public ReportItem validate(ValidationContext vCxt, Node n) {
if (n.isLiteral() && dtURI.equals(n.getLiteralDatatypeURI())) {
// Must be valid for the type
if (!rdfDatatype.isValid(n.getLiteralLexicalForm())) {
String errMsg = toString() + " : Not valid value : Node " + displayStr(n);
return new ReportItem(errMsg, n);
}
return null;
}
if (!n.isLiteral())
return new ReportItem(toString() + " : Not a literal", n);
String dtStr = vCxt.getShapesGraph().getPrefixMapping().qnameFor(dtURI);
if (dtStr == null) {
Node dt = NodeFactory.createURI(n.getLiteralDatatypeURI());
dtStr = ShLib.displayStr(dt);
}
String errMsg = toString() + " : Got datatype " + dtStr + " : Node " + displayStr(n);
return new ReportItem(errMsg, n);
}
Aggregations