Anne van Kesteren

Document layers

What if sites were build up in layers? How many layers would you need? Imagine you could decide how it worked. Currently, people are pushing each other to separate structure from style, which is quite easy to do. Just use the LINK element and learn HTML (beware, you probably don't know it). Separating behavior and structure is possible as well, albeit more difficult in my opinion. Adding a simple onclick behavior from outside the document requires you to use 'onload', which makes things more complicated, since a user could have used 'onload' for something else. You can of course work around all these limitations, but a CSS approach would be easier, definitely.

Another thing that I find strange is that we have to use the SCRIPT element rather than something like rel=behavior. For XML documents it would be nice to have a <?xml-behavior?> processing instruction to add scripting to documents. Currently you can only add scripting if the client supports the XHTML namespace. In such cases, you can use xhtml:script, which feels like a hack (and actually is, since you rely on namespace knowledge that isn't really necessary at all).

A third layer would be a layer of semantics. This could be added to same way as the behaviors to documents. Defining semantics is especially useful for search engines. Google knows HTML semantics and elements, but isn't aware of you custom element HEADER. If you could define the semantic meaning of such an element, just like you can add style to an element, clients would not have problems with it.

(The current proposed version of XBL will have the problem that it relies on CSS:

selector{
 binding:url(doc.xml#binding);
}

I and Daniel Glazman had some discussion about this on IRC a while ago. The main problem was that someone could use XBL to calculate all the costs of bought products, but that it wouldn't work anymore if someone switched CSS of.)

Comments

  1. Note that there are already technologies and standards in place to capture the semantics of relationships between objects. These are Topic Maps and RDF.

    Both have their strengths and weaknesses, although Topic Maps seem more mature and deployed and have ISO backing.The semantic web, however, will probably not be an (X)HTML web.

    Posted by Jeroen Coumans at

  2. I read a bit about RDF, though it will never be as simple as:

    xhtml:h1{
      semantic:header;
      importance:most;
    }

    (Assuming the semantic layer would use CSS syntax.)

    Posted by Anne at

  3. I don't like the article in the way PPK talks about seperating behaviours from structure. It's like he assumes scripting (javascript) is the only way to create behaviours, while he forgets about other ways (for example SMIL).

    Posted by Jerome at