Re: using xml.l

2017-01-16 Thread dean
I thought I was using xml.l since reading yesterday that xm.l was just in
for historic reasons sothat's a very good call on your part Alex and
sorry for my sloppiness :) and YES it works great!

On 16 January 2017 at 20:33, Alexander Burger <a...@software-lab.de> wrote:

> On Mon, Jan 16, 2017 at 07:48:52PM +, dean wrote:
> > When I try to slurp the xml in I get
> > [fl.xml:1] !DOCTYPE -- Unbalanced XML
> >
> > I'm assuming ":1" refers to the second line here...
> > 
> > 
>
> Yes, then please try "@lib/xml.l" instead of up "@lib/xm.l". It handles
> also
> comments and other things which are usually not in plain XML data files.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: using xml.l

2017-01-16 Thread Alexander Burger
On Mon, Jan 16, 2017 at 07:48:52PM +, dean wrote:
> When I try to slurp the xml in I get
> [fl.xml:1] !DOCTYPE -- Unbalanced XML
> 
> I'm assuming ":1" refers to the second line here...
> 
> 

Yes, then please try "@lib/xml.l" instead of up "@lib/xm.l". It handles also
comments and other things which are usually not in plain XML data files.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: using xml.l

2017-01-16 Thread dean
When I try to slurp the xml in I get
[fl.xml:1] !DOCTYPE -- Unbalanced XML

I'm assuming ":1" refers to the second line here...




I've looked at the xml tree using the firefox plugin "xml developer" and
it's indents look pretty uniform from the start to the end so I don'r
really know what I'm doing wrong.





On 16 January 2017 at 17:44, dean  wrote:

