But the problem is that we can't use <item> in the (from) since some
feeds will contain <item attr=3D"value"> only, what do we do about that?

In most cases it will still be <item> and then the subsequent test for
item (in the terminating tag) will of course return true and then we
get nothing.

I mean I don't understand how the above code would work with something
looking like this:

<item attr=3D"value">Content1</item>
<item attr=3D"value">Content2</item>

While still being able to handle

<item>Content1</item>
<item>Content2</item>

What we need is a test for <item and then some way of
discarding/ignoring the first ">" when we do subsequent tills. That's
what I tried to do with an initial (till ">") but it didn't work, like
this:

(in "rss.xml"
  (while
     (from "<item")
     (till ">")
     (println
        (make
           (loop
              (NIL (chain (till ">")))
              (char)
              (T (tail '`(chop "item") @)) ) ) ) ))

/Henrik


On Tue, Nov 3, 2009 at 6:37 PM, Alexander Burger <[email protected]> wrot=
e:
> On Tue, Nov 03, 2009 at 05:58:20PM +0100, Henrik Sarvell wrote:
>> Am I missing something? Won't the first (from) basically find the
>> first instance of "<item" and put the reader at that place? If I use
>
> Yes.
>
>> match here am I not matching on the whole of the rest of the document?
>
> No, I was talking about the return value of 'make'
>
> (while (from "<item>")
> =A0 (println =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 # Instead of printing
> =A0 =A0 =A0(make =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 # do further matching
> =A0 =A0 =A0 =A0 (loop
> =A0 =A0 =A0 =A0 =A0 =A0(NIL (chain (till ">"))) =A0 =A0 =A0 =A0 =A0 =A0 =
=A0# Collect until next tag
> =A0 =A0 =A0 =A0 =A0 =A0(char) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0# Skip '>'
> =A0 =A0 =A0 =A0 =A0 =A0(T (tail '`(chop "item") @)) ) ) ) ) =A0# See if w=
e got <item>
>
> 'make' returns everything that was collected by 'till' and 'chain' in a
> list.
>
> The tail of that list will be ("i" "t" "e" "m") if 'loop' was terminated
> by the 'T' clause, or something unexpected when end of file was hit (the
> 'NIL' clause).
>
> So how about such a structure:
>
> (while (from "<item>")
> =A0 (let Lst
> =A0 =A0 =A0(make
> =A0 =A0 =A0 =A0 (loop
> =A0 =A0 =A0 =A0 =A0 =A0(NIL (chain (till ">")))
> =A0 =A0 =A0 =A0 =A0 =A0(char)
> =A0 =A0 =A0 =A0 =A0 =A0(T (tail '`(chop "item") @)) ) )
> =A0 =A0 =A0(cond
> =A0 =A0 =A0 =A0 ((match ... Lst)
> =A0 =A0 =A0 =A0 =A0 =A0... )
> =A0 =A0 =A0 =A0 ((match ... Lst)
> =A0 =A0 =A0 =A0 =A0 =A0...)
>
>
> You could also immediately check for the trailing ("i" "t" "e" "m") and
> discard results which do not match it:
>
> (use @X
> =A0 (while (from "<item>")
> =A0 =A0 =A0(when
> =A0 =A0 =A0 =A0 (match '(@X "i" "t" "e" "m")
> =A0 =A0 =A0 =A0 =A0 =A0(make
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 (loop
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(NIL (chain (till ">")))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(char)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(T (tail '`(chop "item") @)) ) ) )
> =A0 =A0 =A0 =A0 (got something in @X without trailing "item")
> =A0 =A0 =A0 =A0 ... ) ) )
>
> Again, just ideas, not tested ;-)
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:[email protected]?subject=3dunsubscribe
>
-- 
UNSUBSCRIBE: mailto:[email protected]?subject=unsubscribe

Reply via email to