comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <bauhaus@futureapps.de>
Subject: Re: Data table text I/O package?
Date: Thu, 23 Jun 2005 00:24:30 +0200
Date: 2005-06-23T00:24:43+02:00	[thread overview]
Message-ID: <42b9e52a$0$15427$9b4e6d93@newsread2.arcor-online.net> (raw)
In-Reply-To: <5k89l0blbw5m.tlbbgh2pji8x.dlg@40tude.net>

Dmitry A. Kazakov wrote:


> But for data exchange there are better techniques than XML.

Such as ...?

> Then you cannot talk about numbers transferred. You said "3.15" is a text.
> So let it be a text. "3.1 5" is also a text, as valid as "3.15" [at this
> level of abstraction.]

How is a number transfered from one human to another?
How do you explain the number three to a person who
cannot see?


> [sending two literals instead of one]
> The true value is always within the bounds. There is still a
> problem, but a much lesser one.

I don't agree because you are actually introducing two intervals.
And mine might be different from yours anyway. So why not use "3.15"
as per the needs of the application?

> Relevant errors are only ones made by humans.

Ahh, no. Think of the last time you have been watching satellite
TV with a strong cloud in the way. Where is your nice data stream...
(No I'm not suggesting XML here, of course, but satellites aren't
just used for MPEG streams. They can transmit XML data too.)

> [I don't talk about writing, because to write
> in XML is beyond anybody's capability anyway.]

I suggest you have a look at oXygen or nXML mode for Emacs,
or PSGML mode for Emacs. (Serna is also nice,
though it is, uhm, stabilizing.)
They all provide functions similar to a good programmer's IDE,
analysing source text to help you with typing, inserting
completions automatically, running the validator in the
background etc.

(In fact, XML lends itself well to syntax directed editing,
whether you see the tags or not. :-))


> Humans are unbeatable in pattern recognition. This is whole idea behind
> tables. Tab stops and lines are very easy patterns to detect and any error
> becomes immediately visible long before inspecting the table contents.

Right. So next time someone sends you an HTML table full of data,
use this for a start, to get a nice plain text table. (It's verbose,
I know :)

<?xml version='1.0' encoding='UTF-8'?>
<transform
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.w3.org/1999/XSL/Transform"
   version="1.0">

  <!-- Transforms an XHTML table into a plain text table.

Input: An XHTML document containing tables.
Output: A text document containing tables.

The tables should contain small portions of text in their cells, for
example matrix data or some tabular array of small strings.

The default width of columns in this transformation is 8, see "pad". -->

  <output method="text"/>

  <param name="my-line-terminator">
    <!--
      do not use system defaults for terminating lines.
      Use these characters instead. See new-line.
      -->
    <text>&#13;&#10;</text>
  </param>



  <template match="/">
    <!-- insert some empty lines and then start the plain text table -->
    <for-each select="descendant::table">
      <call-template name="new-line">
        <with-param name="count">2</with-param>
      </call-template>
      <apply-templates select="tbody"/>
    </for-each>
  </template>


  <template match='tbody'>
    <!-- print the head, then a separating line, then the rows -->
    <apply-templates select="tr/th"/>
    <call-template name="new-line"/>
    <text>================================================</text>
    <for-each select="tr">
      <apply-templates select="td"/>
      <call-template name="new-line"/>
    </for-each>
  </template>


  <template match="td | th">
    <!-- place the text content inside a cell padded with blanks -->
    <call-template name="pad">
      <with-param name="characters">
        <apply-templates/>
      </with-param>
    </call-template>
  </template>


  <template match="td//*">
    <!-- inside a table cell, discard everything but text -->
    <value-of select="text()"/>
  </template>


  <template name='pad'>
    <param name="characters"/>
    <!-- the text to which padding blanks might be added -->

    <param name="default-width">8</param>
    <!-- default column width measured in number of characters -->

    <variable name="fill"
              select="$default-width - string-length($characters)"/>
    <choose>
      <when test="$fill &lt; 0">
        <message>Please choose a wider display</message>
      </when>
      <otherwise>
        <value-of select="$characters"/>
        <value-of select=" substring('        ',  1, $fill)"/>
      </otherwise>
    </choose>
  </template>


  <template name="new-line">
    <!-- 1 or more lines will be terminated -->
    <param name="count">1</param>

    <if test="$count &gt; 0">
      <value-of select="$my-line-terminator"/>
      <call-template name="new-line">
        <with-param name="count">
          <value-of select="$count - 1"/>
        </with-param>
      </call-template>
    </if>
  </template>

