<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2314.1000" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=240074008-23091999>I find
this way surprising. Yes, it's clear that opening and closing tags compress
well, but I would still have expected the attribute version to be
smaller...</SPAN></FONT></DIV>
<DIV> </DIV>
<P><FONT size=2>--<BR>Julian F. Reschke (<A
href="mailto:reschke@medicaldataservice.de"
target=_blank>mailto:reschke@medicaldataservice.de</A>)<BR>MedicalData Service
GmbH Münster, Germany </FONT></P>
<BLOCKQUOTE
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
<DIV align=left class=OutlookMessageHeader dir=ltr><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> owner-xml-dev@ic.ac.uk
[mailto:owner-xml-dev@ic.ac.uk]<B>On Behalf Of </B>Mark Nutter<BR><B>Sent:</B>
Wednesday, September 22, 1999 7:26 PM<BR><B>To:</B>
xml-dev@ic.ac.uk<BR><B>Subject:</B> RE: RFC: Attributes and
XML-RPC<BR><BR></DIV></FONT>At 12:16 PM 09/22/99 -0400, Hunter, David
wrote:<BR>
<BLOCKQUOTE cite type="cite">So even if you<BR>compress the files, the
attribute version will be able to compress to 50%<BR>smaller than the other
file. Again, 2KB isn't a lot, but if we're talking<BR>megabytes in
size, 50% is a lot.</BLOCKQUOTE><BR>I wrote a quick perl script to take
/usr/dict/words and turn it into an XML file, with some artificially generated
"attributes". In the resulting file named attrib.xml, each <word>
tag contains the additional information as attributes. I did the same
thing to produce a file called child.xml, except that the additional
information is presented as a child element instead of as an attribute.
Here are the results:<BR><BR><TT>$ ./make.pl<BR>$ ls -l<BR>total
13004<BR>-rw-rw-r-- 1 mnutter mnutter 5811852
Sep 22 13:16 attrib.xml<BR>-rw-rw-r-- 1 mnutter
mnutter 7445892 Sep 22 13:16 child.xml<BR>-rwxr-xr-x 1
mnutter mnutter 976 Sep 22 13:16
make.pl<BR>$ gzip attrib.xml<BR>$ gzip child.xml<BR>$ ls -l<BR>total
1127<BR>-rw-rw-r-- 1 mnutter mnutter
671039 Sep 22 13:16 attrib.xml.gz<BR>-rw-rw-r-- 1 mnutter
mnutter 472394 Sep 22 13:16
child.xml.gz<BR>-rwxr-xr-x 1 mnutter
mnutter 976 Sep 22 13:16
make.pl<BR><BR></TT>I used gzip as an example of off-the-shelf compression
technology. As you can see, even though the raw child.xml file is
larger, the compressed version is *smaller* than the corresponding
implementation with attributes.<BR><BR>This may not be true in all cases, of
course, but I expect it often will, due to the way such compression algorithms
work.<BR><BR>For your reference, here is the Perl script I used to create the
two files:<BR><BR>open WORDS, "</usr/dict/words" or die "Couldn't open
dictionary.\n";<BR>open ATTRIB, ">attrib.xml" or die "Couldn't open
attrib.xml\n";<BR>open CHILD, ">child.xml" or die "Couldn't open
child.xml\n";<BR><BR>@twenty_strings = qw(one two three four five six seven
eight nine
ten<BR>
eleven twelve thirteen fourteen fifteen
sixteen<BR>
seventeen eighteen nineteen twenty);<BR><BR>print ATTRIB
"<attrib>\n";<BR>print CHILD "<child>\n";<BR><BR>while($word =
<WORDS>)<BR>{<BR> $time =
time();<BR> $timestr =
localtime($time);<BR> $twenty = rand %
20;<BR> $twentystr =
$twenty_strings[$twenty];<BR> print ATTRIB
<<EOM;<BR> <word time="$time" timestr="$timestr"
twenty="$twenty"<BR>
twentystr="$twentystr">$word</word><BR>EOM<BR>
print CHILD <<EOM;<BR> <word><BR>
<time>$time</time><BR>
<timestr>$timestr</timestr><BR>
<twenty>$twenty</twenty><BR>
<twentystr>$twentystr</twentystr><BR>
</word><BR>EOM<BR>}<BR><BR>print ATTRIB "</attrib>\n";<BR>print
CHILD "</child>\n";<BR><BR>close CHILD;<BR>close ATTRIB;<BR>close
WORDS;<BR><BR><BR>
<DIV>-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-</DIV><BR>
<DIV>Mark Nutter, <mnutter@fore.com></DIV>
<DIV>Internet Applications Developer</DIV>
<DIV>FORE Systems</DIV>
<DIV>Some people are atheists 'til the day they
die.</DIV></BLOCKQUOTE></BODY></HTML>