wiki:XML_File_Format

We need to change eXe's native file format into XML. But we need to discuss how this will work/look before just leaping into it.

At first we were going to do our own XML format such as the below example, however now the plan is to make EXE's native format IMS compliant.

Non IMS compliant XML Example

A Package/Course? would be saved in an XML document. With a format similar to this:

<package name=”myPackage” author=”Matthew Sherborne”
         exeversion=”2.0” fileformatversion=”1” etc..>
  <node shorttitle=”Chapter 1” longtitle=”A new beginning”>
     <idevice id=”Cloze Idevice” title=”A cloze IDevice”>
       <field id=”Static Text” title=”Learner Instructions”>
         <contents>
           <CDATA[[
             <p>Fill in the <i>missing</i> words<p>
           ]]>
         </contents>
       </field>
       <field id=”Cloze”>
         <contents>
           <CDATA[[
             <p>Mary had a little <u>lamb</u></p>
           ]]>
         </contents>
       </field>
       <field id=”Feedback”>
         <contents>
           <CDATA[[
             Well done!
           ]]>
         </contents>
       </field>
     </idevice>
     ...
     <node shorttitle=”Section 1” longtitle=”I'm a sub node”>
       ...
     </node>
   </node>
   ...
</package>

Previous Work

We had a 99% working XML export before. It was just hanging up on the evilness of the SCORM quiz and multichoice quiz question classes. The other disadvantage was that it used nevow, which we now consider evil also.

There's a ticket for it: http://exelearning.org/projects/exe1/ticket/673

Here's how we did it before:

STAN

We used nevow's stan, which allows the user to write XML inside of python without making errors like forgetting to close tags. For example::

 html[
   head[]
   body(onload='dosomething')[
     h1[Hello]
   ]
 ]

is rendered as:

  <html>
    <head/>
    <body onload="dosomething">
       <h1>Hello</h1>
    </body>
  </html>

So basically it uses classes with overridden operators; in python call (brackets) with keyword args set XML attributes and lists ([]) are used for opening tag and closing tags.

Module Changes

We added an extra module called exe.engine.xml which included stan classes for our special tags like package and node etc. Unfortunately I can't seem to find this file anymore.

So Package.savemime is where the whole process starts.

OK. Jim just told me that we're going to go about it next time in an entirely different way, so I'll stop documenting the old way here.

New Way

We're going to hack into the export/imsexport.py and include the data for idevices in invisible <div>'s.

For import we'll select a nice python XML lib. Hopefully one that supports xpath so we can go something like:

   dom = parse(page)
   ideviceDivs = dom.xpath('.//div[@style="visibility: collapse"]')
   for idDiv in ideviceDivs:
       for fieldDiv in ideviceDivs.xpath('./div[@
Last modified 10 years ago Last modified on 2009-05-22T06:13:22+09:00