Saturday, March 14, 2009

An XML Schema Declaration for a Sermon

Just something I've been working on for a project (I DO do more than blog, you know). Anyway, the following is code I've developed to try to put together an XML schema defining a sermon. Any ideas?

I know that, theoretically, OSIS could be employed to encode a sermon, but that's not a very satisfying solution. Sermons have elements peculiar to sermons. A good XML representation of a sermon should know the difference between a point and a conclusion.

I only took two preaching classes in seminary, and they were a long time ago. I may very well have missed something important. So if this code is helpful to you, then I'm glad for you to use it so long as you give me credit. And if you can help me make this code better, I welcome the help.


<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Sermon"
    targetNamespace="http://tempuri.org/Sermon.xsd"
    elementFormDefault="qualified"
    xmlns="http://tempuri.org/Sermon.xsd"
    xmlns:mstns="http://tempuri.org/Sermon.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:osis="http://www.bibletechnologies.net/2003/OSIS/namespace"
>
  <xs:import id="osis" namespace="http://www.bibletechnologies.net/2003/OSIS/namespace" 
             schemaLocation="http://www.bibletechnologies.net/osisCore.2.1.1 - 06March2006.xsd"
             />
  
  
  <!--Definition of simple elements-->
  <xs:element name="author" type="xs:token"/>
  <xs:element name="version" type="xs:positiveInteger"/>
  <xs:element name="decisions" type="xs:nonNegativeInteger"/>
  <xs:element name="title" type="xs:token"/>
  <xs:element name="text" type="xs:token"/>
  <xs:element name="centralIdeaOfText" type="xs:string"/>
  <xs:element name="thesis" type="xs:string"/>
  <xs:element name="objective">
    <xs:complexType mixed="true">
      <xs:attribute ref="majorObjective"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="createdDate" type="xs:date"/>
  <xs:element name="occasionStart" type="xs:dateTime"/>
  <xs:element name="location" type="xs:token"/>
  <xs:element name="description" type="xs:string"/>
  <xs:element name="occasionsPreached" type="preachingOccasion"/>
  
  <!--Definition of attributes-->
  <xs:attribute name="majorObjective" default="Evangelistic">
    <xs:simpleType>
      <xs:restriction base="xs:token">
        <xs:enumeration value="Evangelistic"/>
        <xs:enumeration value="Consecrative"/>
        <xs:enumeration value="Ethical"/>
        <xs:enumeration value="Doctrinal"/>
        <xs:enumeration value="Supportive"/>
        <xs:enumeration value="Devotional"/>
        <xs:enumeration value="Programmatic"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:attribute>

  <xs:attribute name="reference" type="xs:token"/>
  <xs:attribute name="translation" type="xs:token" default="NASB"/>
  
  <!--Definition of complex elements-->
  <!--Sermon Header-->
  <xs:element name="head">
    <xs:complexType mixed="true">
      <xs:sequence minOccurs="1" maxOccurs="1">
        <xs:element ref="author" maxOccurs="1" minOccurs="1"/>
        <xs:element ref="text" maxOccurs="1" minOccurs="1"/>
        <xs:element ref="title" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="centralIdeaOfText" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="thesis" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="objective" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="createdDate" maxOccurs="1" minOccurs="1"/>
        <xs:element ref="occasionsPreached" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <!--Abstract Elements-->
  <xs:element name="inlineElement" abstract="true">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="inlineElement"/>
        <xs:element ref="blockElement"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:element name="blockElement" abstract="true">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="inlineElement"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>
  
  <!--Content Elements-->
  <xs:element name="p" substitutionGroup="blockElement"/>
  <xs:element name="em" substitutionGroup="inlineElement"/>
  <xs:element name="i" substitutionGroup="inlineElement"/>
  <xs:element name="strong" substitutionGroup="inlineElement"/>
  <xs:element name="b" substitutionGroup="inlineElement"/>

  <xs:element name="blockquote">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="blockElement"/>
        <xs:element ref="inlineElement"/>
        <xs:element ref="ul"/>
        <xs:element ref="ol"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:element name="li">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="blockElement"/>
        <xs:element ref="blockquote"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:element name="ul">
    <xs:complexType mixed="false">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="li"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:element name="ol">
    <xs:complexType mixed="false">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="li"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:element name="explanation">
    <xs:complexType mixed="true">
      <xs:complexContent>
        <xs:extension base="blockElementContainer">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="inlineElement"/>
          </xs:choice>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="illustration">
    <xs:complexType mixed="true">
      <xs:complexContent>
        <xs:extension base="blockElementContainer">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="inlineElement"/>
          </xs:choice>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="application">
    <xs:complexType mixed="true">
      <xs:complexContent>
        <xs:extension base="blockElementContainer">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="inlineElement"/>
          </xs:choice>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="transition">
    <xs:complexType mixed="true">
      <xs:complexContent>
        <xs:extension base="blockElementContainer">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="inlineElement"/>
            <xs:element ref="application"/>
            <xs:element ref="explanation"/>
            <xs:element ref="illustration"/>
            <xs:element ref="scriptureReference"/>
          </xs:choice>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="point">
    <xs:complexType mixed="true">
      <xs:sequence minOccurs ="1" maxOccurs="1">
        <xs:element ref="pointStatement"/>
        <xs:choice minOccurs ="0" maxOccurs="unbounded">
          <xs:element ref="blockElement"/>
          <xs:element ref="inlineElement"/>
          <xs:element ref="pointGroup"/>
          <xs:element ref="explanation"/>
          <xs:element ref="illustration"/>
          <xs:element ref="application"/>
          <xs:element ref="transition"/>
          <xs:element ref="ol"/>
          <xs:element ref="ul"/>
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="pointStatement" type="xs:string"/>

  <xs:element name="pointGroup">
    <xs:complexType mixed="false">
      <xs:choice minOccurs ="0" maxOccurs="unbounded">
        <xs:element ref="point"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:element type="osis:osisCT" name="scriptureReference" />
  
  <xs:element name="introduction" substitutionGroup="transition"/>
  <xs:element name="conclusion" substitutionGroup="transition"/>

  <xs:element name="body">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="transition"/>
        <xs:element ref="pointGroup"/>
        <xs:element ref="inlineElement"/>
        <xs:element ref="blockElement"/>
        <xs:element ref="ol"/>
        <xs:element ref="ul"/>
        <xs:element ref="scriptureReference"/>
        <xs:element ref="explanation"/>
        <xs:element ref="illustration"/>
        <xs:element ref="application"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:element name="sermonBody" substitutionGroup="body"/>

  <!--Definition of complex types-->
  <xs:complexType name="preachingOccasion">
    <xs:all>
      <xs:element ref="description"/>
      <xs:element ref="location"/>
      <xs:element ref="occasionStart"/>
      <xs:element ref="decisions"/>
    </xs:all>
  </xs:complexType>

  <xs:complexType name="blockElementContainer" mixed="true">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element ref="blockElement"/>
      <xs:element ref="blockquote"/>
      <xs:element ref="ul"/>
      <xs:element ref="ol"/>
      <xs:element ref="pointGroup"/>
    </xs:choice>
  </xs:complexType>
  
  <!--Definition of root element-->
  <xs:element name="sermon">
    <xs:complexType mixed="true">
      <xs:sequence minOccurs="1" maxOccurs="1">
        <xs:element ref="head"/>
        <xs:element ref="body"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

