Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XML parsing in P6

2 views
Skip to first unread message

Premshree Pillai

unread,
Mar 12, 2006, 1:57:32 PM3/12/06
to perl6-c...@perl.org
Hello,

[not sure if this belongs to this list; if not, apologies, and maybe
point me to the right list]

New to P6. Just compiled Pugs on OS X, so am just playing around. I
was wondering if there's any XML parsing module available in Pugs. I
saw an XML-SAX in misc/, but was wondering how to use it -- or of it
can be used in the first place.

If there isn't one, can I use a P5 module in P6? I remember seeing
something like "use P5ModuleName--per5". Is that the current state of
the art?

Thanks,
Premshre

Yuval Kogman

unread,
Mar 12, 2006, 2:04:05 PM3/12/06
to Premshree Pillai, perl6-c...@perl.org
On Mon, Mar 13, 2006 at 00:27:32 +0530, Premshree Pillai wrote:
> Hello,
>
> [not sure if this belongs to this list; if not, apologies, and maybe
> point me to the right list]

#perl6 on freenode might be a better choice - much more people are
active.

> New to P6. Just compiled Pugs on OS X, so am just playing around. I
> was wondering if there's any XML parsing module available in Pugs. I
> saw an XML-SAX in misc/, but was wondering how to use it -- or of it
> can be used in the first place.

That's a port of the Perl 5 XML::SAX
(http://search.cpan.org/perldoc?XML::SAX) which is basically a
parser factory...

Unfortunately it doesn't seem like anyone actuallu wrote an XML::SAX
driver in perl 6 yet.

> If there isn't one, can I use a P5 module in P6? I remember seeing
> something like "use P5ModuleName--per5". Is that the current state of
> the art?

Yes: you can do something like

use perl5:XML::SAX;

in Perl 6 code, and get the [reasonably] sane API that XML::SAX
offers, along with the *HUGE* array of drivers.

Essentialy XML::SAX wants you to inherit from some handler base
class, and then handle events like 'start_tag', etc.

Some more "fun" XML modules exist on on the CPAN, which provide more
"treeish" APIs than event parser APIs.

Ciao!

--
() Yuval Kogman <nothi...@woobling.org> 0xEBD27418 perl hacker &
/\ kung foo master: /me climbs a brick wall with his fingers: neeyah!

Premshree Pillai

unread,
Mar 12, 2006, 2:30:42 PM3/12/06
to Premshree Pillai, perl6-c...@perl.org
On 3/13/06, Yuval Kogman <nothi...@woobling.org> wrote:
> #perl6 on freenode might be a better choice - much more people are
> active.

I know. I am currently at a friend's place, and seems like (for
whatever reason), his ISP has blocked certain ports (don't ask me to
use a web-based client :-p).

> Yes: you can do something like
>
> use perl5:XML::SAX;

Okay, this works fine. But now how do I actually inline P5 code in a
P6 program? I just tried using XML::Parser::Lite::Tree, but
(obviously?) am getting errors.

> Essentialy XML::SAX wants you to inherit from some handler base
> class, and then handle events like 'start_tag', etc.

Yeah, aware - have used SAX parsers in perl and otherwise.

Premshree

Yuval Kogman

unread,
Mar 12, 2006, 2:42:59 PM3/12/06
to Premshree Pillai, perl6-c...@perl.org
On Mon, Mar 13, 2006 at 01:00:42 +0530, Premshree Pillai wrote:
> On 3/13/06, Yuval Kogman <nothi...@woobling.org> wrote:
> > #perl6 on freenode might be a better choice - much more people are
> > active.
>
> I know. I am currently at a friend's place, and seems like (for
> whatever reason), his ISP has blocked certain ports (don't ask me to
> use a web-based client :-p).

You can probably have a shell account on feather.perl6.nl (Juerd
needs your full name and I don't know if this can be done by proxy
or not), and definately on my machine, where you can use
screen/irssi to your heart's content, if you please.

> Okay, this works fine. But now how do I actually inline P5 code in a
> P6 program? I just tried using XML::Parser::Lite::Tree, but
> (obviously?) am getting errors.

Paste code / errors?

> > Essentialy XML::SAX wants you to inherit from some handler base
> > class, and then handle events like 'start_tag', etc.
>
> Yeah, aware - have used SAX parsers in perl and otherwise.

Ah, i thought you were a Ruby guy and since you asked what the
XML::SAX thing was I didn't think you've used it before.

--
() Yuval Kogman <nothi...@woobling.org> 0xEBD27418 perl hacker &

/\ kung foo master: /me beats up some cheese: neeyah!!!!!!!!!!!!!!!!!

