Split large XML file into hierarchical directory structure
Closed this issue · 2 comments
tixiOpenDocumentRecursive
allows reading XML files with external data files which is great for using modular XML-file structures. Is there a possibility to do the opposite way, so split a large XML into multiple external data files and store them according to the nodes?
E.g. If I have a CPACS file
<cpacs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CPACS_22_Schema.xsd">
<header>
...
</header>
<vehicles>
<engines>
<engine uID="testengine">
...
</engine>
</engines>
<aircraft>
<model uID="testmodel">
</model>
</aircraft>
<profiles>
...
</profiles>
<structuralElements>
...
</structuralElements>
<materials>
...
</materials>
</vehicles>
<toolspecific>
<toolname1>
...
</toolname1
</toolspecific>
<missions/>
</cpacs>
Would it be possible to create a directory structure and use externaldata
for all elements
<?xml version="1.0" encoding="utf-8"?>
<cpacs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CPACS_22_Schema.xsd">
<externaldata>
<path>file://Header/</path>
<filename>Header.xml</filename>
</externaldata>
<externaldata>
<path>file://Vehicles/</path>
<filename>Vehicles.xml</filename>
</externaldata>
<externaldata>
<path>file://ToolSpecific/</path>
<filename>ToolSpecific.xml</filename>
</externaldata>
<missions/>
</cpacs>
and put the externaldata
into folders
Header
Header.xml
Toolspecific
Toolname1
Toolname1.xml
Toolname2
Toolname2.xml
...
Toolspecific.xml
Vehicles
Engines
...
Engines.xml
Aircraft
...
Aircraft.xml
...
Vehicles.xml
CPACS.xml
This should be already possible without any problems or modifications right now.
Update: What does not work is to create the directories right now. Since PATH could also be a URL to a web site etc, creating the path is not really defined and would only work, if it is a local directory with the right permissions etc. I am not sure yet, whether the automatism would be a good idea though.
I think it would be somehow cleaner to have an external code/script, that is responsible for creating the directories.
@readma, if this is still unresolved for you, feel free to re-open this issue.