XML Schema Definition creation: Journal - Part 1: Primary layout

In a previous series, I went over the process of creating a new XML document to store my video games. (Although in that case I used a DTD.)

This time I’m going to work on a schema to store quasi-journal entries, which I’m hoping will help with my goal to write every day.

What I hope to accomplish

Ultimately I want to store a bit of text for any particular day. The entry should have a date and time associated with it, for both when it was initially created, as well as last updated.

The format should also allow supplemental content to be added and associated with an entry. This supplemental content could be added the same day, or years later.

The content should accept HTML formatting. Comments from non-authors don’t need to be stored or tracked.

Sample layout

After thinking about these needs, I came up with a structure like this on the 15th. Thus far, I haven’t seen much need to expand it.

  • journal source
    • entry id
      • author
        • name
      • dateCreated
      • dateUpdated
      • text
      • supplements
        • supplement id
          • dateAdded
          • text

Explanation of elements

The journal element is what ties it all together. It has a source attribute, which ties all individual journals, from a particular source (hence the name), to a single URI. The source could be a site, service, or person, although each entry could be associated with someone.

Within the journal element is one or more entry elements, which have a unique id attribute. When designing, I envisioned this as GUID (modelling after BlogEngine.NET, with GUIDs being assigned to each post). I also saw each entry being a daily addition. Either way, once a core entry is created (the text element), I didn’t see that it (the core entry text) would be updated any further.

There’s an author element next, which currently stores a name, but could be extended to include an email, Web site, and etcetera.

The next two date elements are fairly obvious, with the first being permanent, and the second being set to the first when the entry is initially created, then updated as each supplement is added.

The text element - which was initially called entry before adding the parent - stores the HTML content of the entry. Again, outside of minor edits, I don’t see this content as changing, much like an actual paper journal.

The supplements element contains one or more supplement elements. These have a dateAdded element, but no element to store an update date. It also has an id attribute (an addition from what I intially outlined on paper), which is just an increasing number, from 1 up, unique to the entry. Like the core entry, it has a text element that stores HTML content of the addition.

The supplements are meant to add additional notes or comments to the original entries, by the author of the original. Again, I did not envision this having any commenting, outside of that by the author.

I also initially saw each entry as being within its own file, but after further thought, believe that a single file could store a month or year’s worth of entries.

Next steps

Before starting on the schema itself I want to research XInclude, to determine whether this would work for pulling multiple entries into a single core XML document. Depending upon what that suggests will determine how the base layout changes, if at all.

Update: XInclude research

Not per se an update for users, since the post is scheduled for the day after I actually wrote it, but …

While my editor, <oXygen> XML Editor, supports XInclude, for the purposes of this schema I don’t believe XInclude is going to be all that helpful.

It might just be that the source referred to will have to handle the individual journal files, however it sees fit. This allows each entry to be either a single entity or contain a number of entries, depending upon the needs and use of the individual author(s).

If you’re interested, here’s the source I used. Pulling this up in Internet Explorer 8.0, as is, doesn’t display it as I would expect, but Author mode in <oXygen/> XML Editor displays it correctly.


<?xml version=“1.0” encoding=“UTF-8”?>
<testParent xmlns:xi=”http://www.w3.org/2001/XInclude“>
    <xi:include href=“child1.xml”/>
    <xi:include href=“child2.xml”/>
    <xi:include href=“child3.xml”/>


The same content was used for each of the three.

<?xml version=“1.0” encoding=“UTF-8”?>