Open jzavala-gonzalez opened 1 year ago
See the following document https://xbrl.us/wp-content/uploads/2023/05/XINCE-documentation-V1.0.pdf
Here is an example that takes an takes a filing gets some data and creates a new XML instance :
python3.9 ~/arelle/Arelle-master/arellecmdline.py --plugins 'xule|xince|transforms/SEC|validate/EFM|inlineXbrlDocumentSet' -f /Users/campbellpryde/Documents/GitHub/ACFR-Taxonomy/SingleAudit/InstanceCreation/xule/output/myInstance.xml --xule-time .005 --xule-debug --noCertificateCheck --logFile /output/test.xml --xule-rule-set /GitHub/ACFR-Taxonomy/SingleAudit/InstanceCreation/xule/compile/sa-ruleset.zip --xince-location /InstanceCreation/xule/output --xince-show-xule-log --xince-file-type=xml
You can also use XINCE to read a Excel spreadsheet and spit out single or multiple instance documents. Xule has a function that allows you to specify excel data and output as XBRL instances against a defined taxonomy.
Here is an example of code to create an instance from an excel template that has no XBRL data in it.
constant $InstanceName = 'myInstance' constant $FILING_EXCEL = '/Users/campbellpryde/Documents/GitHub/ACFR-Taxonomy/SingleAudit/InstanceCreation/Excel/sf-sac.xlsx' constant $TAXONOMY_LOC = 'https://taxonomies.xbrl.us/grip/2022/singleaudit/singleaudit-all_2022.xsd'
output createInstance true instance-name $InstanceName instance-taxonomy list($TAXONOMY_LOC,'https://xbrl.sec.gov/dei/2022/dei-sub-2022.xsd').to-json
constant $GET_DATA = excel-data($FILING_EXCEL, 'FederalAwards',true)
constant $ElementMapping = dict( list(1,"{https://taxonomies.xbrl.us/grip/2022/grants\}FederalProgramIdentifierAxis"), list(2,"blank"), list(3,"{https://taxonomies.xbrl.us/grip/2022/grants\}FederalAwardingAgencyEnumerated"), list(4,"{https://taxonomies.xbrl.us/grip/2022/grants\}CFDANumber"), list(5,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}AdditionalAwardIdentification"), list(6,"{https://taxonomies.xbrl.us/grip/2022/grants\}FederalProgramName"), list(7,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}AmountExpended"), list(8,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}GRMLegalEntityAuditClusterName"), list(9,"blank"), list(10,"blank"), list(11,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}FederalLoanOrLoanGuarantee"), list(12,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}OutstandingLoanBalance"), list(13,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}DirectAward"), list(14,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}PassThroughSourceEntityName"), list(15,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}PassThroughSourceEntityIdentifier"), list(16,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}AwardPassedThroughToSubrecipients"), list(17,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}PassThroughAmount"), list(18,"blank"), list(19,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}MajorProgram"), list(20,"blank"), list(21,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}TypeofSingleAuditOpinion"), list(22,"{https://taxonomies.xbrl.us/grip/2022/singleAudit\}GRMLegalEntityAuditFindingsTotalQuantity") )
constant $units = dict( list(3,unit(xbrli:pure)), list(7,unit(iso4217:USD)), list(12,unit(iso4217:USD)), list(17,unit(iso4217:USD)), list(22,unit(xbrli:pure)) )
/ Get the Federal Awards sheet / output federalAwards for $row in $GET_DATA for $i in range($row.length) if $i == 1 skip else if $ElementMapping[$i] == "blank" or $row[$i] == 'None' skip else $member_value = $row[1]; $sa_value = $row[$i]; $is-nil = if $row[$i] == '' true else false $conceptName = $ElementMapping[$i]; $period = duration($GET_FISCAL_PERIOD_START[1] , $GET_FISCAL_PERIOD_END[1]) $unit_value = if exists($units[$i]) $units[$i] else none ; true
fact-instance $InstanceName fact-value $sa_value fact-concept $conceptName.to-xince fact-dimensions dict(list("{https://taxonomies.xbrl.us/grip/2022/grants\}FederalProgramIdentifierAxis", $member_value)).to-xince fact-entity entity('http://some/schema', 'CompanyA').to-xince fact-period $period.to-xince fact-unit $unit_value.to-xince fact-is-nil $is-nil
Thank you!! This is super helpful. I'm attempting to run these examples soon to check if I can get it to work. Is the Github/ACFR-Taxonomy repository you reference in the first example available publicly? Such that I can download the sa-ruleset.zip and the sf-sac.xlsx Excel template. Also, I'm glad both examples use ACFR because that's the use case I am looking into. Thank you!
Added a missing parameter that was crashing the run. Does anyone know what parameters or example do we pass to arelleCmdLine to run Xince?