I am trying to programmatically parse through XBRl files and retrieve certain facts such as this year's revenue or asset accounts. I'm running into trouble when trying to have my program determine which context is associated with current year permanent accounts (balance sheet accounts). The issue is that these contexts are defined in the XBRL instance file not in a schema. For example, the context I'm looking for in JP Morgan's most recent filing is:
<xbrli:context id="FI2017Q4">
<xbrli:entity>
<xbrli:identifier scheme="http://www.sec.gov/CIK">0000019617</xbrli:identifier>
</xbrli:entity>
<xbrli:period>
<xbrli:instant>2017-12-31</xbrli:instant>
</xbrli:period>
</xbrli:context>
I can tell this is the context I'm looking for by intrepreting the ID and looking throughout the rest of the document and seeing which facts refer to it but it is impractical to have my program do that.