©2009 C. Bart barber

11 comments:

Dave Miller said...

Does that qualify as a Private Prayer Language?

Bart Barber said...

No. This actually means something.

Dave Miller said...

I guess I need an interpretation of tongues.

I feel challenged just putting a post up. I am too old to be a programmer.

Joe Blackmon said...

My response to this post (in the only programming language I was ever familiar with)

10 PRINT"I HAVE NO IDEA WHAT I JUST READ"
20 GOTO 10

volfan007 said...

Looks like a great sermon!

David

:)

Anonymous said...

Bart, I think we can safely say that when this sermon is all fleshed out, that the local restaurants will all be closed so everyone needs to be very sure they have some coldcuts ready to toss together at home. :)

God gave you too many brains. It just ain't fair. selahV

Les said...

We need a punchline for "How many Mensa'a does it take to write a sermon?"

Bart Barber said...

I'm sorry, folks. I used to have some computer savvy people who read over here. I think they've all moved on. One guy was a C# programmer.

Anyway, I didn't mean to put something up that was completely irrelevant to my readers. My profound apologies.

Anonymous said...

Don't apologize. Anytime you give the rest of us a chance to tease smart people, it's a ministry.

Joe Blackmon said...

Bart

Dude, don't appologize.

joe

Anonymous said...

Bart, apologies are highly overrated anyway. don't bother. selahV :)