NAME
PDF::FacturX::XML - Build and validate Factur-X CrossIndustryInvoice XML
SYNOPSIS
use PDF::FacturX::XML qw(build_xml validate_xml);
my $xml = build_xml({
number => 'FA-2026-0042',
date => '2026-04-19',
due_date => '2026-05-19',
currency => 'EUR',
seller => { name => 'Acme SARL', ... },
buyer => { name => 'Client SAS', ... },
lines => [ { name => 'Service', qty => 1, unit_price => 1000,
vat_rate => 20, vat_cat => 'S' } ],
}, 'en16931');
my ($ok, $msg) = validate_xml($xml, 'en16931');
die "XML invalide : $msg" unless $ok;
DESCRIPTION
Generates the Cross Industry Invoice XML payload required by the Franco-German Factur-X / ZUGFeRD standard (EN 16931). Four profiles are supported: minimum, basicwl, basic, en16931. Output is a Unicode string (UTF-8 internal), suitable for direct embedding in a PDF/A-3 envelope via PDF::FacturX::Embed.
FUNCTIONS
build_xml($invoice_hashref, $profile)
Returns the XML string. Dies on missing required fields or invalid input.
validate_xml($xml_string, $profile, $xsd_root?)
Validates against the official Factur-X 1.0.8 XSD bundled with this dist. Returns (1, 'OK') or (0, $error_message). $xsd_root is optional; when omitted, the bundled XSD is used.
guideline_id($profile)
Returns the URN identifying the Factur-X guideline for that profile.
xsd_root_for($profile)
Returns the directory containing the XSD files for that profile.
INPUT FORMAT
See the source for a full description of the $invoice_hashref. Required fields: number, date, seller.name, buyer.name. For basic and en16931 profiles, lines is also required (non-empty array).
LICENSE
Same terms as Perl itself (Artistic License 2.0).