use of com.helger.phive.engine.vom.v10.VOMEdifactType 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;
}
use of com.helger.phive.engine.vom.v10.VOMEdifactType in project phive by phax.
the class VOM1Converter method _createExecutorEdifact.
@Nonnull
private IValidationExecutor<IValidationSourceXML> _createExecutorEdifact(@Nonnull final VOMEdifactType aEdifact) {
final IEdifactValidationExecutorProviderXML aProvider = m_aComplianceSettings.getEdifactValidationExecutorProviderXML();
final StringMap aOptions = new StringMap();
for (final VOMOptionType aOption : aEdifact.getOption()) aOptions.put(aOption.getName(), aOption.getValue());
LOGGER.info("Trying to resolve Edifact artifact '" + aEdifact.getDirectory() + '/' + aEdifact.getMessage() + "'");
final IValidationExecutor<IValidationSourceXML> aVES = aProvider.createValidationExecutor(aEdifact.getDirectory(), aEdifact.getMessage(), aOptions);
if (aVES == null)
throw new IllegalStateException("Failed to resolve Edifact artifact '" + aEdifact.getDirectory() + '/' + aEdifact.getMessage() + "'");
return aVES;
}
use of com.helger.phive.engine.vom.v10.VOMEdifactType 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;
}
}
}
}
Aggregations