When converting directly from XML to H5, the Python script needs the model.xml path and model.xml file. If the model contains 2 nested models, then parsing the root model.xml file does not work correctly.
Reason: Apparently, the XML parser expects relative paths inside the model.xml while xparser uses absolute paths, relative to the root path of the model.
Solution: (Workaround/hack): whenever a nested model.xml file is about to be parsed, re-set the root to the root model folder where we started (the top model folder).
Example 2
Structure that does not work with xparser 0.17.1, but that is most likely expected by a default XML parser in Python (using the relative path, once traversed into the Level1 subfolder):
Reason this works: when the XML parser parses the root model.xml, it parses the line <file>Subfolder/Level1_nested_model.xml</file>, transcends into that subfolder, and starts to parse the file Level1_nested_model.xml. This refers to <file>subsubfolder/Level2_nested_model.xml</file> which exists relative to Subfolder.
Hi Sander,
can you tell me how exactly I can reproduce the error?
How do you execute it from cmd and which files do you use exactly? (the following arguments are required: modelpath, model_file_name, datapath)
File:
src/data_conversion_scripts/src/xml_hdf5
Problem:
When converting directly from XML to H5, the Python script needs the model.xml path and model.xml file. If the model contains 2 nested models, then parsing the root model.xml file does not work correctly.
Reason: Apparently, the XML parser expects relative paths inside the model.xml while xparser uses absolute paths, relative to the root path of the model.
Solution: (Workaround/hack): whenever a nested
model.xml
file is about to be parsed, re-set the root to the root model folder where we started (the top model folder).Examples:
main_model.xml
Subfolder/Level1_nested_model.xml
Subfolder/subsubfolder/Level2_nested_model.xml
Example 1 Structure that works with xparser 0.17.1, but not with standard XML parser that expects relative paths:
-
main_model.xml
:Subfolder/Level1_nested_model.xml
Example 2 Structure that does not work with xparser 0.17.1, but that is most likely expected by a default XML parser in Python (using the relative path, once traversed into the Level1 subfolder):
-
main_model.xml
:Subfolder/Level1_nested_model.xml
Reason this works: when the XML parser parses the root
model.xml,
it parses the line<file>Subfolder/Level1_nested_model.xml</file>
, transcends into that subfolder, and starts to parse the fileLevel1_nested_model.xml
. This refers to<file>subsubfolder/Level2_nested_model.xml</file>
which exists relative toSubfolder
.