Skip to content

Repository files navigation

Sonarcloud StatusRenovate enabledMaven Central

KSeF FA Java model

Model parser and validator for XML FA(2) KSeF structure.

Sample

Parse and validate FA(2) to Java model

FakturaSerializerserializer = newFakturaSerializer();
Fakturainvoice = serializer.fromFile(newFile("src/test/resources/fa.xml"), true);

Serialize model to XML (without validation)

FakturaSerializerfakturaSerializer = newFakturaSerializer();
Fakturainvoice = fakturaSerializer.create();
Faktura.Podmiot1podmiot1 = newFaktura.Podmiot1();
TAdresaddress = newTAdres();
address.setAdresL1("ul. Kolejowa 123");
address.setAdresL2("05-092 Łomianki");
podmiot1.setAdres(address);
invoice.setPodmiot1(podmiot1);
valstr = fakturaSerializer.toString(invoice, false);
System.out.println(str);

Validate

valerrors = newLinkedList<SAXParseException>();
valfeatures = Set.of(newXMLValidator.SchemaFactoryFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false));
// We need disable secure processing because the schema has restrictions to more than 1000 elements in a sequence// which is completely ridiculous, but what we can do...URLurl = newURL("http://crd.gov.pl/wzor/2023/06/29/12648/schemat.xsd");
valschema = newStreamSource(url.openStream());
valresult = XMLValidator.validate(newFileReader("src/test/resources/fa.xml"), schema, errors, features);

How to use with maven

Stable project attracts are available in Maven Central, just add dependency to your project:

<dependency>
<groupId>io.alapierre.ksef.fa</groupId>
<artifactId>ksef-fa-xml-model</artifactId>
<version>3.0.0</version>
</dependency>

Another connected GitGub Repositories

Build Requirements

The project can be built on JDK17+.

Building the API client library requires:

  1. Java 17+
  2. Maven

About

Model parser and validator for XML FA(3) and FA(2) KSeF structure

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages