Re: Error loading ultra-edit XML files and line numbers

"Dmitry Lizorkin" <[email protected]> Mon, 18 Sep 2006 17:59:51 +0400
Newsgroups gmane.lisp.scheme.ssax-sxml
Message-ID <038101c6db2a$b69efd20$4cc69553@fiona>
Hello!

>> The problem seems to be related to three characters that ultra-edit
>> includes at the beginning of the file. However, other parsers (xerces
>> for instance) work fine.
>
> I guess this is the question for Dmitry as to how customizable
> sxml:document is. It is certain however that sxml:document quite soon
> calls the SSAX parser, ssax:xml->sxml.

Oleg, you are right.
For an XML document requested by URI via sxml:document function, the 
semantics of the sxml:document function is roughly as follows:

(lambda (req-uri)
    (ssax:xml->sxml
     (open-input-resource req-uri)
     '()))

> The parser accepts the input
> port (rather than the file name or URL). It is quite possible to open
> a file on one's own, use peek-char to check if the file starts with
> extra characters (could be the BOM mark), skip these characters if
> needed, and then pass the port to the parser.

Victor, for your project, you can use a variation that provides skipping 
several starting characters, for example, thus:

(lambda (req-uri)
    (let ((port (open-input-resource req-uri)))
      (let loop ()
        (if (char=? (peek-char port) #\<)
            (ssax:xml->sxml port '())
            (begin
              (read-char port)
              (loop))))))

We can probably think of making the sxml:document function customizable for 
providing such a semantics.

Dmitry



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642