<?xml version="1.0" encoding="UTF-8"?>
<essay xml:lang="en" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:gal="http://norman.walsh.name/rdf/gallery#">
<info>
    
    
    
    
    
    
    
    
    
    
    
<title>CVS, Dates, and Validation</title><biblioid class="uri">http://norman.walsh.name/2004/04/06/cvsdates</biblioid>
<volumenum>7</volumenum>
<issuenum>57</issuenum>
<pubdate>2004-04-06T17:43:00-04:00</pubdate>
<date>$Date$</date>
<author>
      <personname>
<firstname>Norman</firstname>
	<surname>Walsh</surname>
</personname>
    </author>
<copyright>
      <year>2004</year>
      <holder>Norman Walsh</holder>
    </copyright>
<abstract>
<para>The CVS $Date$ keyword doesn’t validate as an ISO 8601 date/time.</para>
</abstract>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#CVS"/>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#DocBook"/>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#SelfReference"/>
</info>

<epigraph>
<attribution>
      <personname>
	<firstname>Samuel</firstname>
<surname>Johnson</surname>
      </personname>
    </attribution>
<para xml:id="p1">Men are generally idle, and ready to
satisfy themselves, and intimidate the industry of others, by calling
that impossible which is only difficult.</para>
</epigraph>

<para xml:id="p2">I’ve been working more-and-more with
<link xlink:href="/2004/01/09/bourbon">DocBook NG</link>. Mostly I’m pretty
satisfied, but it’s definitely not without surprises. Handling “universal linking”
has turned out, for example, to be tricky. It’d be easier
with <link xlink:href="http://www.w3.org/TR/xslt20/">XSLT 2.0</link>, but I’m not
ready to make that commitment yet. I mean literally not ready, I still have extension
functions that don’t run in
<link xlink:href="http://saxon.sourceforge.net/">Saxon 7</link>.</para>

<para xml:id="p3">The formatting issues are mostly a matter of intellectual effort, the
right answer is clear even if the solution that produces it isn’t. Here’s something
more interesting: what constraints should be placed on the content of elements
that are clearly supposed to hold dates and times?</para>

<para xml:id="p4">In “Bourbon”, the content of <tag>date</tag> and <tag>pubdate</tag>
are constrained to be dates in the following way:</para>

<programlisting>db.pubdate =
  element date {
    date.attlist,
    (xsd:date | xsd:dateTime | xsd:gYearMonth | xsd:gYear)
  }</programlisting>

<para xml:id="p5">Works for me, until I discover that I routinely (ab)use <tag>date</tag>
in the following way:</para>

<programlisting>&lt;date&gt;$Date$&lt;/date&gt;</programlisting>

<para xml:id="p6">That’s clearly a date, but it doesn’t validate. Yet I still
want the date element to contain the last modified date as provided by
CVS.</para>

<!--
<para xml:id='p7'>(Now, by the same token,</para>

<programlisting>&lt;date&gt;06 Avril 2004&lt;/date&gt;</programlisting>

<para xml:id='p8'>doesn’t validate either. But I wasn’t going to worry about that case:
anyone writing the dates can write them in one of the standard date formats.)</para>
-->

<para xml:id="p9">So what to do? On one end of the spectrum, we could decide that
DocBook will not attempt to constrain the content of the date
elements. On the other end, we could enforce the constraint and I could move
my CVS keyword-based date off into some other element, perhaps one in
my own namespace.</para>

<para xml:id="p10">For the moment, since this is all in a customization layer (specifically,
the “NG” version of the schema for this weblog), I worked around the problem
by providing another pattern for <tag>date</tag> and allowing it in
the <tag>info</tag>:</para>

<programlisting>cvsDate =
   element date {
      date.attlist,
      xsd:string {
         pattern = "$Date: \p{Nd}{4}/\p{Nd}{2}/\p{Nd}{2} \p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2} $"
      }
   }</programlisting>

<para xml:id="p11">Gotta love the flexibility of
<link xlink:href="http://www.relaxng.org/">RELAX NG</link>.</para>

<para xml:id="p12">Thoughts?</para>

</essay>

