[plt-scheme] SXML for R6RS [was: R6RS Interoperability]
To follow up on explaining why my SXML libraries ports are not fully
working on MzScheme:
* HtmlPrag works completely.
* sxml-match works completely.
* sxml-tools issue: sxml-tools uses the SRFI and-let* macro. My SRFIs
ports provide it via the (xitomatl srfi and-let*) library. But MzScheme
currently does not accept library names with a * character in them:
;---------------------------------------------------------------------
#!r6rs
(import (A L*))
ERROR=>
lib: ill-formed module path in: (lib "A/L*.sls")
;---------------------------------------------------------------------
It would be easy to name it something else but R6RS allows library names
to use any symbol and I don't think a name other than and-let* would be
good.
I've been meaning to bring this up and ask: would it be possible for PLT
to support any symbols for library names? Ikarus currently does it by
encoding filename-unfriendly characters like * to %2A. I'd be willing
to make a patch to do this if it's not a dead end.
* SSAX issue: MzScheme does not conform [1] to the R6RS expectation that
the initial/default exception handler return for non-&serious
conditions [2]. Returning for non-&serious conditions allows you to do
things like raise-continuable a &warning condition to let interested
clients catch it and do something about it and maybe return, or the
default handler will return, and execution can continue. I made my
ssax:warn procedure do this and the SSAX library frequently
calls ssax:warn when issues that often can safely be ignored happen. I
hacked together a patch to MzScheme so its default R6RS handler returns
for non-&serious, though I'm not sure it meshes with PLT completely
correctly, and with it my SSAX port works completely:
===========================================================================
--- collects/rnrs/exceptions-6.ss 2008-06-22 21:01:22.000000000 -0700
+++ /collects/rnrs/exceptions-6.ss 2008-06-25 20:30:10.000000000 -0700
@@ -1,6 +1,8 @@
#lang scheme/base
-(require r6rs/private/exns)
+(require r6rs/private/exns
+ (only-in r6rs/private/conds serious-condition? simple-conditions)
+ (only-in rnrs/io/ports-6 standard-error-port))
(provide with-exception-handler
guard else =>
@@ -80,7 +82,21 @@
(define (r6rs:raise exn)
;; No barrier
- (raise exn #f))
+ (parameterize ([uncaught-exception-handler
+ (lambda (exn)
+ (let ([base (if (exn:continuable? exn)
+ (exn:continuable-base exn)
+ exn)])
+ (if (serious-condition? base)
+ (raise exn #f)
+ (begin
+ (display (format "Uncaught Exception:\n~s\n"
+ (simple-conditions base))
+ (standard-error-port))
+ (when (exn:continuable? exn)
+ ((exn:continuable-continuation exn)
+ (lambda () (values))))))))])
+ (raise exn #f)))
(define (raise-continuable exn)
((let/cc cont
===========================================================================
makes it do:
> (call-with-input-file
"/home/d/zone/scheme/SSAX/examples/xml/OMF-sample.xml"
(lambda (fip)
(ssax:xml->sxml fip '())))
Uncaught Exception:
{#(struct:&warning) #(struct:&who ssax) #(struct:&message "DOCTYPE DECL
Reports OMF.dtd found and skipped") #(struct:&port-position 36)
#(struct:&irritants #<textual-input-port>)}
;;; it continues and returns the SXML:
{*TOP* {Reports {^ {TStamp "950226528"}} {SYN {^ {Title "METAR"} {TStamp
"950104440"} {SName "KMRY, MONTEREY PENINSULA"} {LatLon "36.583,
-121.85"} {Elev "77"} {BId "724915"}}
[...]
[1] http://docs.plt-scheme.org/r6rs/conformance.html
[2]
http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-8.html#node_sec_7.1
--
: Derick
----------------------------------------------------------------
On Wed, 2008-07-02 at 18:16 -0700, Derick Eddington wrote:
> I just noticed this discussion. I've completed porting all of the
> common SXML libraries to R6RS: ssax, sxml-tools, htmlprag, and
> sxml-match:
>
> https://code.launchpad.net/~derick-eddington/ikarus-libraries/xitomatl
>
> The complete libraries are provided and all their tests pass (except one
> weird case, see my log comments). All of it works under Ikarus, but
> MzScheme cannot currently run all of it for a few reasons (I'd be glad
> to explain later, need to go to sleep), just try running all the tests
> and you'll see what. [You'll need my SRFIs ports, too.]
>
> I used ^ and ^^ as the replacements for @ and @@.