C# proxy classes to create and serialize .Net objects to Xml that conforms UBL-TR v1.2.1 standards or deserialize UBL-Tr documents to .Net objects.
First install UblTr package:
PM> Install-Package UblTr
privatestaticvoidMain(string[]args){varinvoice=newUblTr.MainDoc.InvoiceType(){UUID=newUblTr.Common.UUIDType(){Value=Guid.NewGuid().ToString()},UBLVersionID=newUblTr.Common.UBLVersionIDType(){Value="2.1"},CustomizationID=newUblTr.Common.CustomizationIDType(){Value="TR1.2"},ProfileID=newUblTr.Common.ProfileIDType(){Value="TEMELFATURA"},ID=newUblTr.Common.IDType(){Value="INV20200000000001"},CopyIndicator=newUblTr.Common.CopyIndicatorType(){Value=false}};XmlSerializerxmlSerializer=newXmlSerializer(typeof(UblTr.MainDoc.InvoiceType));usingTextWriterwriter=newStreamWriter(@"C:\Temp\TestInvoice.xml");//path to documentxmlSerializer.Serialize(writer,invoice,newUblTr.Serialization.UblTrNamespaces());}Xml file content
<?xml version="1.0" encoding="utf-8"?>
<Invoicexmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:ubltr="urn:oasis:names:specification:ubl:schema:xsd:TurkishCustomizationExtensionComponents" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:CustomizationID>TR1.2</cbc:CustomizationID>
<cbc:ProfileID>TEMELFATURA</cbc:ProfileID>
<cbc:ID>INV20200000000001</cbc:ID>
<cbc:CopyIndicator>false</cbc:CopyIndicator>
<cbc:UUID>fa595ae1-9ba4-4661-a031-6c58a53e7429</cbc:UUID>
</Invoice>varpath=@"C:\invoice.xml";// path to invoice documentXmlSerializerserializer=newXmlSerializer(typeof(UblTr.MainDoc.InvoiceType));using(StreamReaderreader=newStreamReader(path)){varinvoice=(UblTr.MainDoc.InvoiceType)serializer.Deserialize(reader);}