[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
#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!
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
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!!!!!!!!!!!!!!!!!
> 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!!!!!!!!!!!!!!!!!!!!!!
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
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
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
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
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