Summary
Implement XML structure validation for PEPPOL BIS Billing 3.0, particularly empty element checks.
Background
Some PEPPOL rules require validating the XML structure itself, not just the parsed Invoice struct. The most notable example is PEPPOL-EN16931-R008: "Document MUST not contain empty elements" (including whitespace-only content).
Current implementation in PR #32 only validates business logic on the Invoice struct, which happens after XML parsing. Structure-level validation requires checking the raw XML.
Requirements
PEPPOL-EN16931-R008
Documents must not contain empty XML elements, including:
- Completely empty:
<Element/>
- Whitespace-only:
<Element> </Element>
- Newline-only:
<Element>\n</Element>
This rule ensures clean, well-formed invoices without unnecessary empty tags.
Other Potential Structure Rules
May need to validate:
- Element ordering
- Namespace usage
- Attribute presence/format
- Comment restrictions
Implementation Options
Option 1: Parse-time validation
Add validation during XML parsing in parser.go:
- Use
encoding/xml Decoder events
- Check for empty elements before populating Invoice struct
- Report violations immediately
Option 2: Post-parse XML validation
After successful parsing:
- Re-read the XML file
- Use XPath or DOM traversal
- Check structure rules
- Combine with business rule violations
Option 3: Separate validation pass
Create dedicated XML validator:
- Runs before or after parsing
- Uses XML schema/schematron-style checks
- Independent of Invoice struct validation
Considerations
- Performance: Structure validation adds overhead
- Error reporting: Need clear messages with XML location
- Backward compatibility: Should not break existing EN 16931 validation
- Profile-specific: Only apply for PEPPOL profile validation
Acceptance Criteria
References
Related
Part of #24 (PEPPOL BIS Billing 3.0 support)
Depends on #32
Summary
Implement XML structure validation for PEPPOL BIS Billing 3.0, particularly empty element checks.
Background
Some PEPPOL rules require validating the XML structure itself, not just the parsed Invoice struct. The most notable example is PEPPOL-EN16931-R008: "Document MUST not contain empty elements" (including whitespace-only content).
Current implementation in PR #32 only validates business logic on the Invoice struct, which happens after XML parsing. Structure-level validation requires checking the raw XML.
Requirements
PEPPOL-EN16931-R008
Documents must not contain empty XML elements, including:
<Element/><Element> </Element><Element>\n</Element>This rule ensures clean, well-formed invoices without unnecessary empty tags.
Other Potential Structure Rules
May need to validate:
Implementation Options
Option 1: Parse-time validation
Add validation during XML parsing in
parser.go:encoding/xmlDecoder eventsOption 2: Post-parse XML validation
After successful parsing:
Option 3: Separate validation pass
Create dedicated XML validator:
Considerations
Acceptance Criteria
ValidatePEPPOL()or--profile peppolReferences
Related
Part of #24 (PEPPOL BIS Billing 3.0 support)
Depends on #32