Sofu – SofuML

February 16, 2008

Got bored (again) and wrote SofuML and binary file support for Sofu.Net.

Don’t get me wrong, but I don’t like XML for saving structured data. XML is fine for doing layout and stuff, but if you don’t use proper indentation (as most exporters do) it looks kinda confusing. If you do indentation with tabs, it looks better, but than there is the whole white-space issue: Try saving a value with a leading whitespace, you can’t difference it from an indentation. Sure, you can use xml:space = “preserve” (20 or 22 more bytes in every element), but than you can’t use indentation again.

Than you will have to write the whole name of the element again in the closing tag, (more space used) Which only serves one purpose: To help the parser (or something). You can’t close any other tag than the last opened. This leads to XML elements getting named very short, which defies the whole readability purpose. (Anyone who has seen a MS-Word XML file will probably agree here)

One the other hand XML is a standard and the whole shebang around it has gotten quite powerful. XSLT (with XPath) is one example, no other data-format can be converted that easily (especially to produce HTML output).

That’s why I thought it would be neat to convert .sofu files to .xml files. and I called it SofuML. So you can transform it easily without having to code a program.

XML already brings a way to reference other element (in the same file) and the rest that is needed. (This will still keep the whole whitespace issue, but you can escape leading and trailing whitespaces. (The whole .sofu file will not be changed after being written and read again, but the final product after converting depends a lot on the parser)

Take this .sofu file for example:

somemap={
somelist=(1 2 3)
somevalue="Hello World"
}

Will be converted to this:

<Sofu>
<Element key="somemap">
<Map>
<Element key="somelist">
<List>
<Value>1</Value>
<Value>2</Value>
<Value>3</Value>
</List>
</Element>
<Element key="somevalue">
<Value>Hello World</Value>
</Element>
</Map>
</Element>
</Sofu>

This is not that nice and small, but you can use XSLT to convert it into HTML or even back to Sofu.

The XSLT to convert it to sofu is not complete, (I have found no way to escape keys and values if needed,) but it is funny anyways.

This is what happens if you put it through a compatible browser (IE or Firefox works great): http://sofu.sf.net/test.xml, also check “View Sourcecode” and you will see its just the XML file.

Advertisements

Angriff der Dateien (Attack of the files)

January 2, 2008

Sorry, this post has to be german. English version further down.

Man kann sich ja über vieles unötig aufregen, und das ist normalerweise auch berechtigt. Was mich seid neustem immer wieder zum Lachen bringt sind die im Radio und Fernsehen aufkommenden “Dateien”. Eine Kinderschänderdatei, eine Terroristendatei und auch noch die Bundestrojanerzieldatei.

Das würde dann wahrscheinlich so aussehen: Terror file

So sehr wie unsere Regierung Microsoft Produkte liebt, wird es wahrscheinlich Excel oder Word werden. Allerdings kann Excel nicht so viele Einträge verwalten wie es Muslime in Deutschland gibt. Das Ganze noch zentral irgendwo in einer Datenbank zu verwalten kommt keinem Politiker in den Sinn, der grade das Wort Datei von einem anderen Politiker gehört hat und auch schon mal von seinem/r Sektretär/in beiläufig aufgeschnappt hat. Und da auch die Kosten überschaubar bleiben müssen wird die Datei in dem PC des/der Sektretäres/in landen. (Du kennst dich doch mit Dateien aus …. ) und mit dem nächsten Plattencrash verschwinden.

English explanation:

Currently in Germany all the politician’s and newspapers are talking about files. A terrorists file for example, which stores all the bad bad people suspected of evil (or the “wrong” religion). And knowing the German government and its policy on software: If they are talking about a file, they want a file. Not a database or something else useful. I think it might be a Microsoft Word document, because Excel can only hold 65536 entries, not enough for all the bad people. This whole files project will end in one secretary having a word document on her PC with all the suspects in it.