Re: xml-parse: file position of elements

Sven Hartrumpf <[email protected]> Fri, 04 Feb 2022 08:27:04 +0100 (CET)
Newsgroups gmane.lisp.scheme.bigloo
Message-ID <[email protected]>
Hello Joe.

Joseph Donaldson, 2022-02-01 18:21:
> Hello, Sven,
> Here is an updated version that moves the start-position parameter to position 4 and has the value of the element's starting < character.
> I also removed some debugging print statements that were erroneously left in place. Let me know how it works for you.

Thanks for the new version!

I removed the (+ . 1) in your helper function update-start-position!
because file offsets and string offsets are normally 0-based in Scheme.
The following code

  (call-with-input-string
    "<doc><itm></itm></doc><doc><itm></itm></doc>"
    (lambda (port)
      (pp (xml-parse port :procedure list :encoding 'UTF-8))))

outputs:

((doc () ((itm () () 0)) 0)
 (doc () ((itm () () 22)) 22))

The offsets for the doc-elements are correct,
the ones for the itm-elements are not?

Best regards
Sven