</transform>




  reply	other threads:[~2005-06-22 22:24 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-15  9:57 Data table text I/O package? Jacob Sparre Andersen
2005-06-15 11:43 ` Preben Randhol
2005-06-15 13:35   ` Jacob Sparre Andersen
2005-06-15 14:12     ` Preben Randhol
2005-06-15 15:02       ` Jacob Sparre Andersen
2005-06-15 16:17         ` Preben Randhol
2005-06-15 16:58           ` Dmitry A. Kazakov
2005-06-15 17:30             ` Marius Amado Alves
2005-06-15 18:41               ` Dmitry A. Kazakov
2005-06-15 19:09                 ` Marius Amado Alves
2005-06-15 18:58         ` Randy Brukardt
2005-06-16  9:55           ` Jacob Sparre Andersen
2005-06-16 10:53             ` Marius Amado Alves
2005-06-16 12:24               ` Robert A Duff
2005-06-16 14:01               ` Georg Bauhaus
2005-06-16 12:27                 ` Dmitry A. Kazakov
2005-06-16 14:46                   ` Georg Bauhaus
2005-06-16 14:51                     ` Dmitry A. Kazakov
2005-06-20 11:19                       ` Georg Bauhaus
2005-06-20 11:39                         ` Dmitry A. Kazakov
2005-06-20 18:25                           ` Georg Bauhaus
2005-06-20 18:45                             ` Preben Randhol
2005-06-20 18:54                             ` Dmitry A. Kazakov
2005-06-21  9:24                               ` Georg Bauhaus
2005-06-21  9:52                                 ` Jacob Sparre Andersen
2005-06-21 11:10                                   ` Georg Bauhaus
2005-06-21 12:35                                     ` Jacob Sparre Andersen
2005-06-21 10:42                                 ` Dmitry A. Kazakov
2005-06-21 11:41                                   ` Georg Bauhaus
2005-06-21 12:44                                     ` Dmitry A. Kazakov
2005-06-21 21:01                                       ` Georg Bauhaus
2005-06-22 12:15                                         ` Dmitry A. Kazakov
2005-06-22 22:24                                           ` Georg Bauhaus [this message]
2005-06-23  9:03                                             ` Dmitry A. Kazakov
2005-06-23  9:47                                               ` Georg Bauhaus
2005-06-23 10:34                                                 ` Dmitry A. Kazakov
2005-06-23 11:37                                                   ` Georg Bauhaus
2005-06-23 12:59                                                     ` Dmitry A. Kazakov
2005-06-23 14:16                                               ` Marc A. Criley
2005-06-25 16:38                               ` Simon Wright
2005-06-16 13:26                 ` Marius Amado Alves
2005-06-16 18:10                   ` Georg Bauhaus
2005-06-30  3:02             ` Randy Brukardt
2005-06-30 18:43               ` Jacob Sparre Andersen
2005-07-01  1:22                 ` Randy Brukardt
2005-07-01  3:01                   ` Alexander E. Kopilovich
2005-07-01  5:59                     ` Jeffrey Carter
2005-07-02  1:54                     ` Randy Brukardt
2005-07-02 10:24                       ` Dmitry A. Kazakov
2005-07-06 22:04                         ` Randy Brukardt
2005-06-30 19:24               ` Björn Persson
2005-07-01  0:54                 ` Randy Brukardt
2005-07-01 21:36                   ` TSV and CSV Björn Persson
2005-07-01 22:08                     ` Martin Dowie
2005-07-02  0:05                       ` Georg Bauhaus
2005-07-02  1:10                         ` Randy Brukardt
2005-07-02  1:20                           ` Ed
2005-07-03  9:08                           ` Georg Bauhaus
2005-07-02  0:07                   ` Data table text I/O package? Georg Bauhaus
2005-07-02  1:21                     ` Randy Brukardt
     [not found]     ` <20050615141236.GA90053@pvv.org>
2005-06-15 15:40       ` Marius Amado Alves
2005-06-15 19:18         ` Oliver Kellogg
2005-06-17  9:02           ` Jacob Sparre Andersen
     [not found]       ` <7adf1648bb99ca2bb4055ed8e6e381f4@netcabo.pt>
2005-06-15 15:46         ` Preben Randhol
     [not found]         ` <20050615154640.GA1921@pvv.org>
2005-06-15 16:14           ` Marius Amado Alves
     [not found]           ` <f04ccd7efd67fe197cc14cda89340779@netcabo.pt>
2005-06-15 16:20             ` Preben Randhol
2005-06-15 19:30 ` Simon Wright
2005-06-15 22:40 ` Lionel Draghi
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox