dgm9704 / Xoxo

read, write, compare, convert XBRL reports
GNU Lesser General Public License v3.0
27 stars 9 forks source link

Option to disable 'instance-generator' declaration #86

Closed LukeFranky closed 5 months ago

LukeFranky commented 5 months ago

The Australian Tax Office rejects XBRL with the XML and 'instance-generator' declarations at the top of the file.

Please provide an option to disable the declaration output.

image-2024-05-21-12-30-25-769

dgm9704 commented 5 months ago

Thank you for reporting this issue!I am traveling at the moment but I will take a look at this in a couple of days. On 21. May 2024, at 4.50, LukeFranky @.***> wrote: The Australian Tax Office rejects XBRL with the XML and 'instance-generator' declarations at the top of the file. Please provide an option to disable the declaration output. image-2024-05-21-12-30-25-769.png (view on web)

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

LukeFranky commented 5 months ago

Thank you,

I have been able to workaround with the following approach:

            var remove = new List<XmlNode>();
            XmlDocument doc = this.Instance.ToXmlDocument();

            // Identify nodes incompatible with ATO
            foreach (XmlNode node in doc)
            {
                if (node.NodeType == XmlNodeType.XmlDeclaration || node.NodeType == XmlNodeType.ProcessingInstruction)
                {
                    remove.Add(node);
                }
            }

            // Remove nodes incompatible with ATO
            foreach (XmlNode node in remove)
            {
                doc.RemoveChild(node);
            }

            var settings = new XmlWriterSettings();
            settings.OmitXmlDeclaration = true;
            settings.Indent = true;
            settings.IndentChars = "\t";
            settings.NamespaceHandling = NamespaceHandling.OmitDuplicates;
            settings.Encoding = Encoding.UTF8;

            // Output refined XML
            using (XmlWriter writer = XmlWriter.Create(output, settings))
            {
                doc.WriteTo(writer);
            }
dgm9704 commented 5 months ago

This is now fixed in 3.3.0. You can control specific bits of the metadata with report properties:

            report.OutputInstanceGenerator = false;
            report.OutputTaxonomyVersion = false;
            report.OutputXmlDeclaration = false;
            report.OutputComments = false;

https://www.nuget.org/packages/Diwen.Xbrl/3.3.0

LukeFranky commented 5 months ago

Wow. That was fast.

Thank you,

dgm9704 commented 5 months ago

Well it was a pretty straightforward fix, let's just hope it does what you need.