Search in sources :

Example 1 with ErrorList

use of com.helger.commons.error.list.ErrorList in project ph-schematron by phax.

the class SchematronHelper method convertToErrorList.

/**
 * Convert a {@link SchematronOutputType} to an {@link IErrorList}.
 *
 * @param aSchematronOutput
 *        The result of Schematron validation
 * @param sResourceName
 *        The name of the resource that was validated (may be a file path
 *        etc.)
 * @return List non-<code>null</code> error list of {@link SVRLResourceError}
 *         objects.
 */
@Nonnull
public static IErrorList convertToErrorList(@Nonnull final SchematronOutputType aSchematronOutput, @Nullable final String sResourceName) {
    ValueEnforcer.notNull(aSchematronOutput, "SchematronOutput");
    final ErrorList ret = new ErrorList();
    for (final SVRLFailedAssert aFailedAssert : SVRLHelper.getAllFailedAssertions(aSchematronOutput)) ret.add(aFailedAssert.getAsResourceError(sResourceName));
    return ret;
}
Also used : ErrorList(com.helger.commons.error.list.ErrorList) IErrorList(com.helger.commons.error.list.IErrorList) SVRLFailedAssert(com.helger.schematron.svrl.SVRLFailedAssert) Nonnull(javax.annotation.Nonnull)

Example 2 with ErrorList

use of com.helger.commons.error.list.ErrorList in project mustangproject by ZUGFeRD.

the class CIIToUBL method convert.

/**
 * converts a CII XML file to a UBL XML file
 * thanks to Philip Helger for his library
 * @param input
 * @param output
 */
public void convert(File input, File output) {
    ErrorList occurred = new ErrorList();
    CIIToUBL22Converter cc = new CIIToUBL22Converter();
    Serializable aUBL = cc.convertCIItoUBL(input, occurred);
    if (aUBL instanceof oasis.names.specification.ubl.schema.xsd.invoice_21.InvoiceType) {
        UBL21Writer.invoice().setFormattedOutput(true).write((oasis.names.specification.ubl.schema.xsd.invoice_21.InvoiceType) aUBL, output);
    } else if (aUBL instanceof oasis.names.specification.ubl.schema.xsd.creditnote_21.CreditNoteType) {
        UBL21Writer.creditNote().setFormattedOutput(true).write((oasis.names.specification.ubl.schema.xsd.creditnote_21.CreditNoteType) aUBL, output);
    } else if (aUBL instanceof oasis.names.specification.ubl.schema.xsd.invoice_22.InvoiceType) {
        UBL22Writer.invoice().setFormattedOutput(true).write((oasis.names.specification.ubl.schema.xsd.invoice_22.InvoiceType) aUBL, output);
    } else if (aUBL instanceof oasis.names.specification.ubl.schema.xsd.creditnote_22.CreditNoteType) {
        UBL22Writer.creditNote().setFormattedOutput(true).write((oasis.names.specification.ubl.schema.xsd.creditnote_22.CreditNoteType) aUBL, output);
    }
}
Also used : Serializable(java.io.Serializable) ErrorList(com.helger.commons.error.list.ErrorList) CIIToUBL22Converter(com.helger.en16931.cii2ubl.CIIToUBL22Converter)

Aggregations

ErrorList (com.helger.commons.error.list.ErrorList)2 IErrorList (com.helger.commons.error.list.IErrorList)1 CIIToUBL22Converter (com.helger.en16931.cii2ubl.CIIToUBL22Converter)1 SVRLFailedAssert (com.helger.schematron.svrl.SVRLFailedAssert)1 Serializable (java.io.Serializable)1 Nonnull (javax.annotation.Nonnull)1