> >'read' cannot be used to parse an XML file, because it expects Lisp
> syntax.
>
> Thank you for putting me straight on that.
>
> >You can then operate on the s-expr with all the list manipulation
> functions.
> >And/or use 'body' and 'attr' for convenience.
>
> That sounds really good...thank you very much
>
> On 16 January 2017 at 17:10, Alexander Burger  wrote:
>
>> On Mon, Jan 16, 2017 at 04:04:18PM +, dean wrote:
>> > I tried this on an xml file and it seems ideal re separating the tags
>> and
>> > data for processing
>> > (in "fl.xml" (until (eof) (prinl (read
>> >
>> > The input is stopping abruptly when I hit an isolated closed paren
>> though
>>
>> 'read' cannot be used to parse an XML file, because it expects Lisp
>> syntax.
>>
>>
>> > I'm just wondering how best to get around this
>>
>> "@lib/xm.l" or "@lib/xml.l" are for that.
>>
>> The function 'xml' slurps in a whole XML tree:
>>
>>: (load "@lib/xm.l")
>>
>>: (in "fl.xml" (and (xml?) (xml)))
>>-> (...)  # Get s-expr representing the XML
>>
>>: (pretty @)
>>   # Get pretty-printed output of the structure
>>
>> You can then operate on the s-expr with all the list manipulation
>> functions.
>> And/or use 'body' and 'attr' for convenience.
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: using xml.l

2017-01-16 Thread dean
>'read' cannot be used to parse an XML file, because it expects Lisp syntax

Re: using xml.l

2017-01-16 Thread Alexander Burger
On Mon, Jan 16, 2017 at 04:04:18PM +, dean wrote:
> I tried this on an xml file and it seems ideal re separating the tags and
> data for processing
> (in "fl.xml" (until (eof) (prinl (read
> 
> The input is stopping abruptly when I hit an isolated closed paren though

'read' cannot be used to parse an XML file, because it expects Lisp syntax.


> I'm just wondering how best to get around this

"@lib/xm.l" or "@lib/xml.l" are for that.

The function 'xml' slurps in a whole XML tree:

   : (load "@lib/xm.l")

   : (in "fl.xml" (and (xml?) (xml)))
   -> (...)  # Get s-expr representing the XML

   : (pretty @)
  # Get pretty-printed output of the structure

You can then operate on the s-expr with all the list manipulation functions.
And/or use 'body' and 'attr' for convenience.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: using xml.l

2017-01-16 Thread dean
I tried this on an xml file and it seems ideal re separating the tags and
data for processing
(in "fl.xml" (until (eof) (prinl (read

The input is stopping abruptly when I hit an isolated closed paren though
a).
which is resulting in
Bad input ')'
I'm just wondering how best to get around this



On 16 January 2017 at 14:53, dean  wrote:

> Thank you very much for that.
> Best Regards
> Dean
>
> On 16 January 2017 at 14:33, Alexander Burger  wrote:
>
>> Hi Dean,
>>
>> > To get started I thought I'd try to list all the functions in xml.l
>> using
>> > PL and tried...
>> > in "/home/me/xml.l" (while (line T) (prinl @)))
>> > as a starting point but I'm not sure how you get past the third line
>> which
>> > is blank so
>>
>> Yes, 'line' returns NIL for blank lines, so the loop will stop.
>>
>>
>> > I reverted to what I know for now :)
>> >
>> > $ perl -ne'$w='de';print if /.*$w /i' /home/me/xml.l
>> > (de xml? (Flg)
>> > (de xml (Lst N)
>> > ...
>>
>> You could try this:
>>
>>(in "@lib/xml.l"
>>   (until (eof)
>>  (let? L (line)
>> (and (= "(" (car L)) (prinl L)) ) ) )
>>
>> Outputs:
>>
>>(de xml? (Flg)
>>(de xml (Lst N)
>>(de _xml_ (Lst)
>>(de _xml (In Char)
>>(de xmlEsc (L)
>>...
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: using xml.l

2017-01-16 Thread dean
Thank you very much for that.
Best Regards
Dean

On 16 January 2017 at 14:33, Alexander Burger  wrote:

> Hi Dean,
>
> > To get started I thought I'd try to list all the functions in xml.l using
> > PL and tried...
> > in "/home/me/xml.l" (while (line T) (prinl @)))
> > as a starting point but I'm not sure how you get past the third line
> which
> > is blank so
>
> Yes, 'line' returns NIL for blank lines, so the loop will stop.
>
>
> > I reverted to what I know for now :)
> >
> > $ perl -ne'$w='de';print if /.*$w /i' /home/me/xml.l
> > (de xml? (Flg)
> > (de xml (Lst N)
> > ...
>
> You could try this:
>
>(in "@lib/xml.l"
>   (until (eof)
>  (let? L (line)
> (and (= "(" (car L)) (prinl L)) ) ) )
>
> Outputs:
>
>(de xml? (Flg)
>(de xml (Lst N)
>(de _xml_ (Lst)
>(de _xml (In Char)
>(de xmlEsc (L)
>...
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: using xml.l

2017-01-16 Thread Alexander Burger
Hi Dean,

> To get started I thought I'd try to list all the functions in xml.l using
> PL and tried...
> in "/home/me/xml.l" (while (line T) (prinl @)))
> as a starting point but I'm not sure how you get past the third line which
> is blank so

Yes, 'line' returns NIL for blank lines, so the loop will stop.


> I reverted to what I know for now :)
> 
> $ perl -ne'$w='de';print if /.*$w /i' /home/me/xml.l
> (de xml? (Flg)
> (de xml (Lst N)
> ...

You could try this:

   (in "@lib/xml.l"
  (until (eof)
 (let? L (line)
(and (= "(" (car L)) (prinl L)) ) ) )

Outputs:

   (de xml? (Flg)
   (de xml (Lst N)
   (de _xml_ (Lst)
   (de _xml (In Char)
   (de xmlEsc (L)
   ...

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


using xml.l contd

2017-01-16 Thread dean
Ok I found some good examples on Rosetta code i.e.

https://rosettacode.org/wiki/XML/Input#PicoLisp

and see that I have unbalanced xml.

I'm just wondering what the best tools to analyse this would be on openbsd.


using xml.l

2017-01-16 Thread dean
To get started I thought I'd try to list all the functions in xml.l using
PL and tried...
in "/home/me/xml.l" (while (line T) (prinl @)))
as a starting point but I'm not sure how you get past the third line which
is blank so
I reverted to what I know for now :)

$ perl -ne'$w='de';print if /.*$w /i' /home/me/xml.l
(de xml? (Flg)
(de xml (Lst N)
(de _xml_ (Lst)
(de _xml (In Char)
(de xmlEsc (L)
(de escXml (X)
(de xml$ (Lst)
(de body (Lst . @)
(de attr (Lst Key . @)
(de "xmlL" Lst
(de "xmlO" Lst
(de  ("N" . Lst)

Is there a very simple intro re how I'd manipulate my xml file using these
and how would I get this list using PL...'cos that's my tool of choice now
:)
Thank you in anticipation.