[gambit-list] Is this a fix? Re: sxml>>xml layout question.

Hendrik Boom hendrik at topoi.pooq.com
Sun Jan 29 10:47:17 EST 2012


On Sat, 28 Jan 2012 22:38:46 +0000, Hendrik Boom wrote:

> On Wed, 25 Jan 2012 02:38:32 +0000, Hendrik Boom wrote:
> 
>> On Wed, 25 Jan 2012 00:37:35 +0100, Álvaro Castro-Castilla wrote:
>> 
>>> Hi Hendrik,
>>> 
>>> I've used scml->xml with Blackhole and got normal xml output. How are
>>> you using it?
>> 
>> Thanks.  That's valuable information.  Now that I know that this
>> behaviour isn't normal, I'll find it worthwhile trimming the text and
>> either tracking down the problem or posting a smaller version here.
> 
> OK.  Here's the file try.scm:
> 
> 
> 
> (define test
>   '(*TOP* (*PI* xml "version=\"1.0\" encoding=\"UTF-8\"")
>        (urn:oasis:names:tc:opendocument:xmlns:office:1.0:document
>         (@ (urn:oasis:names:tc:opendocument:xmlns:office:1.0:version
> "1.1")
>            (urn:oasis:names:tc:opendocument:xmlns:office:1.0:mimetype
>             "application/vnd.oasis.opendocument.text"))
>         (urn:oasis:names:tc:opendocument:xmlns:office:1.0:body
>          (urn:oasis:names:tc:opendocument:xmlns:office:1.0:text
>           (@ (urn:oasis:names:tc:opendocument:xmlns:text:1.0:use-soft-
> page-breaks
>               "true"))
>           (P "P4" "Catharine")
>           (P "P5"
>              "Catharine is sitting in a seaside cafeteria at a counter
> facing the ocean. "
>              (S)
>              "She looks out over the sea at the massing clouds and
> shudders. "
>              (S)
>              "Andrei, a thin man, comes to sit beside her at the
>              counter.
> "
>              (S)
>              "Lightning flashes among the clouds."))))))
> 
> 
> 
> (import std/string/sxml-to-xml)
> 
> (define o (open-output-file "testout.xml")) (sxml>>xml test o)
> (close-output-port o)
> 
> 
> I run bh and import try.scm:
> 
> hendrik at notlookedfor:~/write/storm/storm/icv$ bh Gambit Scheme w/ Black
> Hole
>> (import try)
>> 
>> 
> 
> and afterwards, the output file testout.xml is as follows:
> 
> 
> <?xml version="1.0" encoding="utf-8"?> <*TOP*
>  ><*PI*
>   >xmlversion="1.0" encoding="UTF-8"</*PI*
>  ><urn:oasis:names:tc:opendocument:xmlns:office:1.0:document
>  >urn:oasis:names:tc:opendocument:xmlns:office:1.0:version="1.1"
>  >urn:oasis:names:tc:opendocument:xmlns:office:1.0:mimetype="application/vnd.oasis.opendocument.text"
>   ><urn:oasis:names:tc:opendocument:xmlns:office:1.0:body
>    ><urn:oasis:names:tc:opendocument:xmlns:office:1.0:text
>    >urn:oasis:names:tc:opendocument:xmlns:text:1.0:use-soft-page-breaks="true"
>     ><P
>      >P4Catharine</P
>     ><P
>      >P5Catharine is sitting in a seaside cafeteria at a counter facing
>      >the ocean. <S />She looks out over the sea at the massing clouds
>      >and shudders. <S />Andrei, a thin man, comes to sit beside her at
>      >the counter. <S />Lightning flashes among the clouds.</P
>     ></urn:oasis:names:tc:opendocument:xmlns:office:1.0:text
>    ></urn:oasis:names:tc:opendocument:xmlns:office:1.0:body
>   ></urn:oasis:names:tc:opendocument:xmlns:office:1.0:document
>  ></*TOP*
>>
>>
> 
> Do I perhaps have the wrong version of sxml>>xml ?
> 
> I got my version using
> 
> hendrik at notlookedfor:~/dv/gambit$ git clone
> git://github.com/pereckerdal/blackhole-libs.git Cloning into
> 'blackhole-libs'...
> remote: Counting objects: 208, done.
> remote: Compressing objects: 100% (102/102), done. remote: Total 208
> (delta 107), reused 201 (delta 104) Receiving objects: 100% (208/208),
> 199.39 KiB, done. Resolving deltas: 100% (107/107), done.
> hendrik at notlookedfor:~/dv/gambit$
> 

I swapped a few lines in smxl-to-xml.scm.  But I find myself wondering 
if this might cause problems elsewhere.  Why, after all, were they out of
 order in the first place?

*** /home/hendrik/dv/gambit/blackhole-libs/string/sxml-to-xml.scm	2012-01-20 12:04:49.000000000 -0500
--- sxml-to-xml.scm	2012-01-29 10:15:19.000000000 -0500
***************
*** 377,390 ****
  						 (@char>> #\space port)
  						 (lp (- i 1)))))))))
  		 (out>>/body>> (lambda (body>>)
- 				 (maybe-indent>> next-level)
  				 (@char>> #\> port)
  				 (body>>)
  				 (@char>> #\< port)
  				 (@char>> #\/ port)
  				 (@symbol>> (@car l) port)
! 				 (maybe-indent>> maybe-level)
! 				 (@char>> #\> port)))
  		 (end>> (lambda ()
  			 (if xml? (begin
  				    (@char>> #\space port)
--- 377,390 ----
  						 (@char>> #\space port)
  						 (lp (- i 1)))))))))
  		 (out>>/body>> (lambda (body>>)
  				 (@char>> #\> port)
+ 				 (maybe-indent>> next-level)
  				 (body>>)
  				 (@char>> #\< port)
  				 (@char>> #\/ port)
  				 (@symbol>> (@car l) port)
! 				 (@char>> #\> port)
! 				 (maybe-indent>> maybe-level)))
  		 (end>> (lambda ()
  			 (if xml? (begin
  				    (@char>> #\space port)


Now the output looks considerably better:

<?xml version="1.0" encoding="utf-8"?>
<*TOP*>
 <*PI*>
  xmlversion="1.0" encoding="UTF-8"</*PI*>
 <urn:oasis:names:tc:opendocument:xmlns:office:1.0:document urn:oasis:names:tc:opendocument:xmlns:office:1.0:version="1.1" urn:oasis:names:tc:opendocument:xmlns:office:1.0:mimetype="application/vnd.oasis.opendocument.text">
  <urn:oasis:names:tc:opendocument:xmlns:office:1.0:body>
   <urn:oasis:names:tc:opendocument:xmlns:office:1.0:text urn:oasis:names:tc:opendocument:xmlns:text:1.0:use-soft-page-breaks="true">
    <P>
     P4Catharine</P>
    <P>
     P5Catharine is sitting in a seaside cafeteria at a counter facing the ocean. <S />She looks out over the sea at the massing clouds and shudders. <S />Andrei, a thin man, comes to sit beside her at the counter. <S />Lightning flashes among the clouds.</P>
    </urn:oasis:names:tc:opendocument:xmlns:office:1.0:text>
   </urn:oasis:names:tc:opendocument:xmlns:office:1.0:body>
  </urn:oasis:names:tc:opendocument:xmlns:office:1.0:document>
 </*TOP*>

-- hendrik




More information about the Gambit-list mailing list