Yuval Kogman

unread,
Mar 12, 2006, 2:45:41 PM3/12/06
to Premshree Pillai, perl6-c...@perl.org
On Sun, Mar 12, 2006 at 21:42:59 +0200, Yuval Kogman wrote:

> You can probably have a shell account on feather.perl6.nl (Juerd
> needs your full name and I don't know if this can be done by proxy
> or not), and definately on my machine, where you can use
> screen/irssi to your heart's content, if you please.

Oh, additionally for when i'm stuck in your kind of situation I have
port 443 mapped to ssh on my machine, and I think feather does that
too if audrey is in the mood ;-)

--
() Yuval Kogman <nothi...@woobling.org> 0xEBD27418 perl hacker &

/\ kung foo master: /me tips over a cow: neeyah!!!!!!!!!!!!!!!!!!!!!!

Premshree Pillai

unread,
Mar 12, 2006, 4:19:38 PM3/12/06
to perl6-c...@perl.org
On 3/13/06, Yuval Kogman <nothi...@woobling.org> wrote:
> Paste code / errors?

I have this bit of code:

my $tree = XML::Parser::Lite::Tree::instance()->parse($xml_data);

And following's the error Pugs throws out:

unexpected ">"
expecting ":", term postfix, operator, ";" or "}"
at test.p6 line 28, column 63

> Ah, i thought you were a Ruby guy and since you asked what the
> XML::SAX thing was I didn't think you've used it before.

I started off with Perl. :-)

Premshree

Luke Palmer

unread,
Mar 13, 2006, 1:33:06 AM3/13/06
to Premshree Pillai, perl6-c...@perl.org
On 3/12/06, Premshree Pillai <premshre...@gmail.com> wrote:
> On 3/13/06, Yuval Kogman <nothi...@woobling.org> wrote:
> > Paste code / errors?
>
> I have this bit of code:
>
> my $tree = XML::Parser::Lite::Tree::instance()->parse($xml_data);
>
> And following's the error Pugs throws out:
>
> unexpected ">"
> expecting ":", term postfix, operator, ";" or "}"
> at test.p6 line 28, column 63

Well, yeah. Just because you're using a Perl 5 module doesn't mean
you use Perl 5 syntax.

my $tree = XML::Parser::Lite::Tree::instance().parse($xml_data);

Luke

Yuval Kogman

unread,
Mar 13, 2006, 1:39:22 AM3/13/06
to Luke Palmer, Premshree Pillai, perl6-c...@perl.org
On Mon, Mar 13, 2006 at 06:33:06 +0000, Luke Palmer wrote:

> Luke

Luke! You're back from the dead!

*dance*

Premshree Pillai

unread,
Mar 13, 2006, 1:42:20 AM3/13/06
to Luke Palmer, perl6-c...@perl.org
On 3/13/06, Luke Palmer <lrpa...@gmail.com> wrote:
> Well, yeah. Just because you're using a Perl 5 module doesn't mean
> you use Perl 5 syntax.
>
> my $tree = XML::Parser::Lite::Tree::instance().parse($xml_data);

Heh. I had tried that already. :-) This is the error I get in this case:

*** No such method in class Any: "&parse"
at flickr.p6 line 28, column 28-80
flickr.p6 line 37, column 5-17

Premshree

Luke Palmer

unread,
Mar 13, 2006, 2:19:46 AM3/13/06
to Premshree Pillai, perl6-c...@perl.org
On 3/13/06, Premshree Pillai <premshre...@gmail.com> wrote:
> On 3/13/06, Luke Palmer <lrpa...@gmail.com> wrote:
> > Well, yeah. Just because you're using a Perl 5 module doesn't mean
> > you use Perl 5 syntax.
> >
> > my $tree = XML::Parser::Lite::Tree::instance().parse($xml_data);
>
> Heh. I had tried that already. :-) This is the error I get in this case:

Well, as Yuval points out, I've been dead for a while, so this bug may
have already been fixed, but if not:

my $parser = XML::Parser::Lite::Tree::instance();
my $tree = $parser.parse($xml_data);

Should do the trick. This bug is perhaps one of the most annoying in
Pugs, and I have tried to fix it on several occasions with no success.

Luke

Premshree Pillai

unread,
Mar 13, 2006, 2:53:17 AM3/13/06
to perl6-c...@perl.org

Well, something's still wrong:

*** No such sub: "&XML::Parser::Lite::Tree::instance"
at test.p6 line 29, column 30-65
ftest.p6 line 39, column 5-17

Ideas?

Premshree

0 new messages