Search in sources :

Example 1 with PSDiagnostic

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;
}
Also used : PSDiagnostic(com.helger.schematron.pure.model.PSDiagnostic) PSDiagnostics(com.helger.schematron.pure.model.PSDiagnostics) Nonnull(javax.annotation.Nonnull)

Example 2 with PSDiagnostic

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;
}
Also used : PSDiagnostic(com.helger.schematron.pure.model.PSDiagnostic) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) PSSchema(com.helger.schematron.pure.model.PSSchema) Nullable(javax.annotation.Nullable)

Aggregations

PSDiagnostic (com.helger.schematron.pure.model.PSDiagnostic)2 CommonsHashMap (com.helger.commons.collection.impl.CommonsHashMap)1 PSDiagnostics (com.helger.schematron.pure.model.PSDiagnostics)1 PSSchema (com.helger.schematron.pure.model.PSSchema)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1