public static OrdinateCollection ParseOrdinates(XmlElement root, string id, XmlNamespaceManager ns, Collection <Label> labels, string currentPath, Signature currentSignature) { var result = new OrdinateCollection(); var items = root.SelectNodes($"table:definitionNodeSubtreeArc[@xlink:from='{id}']", ns); foreach (XmlElement item in items) { id = item.GetAttribute("xlink:to"); var order = int.Parse(item.GetAttribute("order")).ToString("000"); var path = string.IsNullOrEmpty(currentPath) ? order : $"{currentPath}.{order}"; var ordinateCode = labels.Where(l => l.Id == id).FirstOrDefault(l => l.Type == "rc-code").Value; var metric = ""; var signature = new Signature(currentSignature); var ruleNode = (XmlElement)root.SelectSingleNode($"table:ruleNode[@id='{id}']", ns); if (ruleNode != null) { var metricNode = ruleNode.SelectSingleNode("formula:concept/formula:qname", ns); if (metricNode != null) { metric = metricNode.InnerText; signature["met"] = metric; } var sigNodes = ruleNode.SelectNodes("formula:explicitDimension", ns); foreach (XmlElement sigNode in sigNodes) { var dimension = sigNode.GetAttribute("dimension"); var member = sigNode.SelectSingleNode("formula:member/formula:qname", ns).InnerText; signature[dimension] = member; } } if (!string.IsNullOrEmpty(ordinateCode)) { var ordinate = new Ordinate(ordinateCode, path, signature); result.Add(ordinate); } var subItems = ParseOrdinates(root, id, ns, labels, path, signature); foreach (var subItem in subItems) { result.Add(subItem); } } return(result); }
public static OrdinateCollection ParseKeyOrdinates(XmlElement root, XmlNamespaceManager ns, string aspectId, string order, string axisId, Collection <Label> labels) { var ordinates = new OrdinateCollection(); var aspectNodes = root.SelectNodes($"table:aspectNode[@id='{aspectId}']", ns); foreach (XmlElement aspectNode in aspectNodes) { var path = order; var labelItem = labels.FirstOrDefault(l => l.Id == axisId); var ordinateCode = labelItem.Value; var dimensionNode = aspectNode.SelectSingleNode("table:dimensionAspect", ns); var dimension = dimensionNode.InnerText; //<table:aspectNodeFilterArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2014/aspect-node-filter" xlink:from="s2md_a6.root" xlink:to="s2md_a6.root.filter" complement="false" /> // < df:explicitDimension xlink:type = "resource" xlink: label = "s2md_a6.root.filter" id = "s2md_a6.root.filter" > // < df:dimension > // < df:qname > s2c_dim:BL </ df:qname > // </ df:dimension > // < df:member > // < df:qname > s2c_LB:x0 </ df:qname > // < df:linkrole > http://eiopa.europa.eu/xbrl/s2c/role/dict/dom/LB/33</df:linkrole> //< df:arcrole > http://xbrl.org/int/dim/arcrole/domain-member</df:arcrole> //< df:axis > descendant </ df:axis > // </ df:member > // </ df:explicitDimension > var member = "*"; var filterArc = (XmlElement)root.SelectSingleNode($"table:aspectNodeFilterArc[@xlink:from='{aspectId}']", ns); if (filterArc != null) { var explicitDimensionId = filterArc.GetAttribute("xlink:to"); var explicitDimension = (XmlElement)root.SelectSingleNode($"df:explicitDimension[@id='{explicitDimensionId}']", ns); var linkroleNode = (XmlElement)explicitDimension.SelectSingleNode("df:member/df:linkrole", ns); var role = linkroleNode.InnerText; var r = role.Split('/'); member = $"{r[r.Length - 2]}/{r[r.Length - 1]}"; } var signature = new Signature(); signature.Add(dimension, member); var ordinate = new Ordinate(ordinateCode, path, signature); ordinates.Add(ordinate); } return(ordinates); }