Markup spec/DTD

Introduction
This is a draft of Wikipedia DTD, an interchangable XML representation of the content of wikipedia articles. It contains elements for the content of an article (Wikitext DTD). This is also a contribution to get a formal wikitext standard that is still lacking. When there is such a standard multiple suites of software (some based on mediawiki, some not) could support it, and each Wikipedia could choose between them, while supporting the same portable open content.

Important notes
Wikipedia DTD is an interchange format. It is not to be meant to write articles in it nor to replace a database!

Up to now I (Jakob Voss) am the only author of the Wikipedia DTD but this is meant to be collaborative work in progress - feel free to contribute. Though you should at least know XML basics. Please add comments on Talk:Wikipedia DTD. I am also working on simple WikipediaDTD-to-HTML and WikipediaDTD-to-Wikitax scripts that will be made public soon. The most important thing to use Wikipedia DTD in real life is a Wikitax-2-XML parser. The possibility to mix wiki syntax with invalid HTML is quite complicated.

On Compatibility: Up to know there are wikipedia-articles containing data that will not fit into wikiarticle.dtd because they contain broken or ugly HTML. Some elements that are still allowed in wikitex should have to be removed (for instance HTML-coded headings and horizontal lines or the font-element). This is a topic to discuss.

Advantages
You could also use an XML representation to


 * produce valid XHTML
 * produce printable output (for instance PDF with FO)
 * export to other XML formats (for instance DocBook)
 * perform automatic analysis on structure and layout of articles
 * exploit better XML-based tools to define and extend Wikitax
 * integrate specialized DTDs for "who" (person_DTD), "when and where" (spacetime_DTD) easily, as long as the tag spaces are distinct

Root element
Up to now the Wikipedia DTD is only meant to single articles so the root element is article. There is a metadata section containing the title and other stuff and the article content itself that may be text or a redirect.

<!ELEMENT article (meta, (text | redirect))>

Linking model
Links (to other articles) are one of the most important thing in Wikipedia. In most cases they simply consist of an article name, but there may also be namespaces. In Wikipedia there are 9 namespaces: default (none), talk, user, user-talk, wikipedia, wikipedia-talk, image, image-talk and special. The names of namespaces may differ in different languages but the namespaces remain the same. For instance there is no namespace Diskussion, it is only the german name for the talk namespace. Local names are not part of the Wikipedia DTD.

I prefer seperating the talk-property of a namespace.

<!ENTITY % possible-namespaces "(special | user | wikipedia | image)">

<!ENTITY % local-link-model " 	talk (talk) #IMPLIED	namespace %possible-namespaces; #IMPLIED	article CDATA #REQUIRED ">

The attributes of the local-link-model parameter entity form a full local link destination.

Metadata elements
The metadata section contains information about title, status, version history and interwiki links. Only the title is obligatory. There may be added elements for copyright information, category-links and other this-is-much-more-dublin-core-than-article-content-stuff.

<!ELEMENT meta (title, status?, interwiki*, history?)>

Title
The title of an article does not change - so it is not part of the article history. Since a title may contain namespaces it is the easisiest to specify the full title as a link to the article itself. The interwiki-attribute may specify the wiki the article comes from (normally a language).

<!ELEMENT title EMPTY> <!ATTLIST title interwiki NMTOKEN #IMPLIED %local-link-model; >

Interwiki links
There are several reasons why interwiki links belong into the metadata section. Interwikilinks are relations of an article (maybe there will be other relation types in the future) in spite of normal links in the article content that may mean several things. Concurrently there may be links to other wikipedias inside the article content. Do not mix this. Interwiki links use the same as other links but they must specify a known language.

<!ELEMENT interwiki EMPTY> <!ATTLIST interwiki language NMTOKEN #REQUIRED %local-link-model; >

Article Status
The status element contains status information like whether the article is protected, whether a table of contents should be shown etc. Since the status may change due edits it´s also part of the article history.

<!ELEMENT status EMPTY> <!ATTLIST status protected (protected) #IMPLIED counter CDATA #IMPLIED notoc (notoc) #IMPLIED >

Note: In the actual database the counter (number of times a page has been viewed) is only saved for the current version. This should be changed in the future to get more usage information (for instance to see how often a page has been viewed since the last edit or to detect edit-wars automatically).

Version history
The version history simply contains of a number of edits.

<!ELEMENT history (edit)+>

Each edit contains the edit information (user, timestamp...) and the current status, interwiki-links and content of an article after the edit. The article content is optional - if it is not provided there is just no change or it is just not included because were are not interested in.

