When adding a unit to the XbrlInstance like ‘iso4217:EUR’ then the namespace xmlns:iso4217=“http://www.xbrl.org/2003/iso4217
” will not be added to the html file when saving as IXBRL.
Sample Project:
AsposeFinanceContextUnitNamespaceBug.zip (2.1 KB)
using Aspose.Finance.Xbrl;
// Create a new xbrlInstance
var xbrlInstances = new XbrlDocument().XbrlInstances;
var xbrlInstance = xbrlInstances[xbrlInstances.Add()];
// Add the Unit
xbrlInstance.Units.Add(new Unit(UnitType.Measure)
{
Id = "EUR",
MeasureQualifiedNames = { new QualifiedName("EUR", "iso4217", "http://www.xbrl.org/2003/iso4217") },
});
// Declare SaveOptions
var saveOptions = new SaveOptions()
{
SaveFormat = SaveFormat.IXBRL,
SaveLinkbasesToDesticationFolder = false,
SaveSchemasToDesticationFolder = false,
};
var tempPath = Path.GetTempFileName();
// Save the xbrlInstance to a temp-file
xbrlInstance.XbrlDocument.Save(tempPath, saveOptions);
var xbrlInstanceHtmlString = Read(tempPath);
var xbrlInstanceHtmlStringContainsScenario = xbrlInstanceHtmlString.Contains(@"xmlns:iso4217=""http://www.xbrl.org/2003/iso4217""");
Console.WriteLine(@$"Check if XbrlInstance contains namespace 'xmlns:iso4217=""http://www.xbrl.org/2003/iso4217""': {xbrlInstanceHtmlStringContainsScenario}");
Console.WriteLine("Should be 'True'");
Console.ReadLine();
string Read(string path)
{
// read it to string
var xbrlInstanceAsString = File.ReadAllText(path);
// Cleanup the temp-file
if (File.Exists(path)) File.Delete(path);
return xbrlInstanceAsString;
}
Desired Output:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ix="http://www.xbrl.org/2013/inlineXBRL"
xmlns:ixt="http://www.xbrl.org/inlineXBRL/transformation/2010-04-20"
xmlns:link="http://www.xbrl.org/2003/linkbase"
xmlns:xbrli="http://www.xbrl.org/2003/instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xbrldi="http://xbrl.org/2006/xbrldi"
# CURRENTLY MISSING ################################
# xmlns:iso4217="http://www.xbrl.org/2003/iso4217" #
####################################################
>
<head>
<title>Ixbrl Document</title>
</head>
<body>
<div style="display: none">
<ix:header>
<ix:hidden />
<ix:references />
<ix:resources>
<xbrli:unit id="EUR">
<xbrli:measure>iso4217:EUR</xbrli:measure>
</xbrli:unit>
</ix:resources>
</ix:header>
</div>
</body>
</html>