It may be bad form, but I am going to attach some files for this example. The test provides both a read, write, and compare example.

Here is a really long example, for those who are willing to read it.

To use this example, you would have to have the following source tree:

/src/Tree
                Objects & Betwixt Files
      /Util
                XML Utility File

/test/Tree
                Test Case
                logger.properties

/bin/conf/test
                        questions_test.xml
/bin/logs

Objects:



Utility:

Test:

<fo:questionnaire xmlns:fo="http://fallingonline.com/fo";>
	<fo:questionnaireInfo>
		<fo:questionnaireId>1</fo:questionnaireId>
		<fo:questionnaireNumber>FO001</fo:questionnaireNumber>
		<fo:questionnaireName>Harry Potter Trivia</fo:questionnaireName>
		<fo:questionnaireDesc>A simple example</fo:questionnaireDesc>
	</fo:questionnaireInfo>
	<fo:questionGroup depth="1">
		<fo:question answerRequiredType="A" selectMultipleChildren="true" numAnswerChoices="3" questionText="Who is your favorite teacher?" questionNumber="01" questionId="1">
			<fo:questionGroup depth="2">
				<fo:question answerRequiredType="B" selectMultipleChildren="false" numAnswerChoices="2" questionText="Snape" questionNumber="01.01" questionId="2">
					<fo:questionGroup depth="3">
						<fo:question answerRequiredType="C" selectMultipleChildren="false" numAnswerChoices="3" questionText="Flitwick" questionNumber="01.01.01" questionId="3">
							<fo:questionGroup />
						</fo:question>
					</fo:questionGroup>
				</fo:question>
			</fo:questionGroup>
		</fo:question>
		<fo:question answerRequiredType="A" selectMultipleChildren="true" numAnswerChoices="3" questionText="Where would you find a beasil" questionNumber="02" questionId="4">
			<fo:questionGroup depth="2">
				<fo:question answerRequiredType="C" selectMultipleChildren="false" numAnswerChoices="0" questionText="Under a rock" questionNumber="01.01.01" questionId="5">
					<fo:questionGroup />
				</fo:question>
				<fo:question answerRequiredType="C" selectMultipleChildren="false" numAnswerChoices="0" questionText="In a goat" questionNumber="01.01.01" questionId="6">
					<fo:questionGroup />
				</fo:question>
			</fo:questionGroup>
		</fo:question>
	</fo:questionGroup>
</fo:questionnaire>


On Nov 8, 2005, at 12:13 PM, Richard Sullivan wrote:


Hi Ryan,

thanks for your second reply - unfortunately I am not quite ready to implement it yet :=(

I have tried to create a test project of the Questionnaire example.

I have assumed that the major business rule is that a question can either consist of a question-text or sub-questions.

A question that contains sub-questions will be mapped to an instance of Questions.

The Main.java reads in test1.xml

<?xml version="1.0"?>
<questionnaire id="1">
    <questions id="2">
      <question id="3">
        <questionText>Text of Q1?</questionText>
      </question>
      <questionGroup id="4">
                  <question id="4a">
                        <questionText>Question group 2a?</questionText>
                  </question>
                  <question id="4b">
                        <questionText>Question group 2b?</questionText>
                  </question>
      </questionGroup>
      <question id="5">
        <questionText>Text of Q3?</questionText>
      </question>
      <question id="6">
        <questionText>Text of Q4?</questionText>
      </question>
    </questions>
  </questionnaire>

but doesn't manage to parse the questionGroup element as I would wish.
The output is

<?xml version="1.0"?>
 <questionnaire id="1">
    <info title="no title" version="1.0" id="2"/>
    <questions id="3">
      <question id="4">
        <questionText>Text of Q1?</questionText>
      </question>
      <question id="5">
        <questionText>Text of Q3?</questionText>
      </question>
      <question id="6">
        <questionText>Text of Q4?</questionText>
      </question>
    </questions>
  </questionnaire>

The debugger shows that it did create a Question object but wasn't able to fill the collection properly.


Any ideas?

Thanks,
Richard

______________________________________________________________________ ____ Erweitern Sie FreeMail zu einem noch leistungsstärkeren E-Mail- Postfach!
Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131

<questionnaire.zip>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to