Tell you what.. I'll upload my translation of OSE-XML.plist for comparison.
The translation seems OK, but I don't guarantee it. All it takes is one rouge <key> to make the translation gibberish.
It is not OK.
- All the elements of an array must be terminated by a ","
- Only the last element in an array does not need the "," For some operating systems a "," is not even allowed for the last element.
- You defined the outer shell as a dictionary. Than you need a key value next but it is a new directory declaration.
- At the end there are "};" listed wheat should be "}," or better "}".
When I try to load my plist editor now already stumbles over the first line.
- You defined the outer shell as a dictionary. Than you need a key value next but it is a new directory declaration.
- At the end there are "};" listed wheat should be "}," or better "}".
When I try to load my plist editor now already stumbles over the first line.
That outer shell would be <plist></plist> being translated to {}, same as dicts. I guess translator should simply ignore the plist part.. That's my flawed understanding of how the XML format works.. (as I said before, I can't tell heads from tails)
Regarding those ; I still need to "crack" the principle. I tried to get some answers from online wikis and tutorials, and the best explanation I got was that "lines can end with ; , but don't have to. (or was it for JS.. information overload...)
I guess that's what happens when you try to translate something from one language you don't understand, to another that you understand even less... while you have no idea what you're translating...
If I do a script action for a given system, say "0 170" in the planetinfo.plist, will that script action also be called all ten seconds or so or will it only be called when entering the "0 170" system?
Would be important information, thanks in advance for answers
That (failed) attempt was actually a latest feature of a toolset that is in the developing (progress at continuous 95%).
Something that started as a simple tool to reduce a XML size (initiated by OSE plist size ) grew into a tool that does that in a batch... now has about 20 features that mostly work (this translation is the latest, and I failed it).
.. and I keep adding features, instead of releasing the thing...
If I do a script action for a given system, say "0 170" in the planetinfo.plist, will that script action also be called all ten seconds or so or will it only be called when entering the "0 170" system?
That would just be called the moment the system is populated.
It's just as easy/difficult to do the same thing using js, though...
That outer shell would be <plist></plist> being translated to {}, same as dicts. I guess translator should simply ignore the plist part.. That's my flawed understanding of how the XML format works.. (as I said before, I can't tell heads from tails)
You would have noticed when looking at an existing ascii plist. But removing the last flaws is just peanuts compared by what your script already achieves. I just wondered how those last two instances of "};" were generated. With an automated process you would think that when the rules are set up, everything works according those rules but only the last two instances were wrong.
Only problem are the ending "," that separate the elements in an array. There seem to be two definitions around. According mac OSX 10.4 or older it is not allowed to use a "," for the last element. The OS refuses to load these plist. For newer Mac OS or windows it is allowed to use a "," for the last element but it won't complain when one is missing. So to let it work for all operating systems, use the "," as separator of the elements and not as termination of the elements.
I've fixed the translator code so it will generate commas and semi-columns according to array/dictionary structure. Here is re-uploaded OSE-XML.plist, so if anyone would care to test it (and point the errors) I would greatly appreciate it.
You’re putting commas after arrays in dictionaries, which does not make sense.
A dictionary consists of key-value pairs, of the form “key = value;”. There is always a semicolon after the dictionary. A dictionary is always enclosed in braces.
An array consists of items separated by commas. There is no comma after the last item. An array is always enclosed in parentheses.
You’ve incorporated comments into the code as strings, which will annoy the parser/whitelister.
Also, I don’t see why the file is called OSE-XML.plist when it isn’t XML. :-)
I don’t like the indentation style, but it isn’t technically wrong.
[universe.tradeInValueForCommanderDictionary.valueCalculationError]: ***** ERROR: Shipyard dictionary entry for ship caduceus-omega-player required for trade in value calculation, but does not exist. Setting ship value to 0.
That's really strange because there's a shipyard.plist and shipyard-overrides.plist file which BOTH define that ship!
You’re putting commas after arrays in dictionaries, which does not make sense..
Thanks for the input... will fix that.
Ahruman wrote:
There is always a semicolon after the dictionary.
Eric Walch wrote:
- At the end there are "};" listed wheat should be "}," or better "}".
Now, I'm confused.
Ahruman wrote:
An array consists of items separated by commas. There is no comma after the last item. An array is always enclosed in parentheses.
Are you just stating the rules, or are you telling me thet there ARE commas after the last item in arrays? (and there should't be, 'coz I've fixed that part of the code...)
Ahruman wrote:
You’ve incorporated comments into the code as strings, which will annoy the parser/whitelister.
No, I haven't. There are no comments in the file whatsoever.
- At the end there are "};" listed wheat should be "}," or better "}".
Now, I'm confused.
Oh dear… that was exactly the opposite of what I meant.
There is always a semicolon after each dictionary entry. There is nothing specifically after a dictionary except the closing }. Whether it’s followed by a semicolon, a space or nothing depends entirely on what it’s contained in.
Chaky wrote:
Are you just stating the rules,
Just the rules, m’am. Except where I got them wrong, of course. :-)
Chaky wrote:
Ahruman wrote:
You’ve incorporated comments into the code as strings, which will annoy the parser/whitelister.
No, I haven't. There are no comments in the file whatsoever.
- At the end there are "};" listed wheat should be "}," or better "}".
Now, I'm confused.
When you look at the example Ahruman gives you'll see he means a semicolon after every dictionary entry.
Chaky wrote:
Ahruman wrote:
An array consists of items separated by commas. There is no comma after the last item. An array is always enclosed in parentheses.
Are you just stating the rules, or are you telling me thet there ARE commas after the last item in arrays? (and there should't be, 'coz I've fixed that part of the code...)
This part is just a bit of a problem as there are two different rules in use. On windows machines both versions are accepted. And as plist are uncommon to windows I assume oolite is under full control in examining them.
Mac OS until 10.4 refuses to read in plists that contain a comma after the last array entry. Mac OS 10.5 is more forgiving and accepts both ways now.
(And for some reason Apple changed the plist editor that ships with OS 10.5 in a way that it also terminates the last array element with a comma on saving. I am particular annoyed because of this as I know that plists saved with this editor in ascii mode are unreadable by older mac OS.)