Index: ruby/trunk/lib/open_ehr/serializer.rb
===================================================================
--- ruby/trunk/lib/open_ehr/serializer.rb	(revision 409)
+++ ruby/trunk/lib/open_ehr/serializer.rb	(revision 410)
@@ -182,4 +182,23 @@
       end
 
+      def definition
+        definition = ''
+        ad = @archetype.definition
+        xml = Builder::XmlMarkup.new(:indent => 2, :target => definition)
+        xml.definition do
+          xml.rm_type_name ad.rm_type_name
+          xml.occurrence do
+            oc = ad.occurrences
+            xml.lower_included oc.lower_included? unless oc.lower_included?.nil?
+            xml.upper_included oc.upper_included? unless oc.upper_included?.nil?
+            xml.lower_unbounded oc.lower_unbounded?
+            xml.upper_unbounded oc.upper_unbounded?
+            xml.lower oc.lower
+            xml.upper oc.lower
+          end
+          xml.node_id ad.node_id
+        end
+      end
+
       def merge
 
Index: ruby/trunk/spec/lib/open_ehr/serializer/adl-test-entry.most_minimal.test.adl
===================================================================
--- ruby/trunk/spec/lib/open_ehr/serializer/adl-test-entry.most_minimal.test.adl	(revision 410)
+++ ruby/trunk/spec/lib/open_ehr/serializer/adl-test-entry.most_minimal.test.adl	(revision 410)
@@ -0,0 +1,20 @@
+archetype (adl_version=1.4)
+    adl-test-ENTRY.most_minimal.draft
+concept
+    [at0000]
+language
+    original_language = <[ISO_639-1::en]>
+definition
+    ENTRY[at0000] matches {*} 
+ontology
+    term_definitions = <
+        ["en"] = <
+            items = <
+                ["at0000"] = <
+                    text = <"most minimal">
+                    description = <"most minimal">
+                >
+            >
+        >
+    >
+
Index: ruby/trunk/spec/lib/open_ehr/serializer/openEHR-EHR-SECTION.test.v1.xml
===================================================================
--- ruby/trunk/spec/lib/open_ehr/serializer/openEHR-EHR-SECTION.test.v1.xml	(revision 410)
+++ ruby/trunk/spec/lib/open_ehr/serializer/openEHR-EHR-SECTION.test.v1.xml	(revision 410)
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archetype xmlns="http://schemas.openehr.org/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <archetype_id>
+    <value>openEHR-EHR-SECTION.test.v1</value>
+  </archetype_id>
+  <concept>at0000</concept>
+  <original_language>
+    <terminology_id>
+      <value>ISO_639-1</value>
+    </terminology_id>
+    <code_string>ja</code_string>
+  </original_language>
+  <description>
+    <original_author id="name">Shinji KOBAYASHI</original_author>
+    <original_author id="organisation">openEHR.jp</original_author>
+    <original_author id="email">skoba@moss.gr.jp</original_author>
+    <lifecycle_state>draft</lifecycle_state>
+    <details>
+      <language>
+        <terminology_id>
+          <value>ISO_639-1</value>
+        </terminology_id>
+        <code_string>ja</code_string>
+      </language>
+      <purpose>Serializer test</purpose>
+      <misuse>evaluate message</misuse>
+    </details>
+  </description>
+  <definition>
+    <rm_type_name>SECTION</rm_type_name>
+    <occurrence>
+      <lower_unbounded>false</lower_unbounded>
+      <upper_unbounded>false</upper_unbounded>
+      <lower>1</lower>
+      <upper>1</upper>
+    </occurrence>
+    <node_id>at0000</node_id>
+  </definition>
+  <ontology>
+    <specialisation_depth>0</specialisation_depth>
+    <term_definitions>
+      <language>ja</language>
+      <terms>
+        <code>at0000</code>
+        <items>
+          <item>
+            <key>text</key>
+            <value>simple test</value>
+          </item>
+          <item>
+            <key>description</key>
+            <value>simple test for serializer</value>
+          </item>
+        </items>
+      </terms>
+    </term_definitions>
+  </ontology>
+</archetype>
Index: ruby/trunk/spec/lib/open_ehr/serializer/xml_serializer_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/serializer/xml_serializer_spec.rb	(revision 409)
+++ ruby/trunk/spec/lib/open_ehr/serializer/xml_serializer_spec.rb	(revision 410)
@@ -6,4 +6,19 @@
 describe XMLSerializer do
   it_should_behave_like 'sample archetype'
+
+  before(:all) do
+    current_dir = File.dirname(__FILE__)
+    xml_file = File.open(current_dir + '/openEHR-EHR-SECTION.test.v1.xml')
+    xml = xml_file.readlines
+    class << xml
+      def unindent(s,e,num)
+        self[s..e].collect{|line| line[num..-1]}.join
+      end
+    end
+    @sample_header = xml.unindent(2, 11, 2)
+    @sample_description = xml.unindent(12, 27, 2)
+    @sample_definition = xml.unindent(28, 37, 2)
+    xml_file.close
+  end
 
   before(:each) do
@@ -16,40 +31,17 @@
 
   it 'should return XML formatted header' do
-    @xml_serializer.header.should == <<END
-<archetype_id>
-  <value>openEHR-EHR-SECTION.test.v1</value>
-</archetype_id>
-<concept>at0000</concept>
-<original_language>
-  <terminology_id>
-    <value>ISO_639-1</value>
-  </terminology_id>
-  <code_string>ja</code_string>
-</original_language>
-END
+    @xml_serializer.header.should == @sample_header
   end
 
   it 'should return XML formatted description' do
-    @xml_serializer.description.should == <<END
-<description>
-  <original_author id="name">Shinji KOBAYASHI</original_author>
-  <original_author id="organisation">openEHR.jp</original_author>
-  <original_author id="email">skoba@moss.gr.jp</original_author>
-  <lifecycle_state>draft</lifecycle_state>
-  <details>
-    <language>
-      <terminology_id>
-        <value>ISO_639-1</value>
-      </terminology_id>
-      <code_string>ja</code_string>
-    </language>
-    <purpose>Serializer test</purpose>
-    <misuse>evaluate message</misuse>
-  </details>
-</description>
-END
+    @xml_serializer.description.should == @sample_description
   end
 
-  it 'should return XML formatted definition'
+  it 'should return XML formatted definition' do
+    @xml_serializer.definition.should == @sample_definition
+  end
 
+  def unindent(lines,n)
+    return lines.collect{|line| line[n..-1]}.join
+  end
 end
