Search in sources :

Example 1 with PSRichGroup

use of com.helger.schematron.pure.model.PSRichGroup in project ph-schematron by phax.

the class PSXPathValidationHandlerSVRL method onFiredRule.

@Override
public void onFiredRule(@Nonnull final PSRule aRule, @Nonnull final String sContext, @Nonnull final int nNodeIndex, @Nonnull final int nNodeCount) {
    final FiredRule aRetRule = new FiredRule();
    aRetRule.setContext(sContext);
    aRetRule.setFlag(aRule.getFlag());
    aRetRule.setId(aRule.getID());
    if (aRule.hasLinkable())
        aRetRule.setRole(aRule.getLinkable().getRole());
    final PSRichGroup aRich = aRule.getRich();
    if (aRich != null) {
        aRetRule.setLang(aRich.getXmlLang());
        if (aRich.hasXmlSpace())
            aRetRule.setSpace(aRich.getXmlSpace().getID());
        aRetRule.setIcon(aRich.getIcon());
        aRetRule.setSee(aRich.getSee());
        aRetRule.setFpi(aRich.getFPI());
    }
    m_aSchematronOutput.getActivePatternAndFiredRuleAndFailedAssert().add(aRetRule);
}
Also used : FiredRule(com.helger.schematron.svrl.jaxb.FiredRule) PSRichGroup(com.helger.schematron.pure.model.PSRichGroup)

Example 2 with PSRichGroup

use of com.helger.schematron.pure.model.PSRichGroup in project ph-schematron by phax.

the class PSXPathValidationHandlerSVRL method _handleDiagnosticReferences.

/**
 * Handle the diagnostic references of a single assert/report element
 *
 * @param aSrcDiagnostics
 *        The list of diagnostic reference IDs in the source assert/report
 *        element. May be <code>null</code> if no diagnostic references are
 *        present
 * @param aDstList
 *        The diagnostic reference list of the SchematronOutput to be filled.
 *        May not be <code>null</code>.
 * @param aBoundAssertReport
 *        The bound assert report element. Never <code>null</code>.
 * @param aRuleMatchingNode
 *        The XML node of the XML document currently validated. Never
 *        <code>null</code>.
 * @throws SchematronValidationException
 */
private void _handleDiagnosticReferences(@Nullable final List<String> aSrcDiagnostics, @Nonnull final List<? super DiagnosticReference> aDstList, @Nonnull final PSXPathBoundAssertReport aBoundAssertReport, @Nonnull final Node aRuleMatchingNode) throws SchematronValidationException {
    if (CollectionHelper.isNotEmpty(aSrcDiagnostics)) {
        if (m_aSchema.hasDiagnostics()) {
            final PSDiagnostics aDiagnostics = m_aSchema.getDiagnostics();
            for (final String sDiagnosticID : aSrcDiagnostics) {
                final PSXPathBoundDiagnostic aDiagnostic = aBoundAssertReport.getBoundDiagnosticOfID(sDiagnosticID);
                if (aDiagnostic == null)
                    _warn(aDiagnostics, "Failed to resolve diagnostics with ID '" + sDiagnosticID + "'");
                else {
                    // Create the SVRL diagnostic-reference element
                    final DiagnosticReference aDR = new DiagnosticReference();
                    aDR.setDiagnostic(sDiagnosticID);
                    final PSRichGroup aRich = aDiagnostic.getDiagnostic().getRich();
                    if (aRich != null) {
                        aDR.setLang(aRich.getXmlLang());
                        if (aRich.hasXmlSpace())
                            aDR.setSpace(aRich.getXmlSpace().getID());
                        aDR.setIcon(aRich.getIcon());
                        aDR.setSee(aRich.getSee());
                        aDR.setFpi(aRich.getFPI());
                    }
                    aDR.getContent().add(_getErrorText(aDiagnostic.getAllBoundContentElements(), aRuleMatchingNode));
                    aDstList.add(aDR);
                }
            }
        } else
            _warn(m_aSchema, "Failed to resolve diagnostic because schema has no diagnostics");
    }
}
Also used : PSXPathBoundDiagnostic(com.helger.schematron.pure.bound.xpath.PSXPathBoundDiagnostic) DiagnosticReference(com.helger.schematron.svrl.jaxb.DiagnosticReference) PSDiagnostics(com.helger.schematron.pure.model.PSDiagnostics) PSRichGroup(com.helger.schematron.pure.model.PSRichGroup)

Aggregations

PSRichGroup (com.helger.schematron.pure.model.PSRichGroup)2 PSXPathBoundDiagnostic (com.helger.schematron.pure.bound.xpath.PSXPathBoundDiagnostic)1 PSDiagnostics (com.helger.schematron.pure.model.PSDiagnostics)1 DiagnosticReference (com.helger.schematron.svrl.jaxb.DiagnosticReference)1 FiredRule (com.helger.schematron.svrl.jaxb.FiredRule)1