Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing the contents of xml_tags depends on their position in the xml file. #7

Open
NicSAE opened this issue Sep 18, 2019 · 4 comments
Assignees
Labels

Comments

@NicSAE
Copy link

NicSAE commented Sep 18, 2019

I am trying to parse a simple xml file, based on the one you use in the "parse_file_simple" test case.

It seems to me that calling xml_file%parse gives satisfying results only when you're trying to acces the content of the first tag.

To demonstrate this, I have created 3 simple xml files (input_light_1/2/3.xml), that contain only 3 tags, "first", "second", "third", but placed in different orders.
I also wrote a minimal fortran code (parse_file_simple_LIGHT.f90), that takes a single xml file as an argument, and attends to access the content of tags "first", "second", and "third" and prints result.

You can find every file in the enclosed archive.

Any help would be greatly appreciated.
FOXY_TEST_CASE.tar.gz

@szaghi szaghi self-assigned this Sep 19, 2019
@szaghi szaghi added the bug label Sep 19, 2019
@szaghi
Copy link
Member

szaghi commented Sep 19, 2019

@NicSAE

Thank you very much for pointing it out, I'll try to investigate end fix the bug as fast as I can.

@szaghi
Copy link
Member

szaghi commented Sep 19, 2019

@NicSAE

I have just pushed a new release that seems to fix the bug: analyzing your test I found that aside the main bug into the content method there was also a bug into the search method. Now both bugs should be fixed. I added a new input for raising the bug on the search method (that is called when a nested content is searched for).

Let me know if this new release works for your application.

Cheers.

input_light_4.xml.gz

@rakowsk
Copy link

rakowsk commented Oct 20, 2019

Dear szaghi,

There still seems to be a problem. I have to extract information from a nested XML file, and maybe it is me getting FoXy wrong and stepping down the levels in a too complicated way. If this is the case, sorry for bothering you (but please, could you point me to an example on how to parse nested XML in the correct way?)!

Everything works fine when I compile with gfortran 7.4.0 or ifort 18.0.5 w/o any debugging options or optimization. But when I switch bound checking on, the code breaks with an error, here for "gfortran -g -fbounds-check -fbacktrace", with similar output for ifort:

At line 224 of file foxy_xml_tag.F90
Fortran runtime error: Substring out of bounds: lower bound (0) of 'source' is less than one

This happens for the second entry in the xml-file, no matter if it is parsed first or second. The example code will always break when scanning for "magnitude", no matter if "origin" is - succesfully - parsed before. If you interchange magnitude and origin, in the XML, it will break for "origin".

simplified_quakeml_test.tar.gz

Thank you very much, first of all for providing this very helpful library!

==========
Some background, not relevant for the bug report, but maybe of interest: FoXy should allow our Fortran90 tsunami simulation code to parse QuakeML, a standard to describe earthquake events, without any python wrapper or such. We need the magnitude and the epicentre longitude and latitude, later also the fault mechanism. The full example I am trying to parse (scroll until QuakeML):
https://github.com/usgs/Quakeml/wiki/Focal-mechanism-example

GitHub
ANSS Quakeml. Contribute to usgs/Quakeml development by creating an account on GitHub.

@rakowsk
Copy link

rakowsk commented Oct 21, 2019

w/o any debugging options or optimization.
Not well formulated: I meant: (w/o any debugging options) or (optimization). FoXy compiled with optimization, e.g., -O3, also works fine and we can extract all values we need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants