Search in sources :

Example 1 with ValidationExecutorXSD

use of com.helger.phive.engine.xsd.ValidationExecutorXSD in project phive by phax.

the class VOM1Converter method _createExecutorXSD.

@Nonnull
private ValidationExecutorXSD _createExecutorXSD(@Nonnull final VOMXSDType aXsd) {
    final ValidationExecutorXSD ret;
    final String sBuiltIn = aXsd.getBuiltIn();
    if (StringHelper.hasText(sBuiltIn)) {
        LOGGER.info("Trying to resolve built-in XSD artifact '" + sBuiltIn + "'");
        final Schema aSchema = m_aXmlSchemaResolver.getXmlSchemaOfID(sBuiltIn);
        if (aSchema == null)
            throw new IllegalStateException("Failed to resolve built-in XSD artifact '" + sBuiltIn + "'");
        ret = new ValidationExecutorXSD(new ValidationArtefact(EValidationType.XSD, new ReadableResourceByteArray("built-in-" + sBuiltIn, ArrayHelper.EMPTY_BYTE_ARRAY)), () -> aSchema);
    } else {
        // External resource
        final VESID aVESID = _createVESID(aXsd.getResource());
        LOGGER.info("Trying to resolve XSD artifact with ID '" + aVESID.getAsSingleID() + "'");
        final IReadableResource aRes = m_aArtifactResolver.getArtifactOfID(aVESID);
        if (aRes == null)
            throw new IllegalStateException("Failed to resolve XSD artifact with ID '" + aVESID.getAsSingleID() + "'");
        ret = ValidationExecutorXSD.create(aRes);
    }
    if (aXsd.hasOptionEntries())
        LOGGER.warn("Ignoring all XSD options");
    return ret;
}
Also used : VESID(com.helger.phive.api.executorset.VESID) Schema(javax.xml.validation.Schema) ValidationArtefact(com.helger.phive.api.artefact.ValidationArtefact) IReadableResource(com.helger.commons.io.resource.IReadableResource) ValidationExecutorXSD(com.helger.phive.engine.xsd.ValidationExecutorXSD) ReadableResourceByteArray(com.helger.commons.io.resource.inmemory.ReadableResourceByteArray) Nonnull(javax.annotation.Nonnull)

Aggregations

IReadableResource (com.helger.commons.io.resource.IReadableResource)1 ReadableResourceByteArray (com.helger.commons.io.resource.inmemory.ReadableResourceByteArray)1 ValidationArtefact (com.helger.phive.api.artefact.ValidationArtefact)1 VESID (com.helger.phive.api.executorset.VESID)1 ValidationExecutorXSD (com.helger.phive.engine.xsd.ValidationExecutorXSD)1 Nonnull (javax.annotation.Nonnull)1 Schema (javax.xml.validation.Schema)1