Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schematron assert ID in AbstractSVRLMessage #103

Closed
mangeg opened this issue Apr 27, 2020 · 4 comments
Closed

Schematron assert ID in AbstractSVRLMessage #103

mangeg opened this issue Apr 27, 2020 · 4 comments
Assignees

Comments

@mangeg
Copy link

mangeg commented Apr 27, 2020

Would it be possible to add the assert id from schematron/XSLT files in the AbstractSVRLMessage (SVRLFailedAssert, SVRLSuccessfulReport)?

The ID I have in mind is "PEPPOL-EN16931-R041" from the sample below.
When using ph-bdve-peppol to validate files, the returned ValidationResults and the containing errors getErrorID() returns null.
I am not sure if the intent of the errorId is to contains this type of information. But I did a test in a fork where I added fetching of error ID from FailedAssert in SVRLFailedAssert and SVRLSuccessfulReport via AbstractSVRLMessage, mangeg@f5d4fb6. With these changes I am able to get the assert id from IError.getErrorID().

The use for this would be to be able to programmatically act on results without depending on the readable validation message, ie. (Allowance/charge base amount MUST be provided when Allowance/charge percentage is provided.) in the sample.

From PEPPOL-EN16931-UBL.sch

SCH:

<rule context="ubl-invoice:Invoice/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-invoice:Invoice/cac:InvoiceLine/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-creditnote:CreditNote/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-creditnote:CreditNote/cac:CreditNoteLine/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)]">
    <assert id="PEPPOL-EN16931-R041" test="false()" flag="fatal">Allowance/charge base amount MUST
        be provided when allowance/charge percentage is provided.</assert>
</rule>

XSLT:

<svrl:failed-assert xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="false()">
    <xsl:attribute name="id">PEPPOL-EN16931-R041</xsl:attribute>
    <xsl:attribute name="flag">fatal</xsl:attribute>
    <xsl:attribute name="location">
        <xsl:apply-templates select="." mode="schematron-select-full-path" />
    </xsl:attribute>
    <svrl:text>Allowance/charge base amount MUST be provided when allowance/charge percentage is provided.</svrl:text>
</svrl:failed-assert>
@phax phax self-assigned this Apr 28, 2020
@phax
Copy link
Owner

phax commented Apr 28, 2020

Hi, Can you please check if a preceeding element fired-rule contains the respective test ID? Than I might take it from there...

@mangeg
Copy link
Author

mangeg commented Apr 28, 2020

No, the fired-rule elements only have template and context + the generated mode and priority attributes.

Should it have been generated on the svrl:fired-rule as well?

The full section from XSLT

<!--RULE -->
<xsl:template match="ubl-invoice:Invoice/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-invoice:Invoice/cac:InvoiceLine/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-creditnote:CreditNote/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-creditnote:CreditNote/cac:CreditNoteLine/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)]" mode="M12" priority="1010">
    <svrl:fired-rule context="ubl-invoice:Invoice/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-invoice:Invoice/cac:InvoiceLine/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-creditnote:CreditNote/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-creditnote:CreditNote/cac:CreditNoteLine/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)]" />

    <!--ASSERT -->
    <xsl:choose>
        <xsl:when test="false()" />
        <xsl:otherwise>
            <svrl:failed-assert test="false()">
                <xsl:attribute name="id">PEPPOL-EN16931-R041</xsl:attribute>
                <xsl:attribute name="flag">fatal</xsl:attribute>
                <xsl:attribute name="location">
                    <xsl:apply-templates mode="schematron-select-full-path" select="." />
                </xsl:attribute>
                <svrl:text>Allowance/charge base amount MUST
be provided when allowance/charge percentage is provided.</svrl:text>
            </svrl:failed-assert>
        </xsl:otherwise>
    </xsl:choose>
    <xsl:apply-templates mode="M12" select="*" />
</xsl:template>

from Schematron

<!-- Allowance/Charge (document level/line level) -->
<rule context="ubl-invoice:Invoice/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-invoice:Invoice/cac:InvoiceLine/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-creditnote:CreditNote/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)] | ubl-creditnote:CreditNote/cac:CreditNoteLine/cac:AllowanceCharge[cbc:MultiplierFactorNumeric and not(cbc:BaseAmount)]">
    <assert id="PEPPOL-EN16931-R041" test="false()" flag="fatal">Allowance/charge base amount MUST
  be provided when allowance/charge percentage is provided.</assert>
</rule>

@stale
Copy link

stale bot commented Jul 27, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 27, 2020
@phax phax added pinned and removed wontfix labels Jul 27, 2020
@phax
Copy link
Owner

phax commented Dec 4, 2020

Finally - that was done in ph-schematron 6.0.1

@phax phax closed this as completed Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants