1
votes
<!-- Mapping from Excel to XBRL -->
<xbrl xmlns="http://www.xbrl.org/2003/instance" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:xbrldt="http://xbrl.org/2005/xbrldt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:ifrs="http://xbrl.ifrs.org/taxonomy/2013-03-28/ifrs">
<link:schemaRef xlink:type="simple" xlink:href="IFRS\ifrs-cor_2013-03-28.xsd"/>
<!-- Contexts -->
<context id="D-2063">
    <entity>
        <identifier scheme="http://www.cro.gov.np">CRO</identifier>
    </entity>
    <period>
        <startDate>2063-04-01</startDate>
        <endDate>2064-03-31</endDate>
    </period>
</context>
<context id="I-2063">
    <entity>
        <identifier scheme="http://www.cro.gov.np">CRO</identifier>
    </entity>
    <period>
        <instant>2064-03-31</instant>
    </period>
</context>
<!-- Units -->
<unit id="U-Monetary">
    <measure>iso4217:NPR</measure>
 </unit>  
<!-- Fact values -->  
<ifrs:Assets contextRef="I-2063" unitRef="U-Monetary" decimals="0">7954664475</ifrs:Assets>
</xbrl>  

The above given is an example of XBRL file which is based on XML. I want to select the attribute value of contextRef from FactValue of ifrs:Assets. As we can see, we have namespaces defined, normal xquery with simple xpath doesn't works. So, I had used

  xquery version "3.0";
  let $x:=doc("/db/Siddhartha/2061.xml")
  return $x/*[local-name()="xbrl"]/*[local-name()="Assets"][@contextRef]

But the value expected I-2063 didn't came up. How can I get the value of attribute contextRef from above file?

1

1 Answers

2
votes

If you want to return the attribute's value use $x/*[local-name()="xbrl"]/*[local-name()="Assets"]/@contextRef/string().

Of course XQuery also allows you to deal with namespaces so you don't need the local-name() "hacks":

xquery version "3.0";
declare default element namespace "http://www.xbrl.org/2003/instance";
declare namespace ifrs = "http://xbrl.ifrs.org/taxonomy/2013-03-28/ifrs";
let $x:=doc("/db/Siddhartha/2061.xml")
return $x/xbrl/ifrs:Assets/@contextRef/string()