Re: read-entity, is there any example or use explication?

Subject: Re: read-entity, is there any example or use explication?
From: James Clark <jjc@xxxxxxxxxx>
Date: Thu, 03 Sep 1998 18:04:06 +0700
Norman Walsh wrote:
> 
> / miguel.mata@xxxxxxxxxx was heard to say:
> | Hi, I don't know how can I use read-entity to access datas from another
> | file, do you know it?, or have you any example?
> 
> From my DocBook stylesheets, v1.13:
> 
> (define ($include$ fileref)
>   (let* (;; Yes, the next line really ends with "#", "\", "[newline]"
>          (newline #\
> )
>          (file-content  (read-entity fileref))
>          (file-charlist (string->list file-content))
>          (file-length   (length file-charlist))
>          (file-headlist (list-head file-charlist (- file-length 1)))
>          (file-taillist (list-tail file-charlist (- file-length 1)))
>          ;; If the last char is a newline, drop it, otherwise print it...
>          (content (if (equal? newline (car file-taillist))
>                       (list->string file-headlist)
>                       file-content)))
>     (make sequence
>       (literal content))))
> 
> All that hackery about the last character is to avoid an extra linefeed,
> it's unnecessary if you're going to use the data somehow (i.e. in some
> SGMLish way) and probably unnecessary if you're not dropping the data
> into an asis environment.

Converting between strings and lists of characters is not very efficient
especially for large strings.  You would be much better off using
string-length/substring/string-ref.

James


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread
  • read-entity, is there any example or use explication?
    • miguel . mata - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id EAA04085Thu, 3 Sep 1998 04:52:12 -0400 (EDT)
      • Norman Walsh - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id GAA05960Thu, 3 Sep 1998 06:42:21 -0400 (EDT)
        • James Clark - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id HAA06733Thu, 3 Sep 1998 07:21:39 -0400 (EDT) <=
          • Norman Walsh - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id KAA19305Thu, 3 Sep 1998 10:44:16 -0400 (EDT)
          • Tony Graham - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id MAA29505Thu, 3 Sep 1998 12:33:29 -0400 (EDT)
          • Russell Steven Shawn O'Connor - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id KAA12102Fri, 4 Sep 1998 10:33:37 -0400 (EDT)
          • Russell Steven Shawn O'Connor - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id KAA12181Fri, 4 Sep 1998 10:36:00 -0400 (EDT)