Closed triska closed 4 years ago
This is resolved with #668, so I'm closing this issue.
@CharlesHoffmanCPA: With #668 applied, we can now use Scryer Prolog to parse and conveniently reason about XBRL files. For example, with said xbrl.xml
sample file from Wikipedia, we can load it, and query what we are interested in, for example via:
?- use_module(library(sgml)). true. ?- use_module(library(xpath)). true. ?- load_xml(file("xbrl.xml"), DOM, []), xpath(DOM, //'OtherOperatingExpenses'(number), Expenses).
Yielding:
DOM = [...], Expenses = 870000000
Note how the predicate xpath/3
from library(xpath)
lets us conveniently query specific elements by specifying XPath selectors. XML files are naturally represented as Prolog terms, and so Prolog is an excellent fit for reasoning about XBRL files!
I would like to use
library(sgml)
to parse XBRL documents and other XML files.When I save the example file shown below to
xbrl.xml
, I get:Instead of a crash, it would be highly preferable to throw an exception that nicely indicates the problem that arose when parsing the file.
roxmltree
should be asked for a description of the error, and this description should be used in the thrown exception.This may be an interesting issue for new contributors who are interested in Rust and XML.
Sample file, taken from https://en.wikipedia.org/wiki/XBRL: