Index  |  Stamped  |  1.3. Original chain
La LCO fue actualizada por última vez el 16/may./2026

1.3. Original chain

According to the SAT, the original chain is understood as:

"The data sequence formed with the information contained within the electronic invoice, established in Section C of Annex 20 of the Miscellaneous Tax Resolution."

The original chain is generated by processing the electronic invoice in XML format (or any other electronic document, CFD) with an XSL or XSLT template (it's the same file type; it's known as XSLT, but file extensions are typically kept to three letters, hence XSL) provided by the SAT (Mexican Tax Administration Service) according to the desired CFD version.

The original chain is a very important and sensitive element of the electronic document. It includes information that is integral to the invoice, which is why its generation must be done with extreme care. For this, it is preferable to use previously approved tools such as libraries (JAR or DLL).

Below is an example of how to obtain the original string in version 3.3 using the following elements provided by the SAT:

The Tax Administration System (SAT) has the current version of CFDI 4.0.

At Solución Factible® we reiterate our commitment to serving you by preparing the necessary scenarios and presenting the relevant documentation on this topic, so that you can take the necessary precautions and make the transition to this new billing system as simple as possible. Learn more here

Note: our "Testing" environment is now available to receive proofs in version 4.0. We recommend you perform the tests you deem necessary.

Original chain result:
||3.3|FTVN|41|2017-08-14T00:00:00|01|30001000000300023699|10000|0|JPY|0.166123|11600|I|PUE|45070|EKU9003173C9|ESCUELA KEMPER URGATE SA DE CV|601|KAHO641101B39|OSCAR KALA HAAK|G01|25101800|23534855|1|EA|PZA|Concepto con divisa JPY|10000|10000|10000|002|Tasa|0.160000|1600|0|002|Tasa|0.160000|1600|1600||

To obtain the original string result in the previous example, xsltproc was used:

  • Windows: download the tools at the following link. libxml
  • Linux: they are already installed by default.
$ xsltproc cadenaoriginal_3_3.xslt ejemplo1cfdv33.xml

1.3.1. Diagram of the generation process

diagrama generar cadena original

1.3.2. Code Examples

Generate Original Chain with Java

                    import javax.xml.transform.Transformer;
                    import javax.xml.transform.TransformerException;
                    import javax.xml.transform.TransformerFactory;
                    import javax.xml.transform.stream.StreamResult;
                    import javax.xml.transform.stream.StreamSource;
                    import java.io.File;
                    import java.io.IOException;

                    public class CadenaOriginalGen {

                        public static void main(String[] args) throws TransformerException, IOException {
                            // cargar el archivo XSLT
                            File xslt = new File("C:/SAT/cadenaoriginal_3_3.xslt");
                            StreamSource sourceXSL = new StreamSource(xslt);

                            // cargar el CFDI
                            File cfdi = new File("C:/SAT/ejemplo1cfdv33.xml");
                            StreamSource sourceXML = new StreamSource(cfdi);

                            // crear el procesador XSLT que nos ayudará a generar la cadena original
                            // con base en las reglas del archivo XSLT
                            TransformerFactory tFactory = TransformerFactory.newInstance();
                            Transformer transformer = tFactory.newTransformer(sourceXSL);

                            // aplicar las reglas del XSLT con los datos del CFDI y escribir el resultado en output
                            transformer.transform(sourceXML, new StreamResult(System.out));
                        }
                    }
                

Generate Original Chain with PHP (Courtesy of Julián May)

                    <?php
                        //ruta al archivo XML del CFDI
                        $xmlFile="C:/SAT/ejemplo1cfdv33.xml";

                        // Ruta al archivo XSLT
                        $xslFile = "C:/SAT/cadenaoriginal_3_3.xslt"; 

                        // Crear un objeto DOMDocument para cargar el CFDI
                        $xml = new DOMDocument("1.0","UTF-8"); 
                        // Cargar el CFDI
                        $xml->load($xmlFile);

                        // Crear un objeto DOMDocument para cargar el archivo de transformación XSLT
                        $xsl = new DOMDocument();
                        $xsl->load($xslFile);

                        // Crear el procesador XSLT que nos generará la cadena original con base en las reglas descritas en el XSLT
                        $proc = new XSLTProcessor;
                        // Cargar las reglas de transformación desde el archivo XSLT.
                        $proc->importStyleSheet($xsl);
                        // Generar la cadena original y asignarla a una variable
                        $cadenaOriginal = $proc->transformToXML($xml);

                        echo $cadenaOriginal;
                        ?>
                

Generar Cadena Original con C# (CSharp)

                    using System;
                    using System.Xml.XPath;
                    using System.Xml.Xsl;
                    using System.Xml;
                    using System.IO;

                    namespace pruebas
                    {
                        public class GeneradorCadenas 
                        {
                            public GeneradorCadenas()
                            {
                                //Cargar el XML
                                StreamReader reader = new StreamReader(@"C:/SAT/ejemplo1cfdv33.xml");
                                XPathDocument myXPathDoc = new XPathDocument(reader);

                                //Cargando el XSLT
                                XslCompiledTransform myXslTrans = new XslCompiledTransform();
                                myXslTrans.Load(@"C:/SAT/cadenaoriginal_3_3.xslt");

                                StringWriter str = new StringWriter();
                                XmlTextWriter myWriter = new XmlTextWriter(str);

                                //Aplicando transformacion
                                myXslTrans.Transform(myXPathDoc, null, myWriter);

                                //Resultado
                                string result = str.ToString(); 

                                //Fin del programa.
                            }
                        }
                    }

                

1.3.3. Tool

Original chain generator

This tool takes an electronic invoice (CFD) (.xml) and obtains its original string by applying the XSLT you have chosen in: string version

  • "Generar/Generate" mode: Processes a previously selected XML file, calculates its original string, and displays it.
  • "Descargar/Download" mode: Processes a previously selected XML file, calculates its original string, and downloads a .txt file containing the string.
Datos de contacto
comments powered by Disqus