<!ELEMENT edit (status?, interwiki*, (text | redirect)?)> <!ATTLIST edit user CDATA #REQUIRED comment CDATA #IMPLIED timestamp CDATA #IMPLIED minor (minor) #IMPLIED >

Redirects
Either an article contains a redirect or text. Redirects are links to articles in the same wiki.

<!ELEMENT redirect EMPTY> <!ATTLIST redirect %local-link-model; >

Wikitext
An XML representation of article content is the core or Wikipedia DTD. You can also use this part alone.

<!ELEMENT text (#PCDATA | %wikitext-block; | %wikitext-inline;)*>

Since this is work in progress the wikitext-block and wikitext-inline parameter entity is not yet fully defined.

wikitext-block:

<!ENTITY wikitext-block "ul | ol | pbr | hr | h1 | h2 | h3 | h4 | h5 | h6">

wikitext-inline: <!ENTITY wikitext-inline "link | strong | em | sub | sup | br | tt">

Headings, horzontal line
In contrast to HTML there are no attributes. <!ELEMENT h1 (#PCDATA | %wikitext-inline;)*> <!ELEMENT h2 (#PCDATA | %wikitext-inline;)*> <!ELEMENT h3 (#PCDATA | %wikitext-inline;)*> <!ELEMENT h4 (#PCDATA | %wikitext-inline;)*> <!ELEMENT h5 (#PCDATA | %wikitext-inline;)*> <!ELEMENT h6 (#PCDATA | %wikitext-inline;)*>

<!ELEMENT hr EMPTY>

Indented lines
<!ELEMENT indent (#PCDATA | %wikitext-inline;)*> <!ATTLIST indent depth CDATA "1" #REQUIRED >

Lists
To avoid #PCDATA and sublist mixing we define oli=li+ol and uli=li+ul

<!ELEMENT ol (li | ol | uli)+> <!ELEMENT ul (li | oli | uli)+> <!ELEMENT oli (li | ol | uli)+> <!ELEMENT uli (li | oli | uli)+>

<!ELEMENT li (#PCDATA | %wikitext-inline;)*>

TODO:
 * attributes: "type", "start", "value", "compact",
 * definition lists

Tables
TODO
 * elements: table, tr, td, th
 * attributes: "summary", "width", "border", "frame", "rules", cellspacing", "cellpadding", "valign", "char", charoff", "colgroup", "col", "span", "abbr", "axis", headers", "scope", "rowspan", "colspan"

pre, center, blockquote, div
TODO these elements (what is allowed inside?) (div also as block?)

<!ATTLIST blockquote cite CDATA #IMPLIED >

Paragraph breaks
Wikitax provides a way to seperate paragraphs: just add an empty line. In Wikitext DTD this is represented by the tag &lt;pbr/&gt; (paragraph break). The posibility to create paragraphs with &lt;p&gt; should be abolished because it leads to broken XML and we should reduce the number of allowed HTML-tags.

<!ELEMENT pbr EMPTY>

Wikitext special elements
TODO: nowiki, media, url, email

Links
TODO: what is allowed inside link text? <!ELEMENT link (#PCDATA | %wikitext-inline-without-some-parts;)*> <!ATTLIST link interwiki NMTOKEN #IMPLIED %local-link-model; >

Math
The image attribute may provide an image representation <!ELEMENT math (#PCDATA)> <!ATTLIST math image ENTITY #IMPLIED >

Reference
<!ELEMENT reference EMPTY> <!ATTLIST system (RFC|ISBN) value CDATA #IMPLIED >

bold/italic

 * b or strong / i or em?

Several HTML tags
Several HTML-tags are also allowed in Wikitext DTD, but most of them are simplified in some way (for instace no or less attributes). ''These tags are not HTML - they are like the same HTML-tags!''


 * big, small, sub, sup, tt, u
 * br
 * ruby-tags

Open questions

 * div (yes), font (no), var (why)

What to do with / where to allow universal HTML attributes (id, class, name, style)?
 * remove id and name, allow class and style at some elements

Variables
Some dynamic variables can be used in Wikitax as .

<!ELEMENT wikivar EMPTY> <!ATTLIST wikivar name (CURRENTMONTH | CURRENTMONTHNAME | CURRENTDAY | CURRENTDAYNAME |       CURRENTYEAR | CURRENTTIME | NUMBEROFARTICLES) #REQUIRED >