ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Simon Pepping <spepping@scaprea.hobby.nl>
Subject: Re: XML Processing
Date: Wed, 21 May 2003 21:56:34 +0200	[thread overview]
Message-ID: <20030521195634.GA799@scaprea> (raw)
In-Reply-To: <04E6633D-8AE1-11D7-B2FC-0003935A6512@indiana.edu>

On Tue, May 20, 2003 at 01:35:08PM -0300, Alexandre Enkerli wrote:
> Hello all,
> 
> Here's the basic structure of the data I want to process:
> 	<question>
> 		<text></text>
> 		<choices>
> 			<choice></choice>
> 		</choices>
> 		<answer></answer>
> 		<info>
> 			<difficulty></difficulty>
> 			<reference></reference>
> 			<text-objective></text-objective>
> 		</info>
> 	</question>
> 
> In LaTeX terminology (sorry!) what I want is to have all the question 
> texts as items in an "enumerate" and answer choices in an alphabetical 
> enumerate for each question. Doesn't sound too hard. In fact, I guess I 
> could probably do a find and replace...

You should write proper callbacks for each element:

\defineXMLenvironment[text]
	{start action}
	{stop action}

It is easy if you want the text of the query italic with a 'Q.' before
it:

\defineXMLenvironment[text]
	{\bgroup Q. \bf}
	{\egroup}

You can also easily start a list:

\defineXMLenvironment[choices]
	{\startitemize}
	{\stopitemize}
\defineXMLcommand[choice]
	{\item}

But collecting all queries together and all answers together, or
sorting the choices alphabetically, sounds pretty hard. You would have
to save them all in appropriate data structures, and then print them
out as desired. The context code has examples which show that this can
be done in TeX macro code, but it is certainly not easy. As per
Berend's suggestion, XSLT is a much better tool for this task. Then
write a context mapping for the properly sorted XML file.

Good luck, Simon

-- 
Simon Pepping
email: spepping@scaprea.hobby.nl

  parent reply	other threads:[~2003-05-21 19:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-20 16:35 Alexandre Enkerli
2003-05-21  8:11 ` Berend de Boer
2003-05-21 19:56 ` Simon Pepping [this message]
2003-05-21 20:12 ` Johannes Hüsing
2003-05-23 12:46   ` Hans Hagen
  -- strict thread matches above, loose matches on Subject: below --
2011-12-31 20:55 xml processing Meer, H. van der
2012-01-01 12:14 ` Hans Hagen
2002-08-26 11:33 XML processing Robbie Pickering
2002-08-26 14:40 ` Hans Hagen
2002-08-26 18:53 ` Simon Pepping
2002-08-26 19:25   ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030521195634.GA799@scaprea \
    --to=spepping@scaprea.hobby.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).