views:

50

answers:

1

Is there an open standard (microformats'ish) that exists for specifying an arbitrary table of key/value pairs in an HTML meta tag?


So let's say I had a website about color, and had a page about a 5-color palette. I essentially want to express information represented in the page, in a format that can be gobbled up by third-party services. In this case, it's the five colors that make up the palette. Like this:

<meta name="data" content="color1:'#ffffff',color2:'#ff00ff',color3:'#ffff00',color4:'#00ffff',color5:'#00ff00'" />


I could roll my own specification, but I really hate doing that if there's something already out there. No need to pollute the web, which is already a quagmire of shady standards...

(p.s. I'm well-aware of RDF. I'd like to specify the content in the page itself... and not require loading another document just for the data.)

A: 

I don't know of any open standards relating to <meta> content, but I think JSON would be a fine format to use if all you want are simple key/value pairs.

<meta name='data' content='
  {
      "key1": "Some value",
      "key2": "Another value"
  }' />
bobbymcr
Yeah, JSON came to mind too. The problem is... it has to be *pseudro* JSON, because quotes can't be properly escaped when inside the `value` attribute's own quotes (and that kinda defeats the "standardized" feel of JSON).
brianreavis
Unless I'm misunderstanding what you're saying, I'm not sure this is actually a problem. If you properly HTML-encode your JSON (just as you would with any attribute text value), any (X)HTML reader is actually going to interpret the attribute value as its unescaped value, giving you back the true JSON string:That is, `<meta name='date' content='{ "x": "'y'" }' />` => should get back `{ "x" : "'y'" }` when `//meta[@name='data']/@content` is programmatically read.
bobbymcr