Newbie XML/XSL questions on save files

J

joey

I am considering using XML as the save file format for some of our
applications and I have a few questions/misconceptions that I'm hoping
someone here can clear up.

We have a whole series of loosely related applications which save (for
instance) one or more sources, a time, and either zero, one, or two units.
In addition to all of these, all the applications save some other stuff
which is specific to their needs.

Now, one feature I wish to have is that if one application saves, any of the
other applications can also read that XML file and pull out the sources,
time, and units. What do I need to do to make this happen? Do they all have
to have the same tag name? Maybe I can use an XSL(T?) to convert from one
XML file to another?

The second feature is that as the programs gets upgraded, more and more stuff
go into the save file. The new versions of the program need to be able to
read the old versions of the save file. Ideally, I would like to have the
program insert default values for things which are not explicitly defined in
the save file. Can XML do that?

Finally, is there a best practices way of defining my XML files?

In case it matters, I am doing all the coding in C++ and right now using
Qt's built in XML which is based on SAX.

Here is an example of two of the example XML files I currently have. Each
from a different program which is listed in the DOCTYPE. Recommendations on
how to make these better would be very welcome!

Example 1
---------

<!DOCTYPE SDCatalog>
<SDDAS>
<Entry_Mask>2</Entry_Mask>
<Idfs_Type>11</Idfs_Type>
<Time>
<Start_Time>
<Year>1900</Year>
<Day>1</Day>
<SecOfDay>0</SecOfDay>
</Start_Time>
<Stop_Time>
<Year>2005</Year>
<Day>75</Day>
<SecOfDay>47640</SecOfDay>
</Stop_Time>
</Time>
<Number_of_Sources>2</Number_of_Sources>
<Source0>
<Project>CLUSTERII</Project>
<Satellite>CLUSTER-1</Satellite>
<Experiment>PEACE</Experiment>
<Instrument>3DX1</Instrument>
<Virtual>CPXP1L</Virtual>
</Source0>
<Source1>
<Project>CLUSTERII</Project>
<Satellite>CLUSTER-1</Satellite>
<Experiment>PEACE</Experiment>
<Instrument>3DX1</Instrument>
<Virtual>CPXP1H</Virtual>
</Source1>
</SDDAS>

Example 2
----------

<!DOCTYPE Contours>
<SDDAS>
<Contours version="v2.1.6" >
<NumberSources>1</NumberSources>
<source0>
<Averaging>0</Averaging>
<Project>14</Project>
<ProjectName>MARS</ProjectName>
<Satellite>3</Satellite>
<SatName>Mars_Express</SatName>
<Experiment>1</Experiment>
<ExpName>ASPERA-3</ExpName>
<Instrument>1</Instrument>
<InstName>ELS</InstName>
<VirtInst>23</VirtInst>
<VirtInstName>ELSSCIL</VirtInstName>
<DataType>1</DataType>
<DataTypeName>Sensor</DataTypeName>
<SensorGrp>0</SensorGrp>
<SensorGrpName>ELS Science Data</SensorGrpName>
<SensorComp>0</SensorComp>
<SensorCompName>Sector 0</SensorCompName>
<SenVidf>0</SenVidf>
<Sensor>0</Sensor>
<SensorName>ELS Sector 0 LR</SensorName>
<CalSet>-1</CalSet>
<CalSetName></CalSetName>
<Mode>-1</Mode>
<ModeName></ModeName>
<ElemNum>-1</ElemNum>
<Element>-1</Element>
<IsSCF>0</IsSCF>
<SCFName></SCFName>
</source0>
<IsEnabled>1</IsEnabled>
<time>
<RealTime>0</RealTime>
<StartTimeYear>2004</StartTimeYear>
<StartTimeDay>235</StartTimeDay>
<StartTimeOfDay>43500</StartTimeOfDay>
<StartTimeStr>2004235 12 05 00</StartTimeStr>
<StopTimeYear>2004</StopTimeYear>
<StopTimeDay>235</StopTimeDay>
<StopTimeOfDay>44400</StopTimeOfDay>
<StopTimeStr>2004235 12 20 00</StopTimeStr>
</time>
<units>
<DataUnits>18</DataUnits>
<DataUnitsName>Energy Intensity (ergs/(cm**2-sr-sec-eV))</DataUnitsName>
<ScanUnits>11</ScanUnits>
<ScanUnitsName>Electron Energy (eV)</ScanUnitsName>
<ScanUnitsPos>4</ScanUnitsPos>
</units>
<data_definition>
<Rotation>1</Rotation>
<NumRotations>15</NumRotations>
<Mass>0</Mass>
<AtomicNumber>1</AtomicNumber>
<PlotType>ZRPlot_Phi</PlotType>
<UseCutPlane>0</UseCutPlane>
<UseForceRandom>0</UseForceRandom>
<CutPlaneOriginX>0</CutPlaneOriginX>
<CutPlaneOriginY>0</CutPlaneOriginY>
<CutPlaneOriginZ>0</CutPlaneOriginZ>
<CutPlaneNormalX>0</CutPlaneNormalX>
<CutPlaneNormalY>0</CutPlaneNormalY>
<CutPlaneNormalZ>0</CutPlaneNormalZ>
<CutRadius>0</CutRadius>
<CutAngle>0</CutAngle>
<TranslationConstantX>0</TranslationConstantX>
<TranslationConstantY>0</TranslationConstantY>
<TranslationConstantZ>0</TranslationConstantZ>
<ConvertToVelocity>0</ConvertToVelocity>
<ShowVectors>1</ShowVectors>
<FindStartOfSpin>0</FindStartOfSpin>
<AverageSweeps>1</AverageSweeps>
</data_definition>
</Contours>
</SDDAS>

Thanks for any help!
Joey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top