XML Question

I’m pretty much a “n00b” when it comes to XML and defining domian specific languages, but I have a problem and I think XML is the right solution. So, I’m writing up my question here on my blog so I can point to this post when I ask people for help. Here it goes …

I want to define a format for a text file that will allow me to quickly create a series of questions for a questionnaire. Once defined I intend to write a program (in Ruby) that will parse my text files and create questionnaires in HTML or PDF. At the most basic level, the text file might look like this:

Start Questionnaire
Q: Where were you born?
Select one
Wiscosnin
Outside Wisconsin
Unknown
Q: Which device(s) do you own?
Select all that apply
TV
Automobile, van, truck or motorcycle
Personal computer
Home
Red plastic dinosaur
Q: When do you leave for work?
Enter time
End Questionnaire

A more XML-esque file might look more like this:

<questionnaire>
  <question>
    <question-id>A13C76</>
    <question-number>1</>
    <pre-question>Knowing where you were born is important when determining benefits.</>
    <question-text>Were you born in the United States?</>
    <answer type="radio" text="Select One">
      <answer-option>Yes</>
      <answer-option>No</>
      <answer-option>Unknown</>
    </answer>
  </question>
</questionnaire>

Assume I need to create many dozens of these questionnaires on a regular basis.

My questions to the XML/DSL experts out there are:

  • How can I find out if someone has already created a schema for asking questions and providing answer options?
  • If I want to parse these text files into HTML forms using Ruby, is XML the way to go?
  • Is there a better way to do all of this?

Any answers or thoughts will be greatly appreciated! And, thanks in advance for your help.

1 thought on “XML Question

Comments are closed.