XML Builder :: Lib

XML Builder Library

License

License

GroupId

GroupId

io.github.project-openubl
ArtifactId

ArtifactId

xml-builder-lib
Last Version

Last Version

1.0.1.Final
Release Date

Release Date

Type

Type

jar
Description

Description

XML Builder :: Lib
XML Builder Library
Project URL

Project URL

https://project-openubl.github.io/
Source Code Management

Source Code Management

https://github.com/project-openubl/xml-builder-lib

Download xml-builder-lib

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.project-openubl/xml-builder-lib/ -->
<dependency>
    <groupId>io.github.project-openubl</groupId>
    <artifactId>xml-builder-lib</artifactId>
    <version>1.0.1.Final</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.project-openubl/xml-builder-lib/
implementation 'io.github.project-openubl:xml-builder-lib:1.0.1.Final'
// https://jarcasting.com/artifacts/io.github.project-openubl/xml-builder-lib/
implementation ("io.github.project-openubl:xml-builder-lib:1.0.1.Final")
'io.github.project-openubl:xml-builder-lib:jar:1.0.1.Final'
<dependency org="io.github.project-openubl" name="xml-builder-lib" rev="1.0.1.Final">
  <artifact name="xml-builder-lib" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.project-openubl', module='xml-builder-lib', version='1.0.1.Final')
)
libraryDependencies += "io.github.project-openubl" % "xml-builder-lib" % "1.0.1.Final"
[io.github.project-openubl/xml-builder-lib "1.0.1.Final"]

Dependencies

compile (3)

Group / Artifact Type Version
org.freemarker : freemarker jar 2.3.28
org.hibernate : hibernate-validator jar 6.1.4.Final
org.glassfish : jakarta.el jar 3.0.3

test (5)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-engine jar 5.6.2
org.mockito : mockito-core jar 3.3.3
org.xmlunit : xmlunit-core jar 2.6.4
org.xmlunit : xmlunit-matchers jar 2.6.4
io.github.project-openubl : xml-sender-ws jar 2.1.1.Final

Project Modules

There are no modules declared in this project.

CI Quality Gate Status

XBuilder

Java library for creating and signing XML files based on UBL standards.

XBuilder can be found in Maven Central

Installation

Maven

Open your pom.xml file and add:

<dependency>
    <groupId>io.github.project-openubl</groupId>
    <artifactId>xbuilder</artifactId>
    <version>1.1.0.Final</version>
</dependency>

Gradle

Open your build.gradle file and add:

compile group: 'io.github.project-openubl', name: 'xbuilder', version: '1.1.0.Final'

Supported countries

  • Perú

If you want support for your country please create an issue.

Getting started

XML files can be created from Input Models; for instance:

InvoiceInputModel input = InvoiceInputModel.Builder.anInvoiceInputModel()
                .withSerie("F001")
                .withNumero(1)
                .withProveedor(ProveedorInputModel.Builder.aProveedorInputModel()
                        .withRuc("12345678912")
                        .withRazonSocial("Softgreen S.A.C.")
                        .build()
                )
                .withCliente(ClienteInputModel.Builder.aClienteInputModel()
                        .withNombre("Carlos Feria")
                        .withNumeroDocumentoIdentidad("12121212121")
                        .withTipoDocumentoIdentidad(Catalog6.RUC.toString())
                        .build()
                )
                .withDetalle(Arrays.asList(
                        DocumentLineInputModel.Builder.aDocumentLineInputModel()
                                .withDescripcion("Item1")
                                .withCantidad(new BigDecimal(10))
                                .withPrecioUnitario(new BigDecimal(100))
                                .withUnidadMedida("KGM")
                                .build(),
                        DocumentLineInputModel.Builder.aDocumentLineInputModel()
                                .withDescripcion("Item2")
                                .withCantidad(new BigDecimal(10))
                                .withPrecioUnitario(new BigDecimal(100))
                                .withUnidadMedida("KGM")
                                .build())
                )
                .build();

// Process Input and get XML
DocumentWrapper<InvoiceOutputModel> result = DocumentFacade.createXML(input, config, systemClock);
InvoiceOutputModel output = result.getOutput();
String xml = result.getXml();

Sign XMLs

After you created the xml file you can now sign it:

String xml;
String signID = "mySignID";

// Get your certificate using the method of your preference
X509Certificate certificate;
PrivateKey privateKey;

Document signedXML = XMLSigner.signXML(xml, signID, certificate, privateKey);
io.github.project-openubl

Project OpenUBL

Open source para facturación electrónica Perú

Versions

Version
1.0.1.Final
1.0.0.Final
1.0.0.Beta4
1.0.0.Beta3
1.0.0.Beta2
1.0.0.Beta1