On Sun, 16 Nov 2003 03:44:10 GMT, Scott Zuyderduyn <sc******@hotmail.com> wrote:
Yes, a compact form is pragmatic, but idealistically it's a departure I
would think. Shouldn't anything more than a simple data type really be
described in XML?
Not necessarily. I've read in books about SGML that the creators freely
acknowledge that SGML is not the best way to store all types of data.
Being able to drop to a more specific, non-SGML syntax is useful. The
same is probably true of XML.
For instance, in some software I'm working on for an RPG, we need to be
able to represent random die rolls. It is possible to break it down to
something like
<roll>
<diecount>2</diecount>
<diesize>8</diesize>
<modifier>-2</modifier>
</roll>
but it makes much more sense to do
<roll expression='2d8-2' />
(or more likely, it'd be an attribute of whatever the roll applies to --
<damage roll='2d8-2' />)
I'm not a purist when it comes to XML; I think the amount of effort
needed to understand and use something should be proportional to the
importance of the individual components.
And regular expressions can be so arcane, an XML based
representation might actually be more easily understood if it was done
properly.
That's the rub. It wouldn't be easy. IMO, an RE is most easily
understood if you can *see* the thing. Counting parentheses isn't a big
deal. A complex RE (say, one that runs to one or two hundred
characters) would be a *nightmare* to try to read and understand if done
in XML -- at least, if each term had to be encoded in its own element.
That said, I can see ways to make things a little easier. You might use
allow an RE component to contain the 'arcane' parts but use XML elements
to link them together. For instance, an RE such as:
([A-Za-z]+|[0-9]+)
might be represented something like
<re var='var1'>
<choose>
<re>[A-Za-z]+</re>
<re>[0-9]+</re>
</choose>
</re>
This isn't *too* hideous. It is not nearly as concise as the first, and
mixes technologies. The latter is the bigger problem IMO.
Trying to fully-describe RE in XML would be horribly painful. Go ahead
and fall back on other representations for data where it makes sense;
this is one case.
Keith
--
Keith Davies "Your ability to bang your head against
ke**********@kjdavies.org reality in the hope that reality will
crack first is impressive, but futile"
-- Geoffrey Brent, rec.games.frp.dnd