use of com.helger.schematron.pure.model.PSDiagnostic in project ph-schematron by phax.
the class PSPreprocessor method _getPreprocessedDiagnostics.
@Nonnull
private static PSDiagnostics _getPreprocessedDiagnostics(@Nonnull final PSDiagnostics aDiagnostics) throws SchematronPreprocessException {
final PSDiagnostics ret = new PSDiagnostics();
if (aDiagnostics.hasAnyInclude())
throw new SchematronPreprocessException("Cannot preprocess <diagnostics> with an <include>");
for (final PSDiagnostic aDiagnostic : aDiagnostics.getAllDiagnostics()) ret.addDiagnostic(aDiagnostic.getClone());
ret.addForeignElements(aDiagnostics.getAllForeignElements());
ret.addForeignAttributes(aDiagnostics.getAllForeignAttributes());
return ret;
}
use of com.helger.schematron.pure.model.PSDiagnostic in project ph-schematron by phax.
the class PSXPathBoundSchema method _createBoundDiagnostics.
@Nullable
private ICommonsMap<String, PSXPathBoundDiagnostic> _createBoundDiagnostics(@Nonnull final XPath aXPathContext, @Nonnull final IPSXPathVariables aGlobalVariables) {
final ICommonsMap<String, PSXPathBoundDiagnostic> ret = new CommonsHashMap<>();
boolean bHasAnyError = false;
final PSSchema aSchema = getOriginalSchema();
if (aSchema.hasDiagnostics()) {
// For all contained diagnostic elements
for (final PSDiagnostic aDiagnostic : aSchema.getDiagnostics().getAllDiagnostics()) {
final ICommonsList<PSXPathBoundElement> aBoundElements = _createBoundElements(aDiagnostic, aXPathContext, aGlobalVariables);
if (aBoundElements == null) {
// error already emitted
bHasAnyError = true;
} else {
final PSXPathBoundDiagnostic aBoundDiagnostic = new PSXPathBoundDiagnostic(aDiagnostic, aBoundElements);
if (ret.put(aDiagnostic.getID(), aBoundDiagnostic) != null) {
error(aDiagnostic, "A diagnostic element with ID '" + aDiagnostic.getID() + "' was overwritten!");
bHasAnyError = true;
}
}
}
}
if (bHasAnyError)
return null;
return ret;
}
Aggregations