yarffaJ nalA (jnala) wrote in lj_dev,
yarffaJ nalA
jnala
lj_dev

  • Music:

DTD desiderata

A continuation of the discussion from March on a DTD for LiveJournal entries. IMHO, the following features are desirable.
  1. The DTD should allow for future server capabilities whenever possible - new metadata, new security levels, etc.
  2. The DTD should be capable of representing posts that have not yet been submitted to the LiveJournal server. (Client offline mode, possible XML protocol, etc.)
  3. The resulting files should be readable and editable by humans. "3 < 4" should not be represented as "3 &amp;lt; 4". Possibly we should use CDATA blocks and conventionally escape "]]( *)>" as "]]$1 >"; inelegant, but nowhere near as ugly as double-escaping characters. Suggestions welcome.
  4. When keywords in the existing protocol and terminology in common usage differ, we should use the latter for tag names.
With that in mind, here's a suggestion for a DTD, stealing much from the current draft:

Update: Fixed typo. This originally had two ATTLISTs for option and none for meta.

<!-- itemid is optional, in case the server hasn't seen this post yet -->
<!ELEMENT entry (subject?, date, security, (option | meta)*, body)>
<!ATTLIST entry itemid  CDATA #IMPLIED
                journal CDATA #REQUIRED>

<!-- ime short one-line text bits make better attributes than tag contents -->
<!ELEMENT subject EMPTY>
<!ATTLIST subject text CDATA #REQUIRED>

<!-- format for date is "yyyy-mm-dd hh:mm:ss", as is used elsewhere in LJ
     seconds-since-epoch would be nice, but fails outside 1970-2038 range
     allow empty date value, with tz, to let server do the timestamp -->
<!ELEMENT date EMPTY>
<!ATTLIST date value CDATA #IMPLIED
               tz    CDATA #IMPLIED>

<!-- use CDATA attribute, not enum, in case we add security types -->
<!ELEMENT security (group+ | mask)?>
<!ELEMENT group EMPTY>
<!ELEMENT mask EMPTY>
<!ATTLIST security type CDATA #REQUIRED>
<!ATTLIST group name CDATA #REQUIRED>
<!ATTLIST mask name CDATA #REQUIRED>

<!-- options are booleans; metas are values associated with predefined keys -->
<!ELEMENT option EMPTY>
<!ATTLIST option name CDATA #REQUIRED>
<!ELEMENT meta EMPTY>
<!ATTLIST meta name  CDATA #REQUIRED
               value CDATA #REQUIRED>

<!-- body of the entry -->
<!ELEMENT body (#PCDATA)>
Example entry, using this DTD:
<entry itemid="4758836" journal="alanj">
  <subject text="Subject of my post"/>
  <date value="2001-06-01 21:41:08"/>
  <security type="custom">
    <group name="Some friends"/>
    <group name="Other friends"/>
  </security>
  <option name="nocomments"/>
  <meta name="userpic" value="dazed"/>
  <meta name="mood" value="confused"/>
  <meta name="weather" value="63'F, mostly cloudy"/>
  <body><![CDATA[
This is my post body.  It has <b>bold</b> and <i>italics</i>. :-&gt;
It also has a CDATA close sequence ]] >, but that got escaped.
]]></body>
</entry>
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 14 comments