These days I tend to salt my SEC files with just enough XML to section the data. This gives my code some directives for more intelligent parsing (key-value pairs and UWP lines, both solved problems) without throwing out the whole purpose of SEC files (human readability and edit-ability).
As I've said before, SEC files are poor databases. Their best use is for humans to edit sector data. Thus a non-intrusive salting of XML makes them easy for machines to create and parse without shackling human editors. Frankly, a light salting is all that's needed to simply import and export sector data from real databases, anyhow.
Document
The top document element is <sec>. It has no real data requirements, but I often put "permanent" or "machine relevant" stuff in here anyway, just for good measure.
Header
Next comes the header. I just wrap whatever data the SEC file keeps here with XML tags and move on. Okay, sometimes I'll format the content into a key: value list, but typically this is done for us anyway.
Subsectors
Again, I keep it simple, simply wrapping the existing data.
References
Sometimes there is reference data, with the names of articles which talk about worlds in this sector. I put that in a <notes> section.
UWP Data
Finally, just a simple wrapper around the UWP lines and I'm done.
Yeah, don't forget the final </sec>.
And that's all your SEC file needs. Let XML do the heavy lifting of breaking the file up into sections. The rest is a solved problem.
As I've said before, SEC files are poor databases. Their best use is for humans to edit sector data. Thus a non-intrusive salting of XML makes them easy for machines to create and parse without shackling human editors. Frankly, a light salting is all that's needed to simply import and export sector data from real databases, anyhow.
Document
The top document element is <sec>. It has no real data requirements, but I often put "permanent" or "machine relevant" stuff in here anyway, just for good measure.
Code:
<sec name="Core"
milieu="Second Survey"
desc="AOTI recapture"
gen="Wed May 10 14:41:53 2006">
Header
Next comes the header. I just wrap whatever data the SEC file keeps here with XML tags and move on. Okay, sometimes I'll format the content into a key: value list, but typically this is done for us anyway.
Code:
<header>
Sector: Core Sector
Alt: Sector fG
DOS: core
Coord: fG
Ref: 9960 Ring/Ray 62832
</header>
Subsectors
Again, I keep it simple, simply wrapping the existing data.
Code:
<subsectors>
A: Apge
B: Perite
C: Ameros
... etc ...
N: Ch'naar
O: Dunea
P: Saregon
</subsectors>
References
Sometimes there is reference data, with the names of articles which talk about worlds in this sector. I put that in a <notes> section.
Code:
<notes>
ref 0125 Trevor (SM) "Traveller News Service"
ref 0140 Reference (TD) "Reference, Center of the Imperium"
ref 0523 Dinhe (SM) "Traveller News Service"
... etc ...
</notes>
UWP Data
Finally, just a simple wrapper around the UWP lines and I'm done.
Code:
<data>
New Ramma 0108 D465540-6 S Ag Ni 703 Im K6 V M6 V G6 V
Saarinen 0113 B566212-8 Lo Ni Rs 513 Im K6 V M5 D
Rena 0123 D596211-7 S Lo Ni 403 Im K4 V
Gulistan 0124 CAB2358-7 S Lo Ni Fl 820 Im K6 II
... etc ...
</data>
</sec>
Yeah, don't forget the final </sec>.
And that's all your SEC file needs. Let XML do the heavy lifting of breaking the file up into sections. The rest is a solved problem.