Search in sources :

Example 1 with VOMXSDType

use of com.helger.phive.engine.vom.v10.VOMXSDType in project phive by phax.

the class VOM1Converter method convertToVES_XML.

@Nullable
public ValidationExecutorSet<IValidationSourceXML> convertToVES_XML(@Nonnull final VOMType aVOM, @Nonnull final ErrorList aErrorList) {
    ValueEnforcer.notNull(aVOM, "VOM");
    ValueEnforcer.notNull(aErrorList, "ErrorList");
    if (m_bPerformValidation) {
        VOM1Validator.validate(aVOM, m_aXmlSchemaResolver, m_aNamespaceContextResolver, m_aResourceResolver, m_aComplianceSettings, aErrorList);
        if (aErrorList.containsAtLeastOneError())
            return null;
    }
    // Create stub
    final ValidationExecutorSet<IValidationSourceXML> ret = new ValidationExecutorSet<>(_createVESID(aVOM.getId()), aVOM.getName(), false);
    if (m_aComplianceSettings.isAllowEdifact() && aVOM.getValidation().hasEdifactEntries()) {
        if (aVOM.getValidation().hasXsdEntries())
            throw new IllegalStateException("If Edifact is enabled and present, than no XSD can be present!");
        // Add all Edifacts
        for (final VOMEdifactType aEdifact : aVOM.getValidation().getEdifact()) ret.addExecutor(_createExecutorEdifact(aEdifact));
    } else {
        // Add all XSDs
        for (final VOMXSDType aXsd : aVOM.getValidation().getXsd()) ret.addExecutor(_createExecutorXSD(aXsd));
    }
    // Add all XSDs
    for (final VOMSchematronType aSchematron : aVOM.getValidation().getSchematron()) ret.addExecutor(_createExecutorSchematron(aSchematron));
    return ret;
}
Also used : ValidationExecutorSet(com.helger.phive.api.executorset.ValidationExecutorSet) VOMSchematronType(com.helger.phive.engine.vom.v10.VOMSchematronType) VOMEdifactType(com.helger.phive.engine.vom.v10.VOMEdifactType) IValidationSourceXML(com.helger.phive.engine.source.IValidationSourceXML) VOMXSDType(com.helger.phive.engine.vom.v10.VOMXSDType) Nullable(javax.annotation.Nullable)

Example 2 with VOMXSDType

use of com.helger.phive.engine.vom.v10.VOMXSDType in project phive by phax.

the class VOM1Validator method validateValidation.

public static void validateValidation(@Nonnull final String sXPath, @Nullable final VOMValidationType aValidation, @Nonnull final IVOMXmlSchemaResolver aXmlSchemaResolver, @Nonnull final IVOMNamespaceContextResolver aNamespaceContextResolver, @Nonnull final IVOMResourceResolver aResourceResolver, @Nonnull final VOM1ComplianceSettings aSettings, @Nonnull final ErrorList aErrorList) {
    if (aValidation == null) {
        aErrorList.add(_createError(EVOMErrorCode.REQUIRED, sXPath));
    } else {
        // validation element is present
        if (aValidation.getXsdCount() + aValidation.getEdifactCount() + aValidation.getSchematronCount() == 0)
            aErrorList.add(_createError(EVOMErrorCode.NO_VALIDATION_RULES, sXPath));
        else {
            // XSD
            // XML uses 1-based indices
            int nIndex = 1;
            for (final VOMXSDType aXSD : aValidation.getXsd()) {
                validateXSD(sXPath + "/xsd[" + nIndex + "]", aXSD, aXmlSchemaResolver, aErrorList);
                ++nIndex;
            }
            // Edifact
            if (aSettings.isAllowEdifact()) {
                nIndex = 1;
                for (final VOMEdifactType aEdifact : aValidation.getEdifact()) {
                    validateEdifact(sXPath + "/edifact[" + nIndex + "]", aEdifact, aErrorList);
                    ++nIndex;
                }
            } else {
                if (!aValidation.getEdifact().isEmpty())
                    aErrorList.add(_createError(EVOMErrorCode.EDIFACT_NOT_ALLOWED, sXPath));
            }
            // Schematron
            nIndex = 1;
            for (final VOMSchematronType aSchematron : aValidation.getSchematron()) {
                validateSchematron(sXPath + "/schematron[" + nIndex + "]", aSchematron, aNamespaceContextResolver, aResourceResolver, aErrorList);
                ++nIndex;
            }
        }
    }
}
Also used : VOMSchematronType(com.helger.phive.engine.vom.v10.VOMSchematronType) VOMEdifactType(com.helger.phive.engine.vom.v10.VOMEdifactType) VOMXSDType(com.helger.phive.engine.vom.v10.VOMXSDType)

Aggregations

VOMEdifactType (com.helger.phive.engine.vom.v10.VOMEdifactType)2 VOMSchematronType (com.helger.phive.engine.vom.v10.VOMSchematronType)2 VOMXSDType (com.helger.phive.engine.vom.v10.VOMXSDType)2 ValidationExecutorSet (com.helger.phive.api.executorset.ValidationExecutorSet)1 IValidationSourceXML (com.helger.phive.engine.source.IValidationSourceXML)1 Nullable (javax.annotation.Nullable)1