ZUGFeRD / mustangproject

Open Source Java e-Invoicing library, validator and tool (Factur-X/ZUGFeRD, UNCEFACT/CII XRechnung)
http://www.mustangproject.org
Apache License 2.0
168 stars 99 forks source link

Empty Element in Document #364

Open RichardCox09 opened 3 months ago

RichardCox09 commented 3 months ago

Hi,

In Mustang Version 2.10.0 we noticed a problem regarding empty elements in the document.

Example:

final TradeParty tradeParty = new TradeParty();
tradeParty.setAdditionalAddress(null);

Results in the following Output: image

Which results in the following validaiton error: <error type="27" location="/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction[1]/ram:ApplicableHeaderTradeAgreement[1]/ram:BuyerTradeParty[1]/ram:PostalTradeAddress[1]/ram:LineTwo[1]" criterion="false()">Document MUST not contain empty elements. [ID PEPPOL-EN16931-R008] from /xslt/XR_30/XRechnung-CII-validation.xslt)</error>

Should this not be ignored in case of null or an empty (trimmed) string? I fixed it by testing the string before calling the method, but it might be more comfortable if the library does it internally?

Thanks for the help.

jstaerk commented 3 months ago

This "requirement" is relatively new (XRechnung 3), and strange, if you ask me, but please feel invited to submit a PR to only write non-empty elements