Re: Xpath
Daniel Perrett <[email protected]> Tue, 11 Dec 2012 11:12:18 +0000
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <OF2E5ACCFE.327C534D-ON80257AD1.003CD126-80257AD1.003D7E03@cambridge.org> |
This is a multipart message in MIME format. --===============0725154560== Content-Type: multipart/alternative; boundary="=_alternative 003D7E0380257AD1_=" This is a multipart message in MIME format. --=_alternative 003D7E0380257AD1_= Content-Type: text/plain; charset="US-ASCII" Oops! In which case I apologise for my previous statement, I have no idea why I either didn't notice that section or comprehend it fully before, the docs seem pretty clear. Thanks a lot - my life just got measurably easier! Daniel From: Tim Brody <[email protected]> To: Daniel Perrett <[email protected]> Cc: Perl XML List <[email protected]> Date: 11/12/2012 11:03 Subject: Re: Xpath In http://search.cpan.org/~shlomif/XML-LibXSLT-1.79/LibXSLT.pm "register_function" and "register_element", which do indeed allow you to call a Perl function on either XPath functions or XSL elements. InputCallback is something completely different. /Tim. On Tue, 2012-12-11 at 10:48 +0000, Daniel Perrett wrote: > "XML::LibXSLT also supports callbacks into Perl space, so you can mix > and match XSLT and Perl in the same template." > Wow, I've been using LibXSLT on a weekly to daily basis for several > years and I never knew that. The POD is very cryptic on the matter: > > "To define XML::LibXSLT or XML::LibXSLT::Stylesheet specific input > callbacks, reuse the XML::LibXML input callback API as described in > XML::LibXML::InputCallback(3)." > > ... which tells me nothing about what an input callback is in this > context, let alone why I might want to use it. > > So does this mean I can create custom XSLT functions that pass a value > (or better, a DOM node) to Perl and get a result back? That would be > *very* handy, not least to et around my occasional need to translate > what ought to be a series of regex replacements into a template that > recurses through a flat list and then does string replacements that > approximate the reex. Or does it mean something else? > > Daniel > > > > From: Tim Brody <[email protected]> > To: [email protected] > Cc: Perl XML List <[email protected]> > Date: 11/12/2012 10:25 > Subject: Re: Xpath > Sent by: [email protected] > > ______________________________________________________________________ > > > > To use an analogy, XSLT is to XML what regexps are to text. Yes, it > takes some time to get your head around but once you do it makes XML > transformations quick to achieve. XSLT is flexible enough to be used > procedurally or as pattern matching - "foreach" vs. "template". > > XML::LibXSLT also supports callbacks into Perl space, so you can mix > and > match XSLT and Perl in the same template. > > To work effectively with XML you should familiarise yourself with DOM, > SAX and XSLT, then you can apply the best technology to the problem in > hand. Otherwise, you can always use one of the modules that turns XML > into native Perl structures ... > > -- > All the best, > Tim. > > On Tue, 2012-12-11 at 00:23 -0500, Tod Harter wrote: > > It is a bit of a thing to wrap your head around, and XSLT is > certainly > > not the most friendly example of a functional language, but once you > > do get a grip on it its kind of elegant. Really I think mostly I'd > > like a non-xml syntax to use, that would make it a lot more fun. The > > other thing is XSLT2 is a LOT nicer, but unfortunately probably will > > never have an implementation with perl bindings. > > > > On Mon, Dec 10, 2012 at 9:14 PM, Thomas Krichel > <[email protected]> > > wrote: > > Tod Harter writes > > > > > IF you know XSLT (or if you're going to learn it anyway > > there's > > > no time like the present). Its a useful language to know. > > > > > > Coming from Perl, I found it hard to learn as you have > > to unlearn procedural thinking. > > > > Cheers, > > > > Thomas Krichel > > http://openlib.org/home/krichel > > > > http://authorprofile.org/pkr1 > > skype: > > thomaskrichel > > > > > > > > > > -- > > The Wise adapts himself to the world. The Fool adapts the world to > > himself. Therefore, all progress depends on the Fool. > > _______________________________________________ > > Perl-XML mailing list > > [email protected] > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > [attachment "signature.asc" deleted by Daniel > Perrett/ELT/UK/cambridge] > _______________________________________________ > Perl-XML mailing list > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > [attachment "signature.asc" deleted by Daniel Perrett/ELT/UK/cambridge] --=_alternative 003D7E0380257AD1_= Content-Type: text/html; charset="US-ASCII" <font size=2 face="sans-serif">Oops! In which case I apologise for my previous statement, I have no idea why I either didn't notice that section or comprehend it fully before, the docs seem pretty clear. </font> <br> <br><font size=2 face="sans-serif">Thanks a lot - my life just got measurably easier!</font> <br> <br><font size=2 face="sans-serif">Daniel</font> <br> <br> <br> <br><font size=1 color=#5f5f5f face="sans-serif">From: </font><font size=1 face="sans-serif">Tim Brody <[email protected]></font> <br><font size=1 color=#5f5f5f face="sans-serif">To: </font><font size=1 face="sans-serif">Daniel Perrett <[email protected]></font> <br><font size=1 color=#5f5f5f face="sans-serif">Cc: </font><font size=1 face="sans-serif">Perl XML List <[email protected]></font> <br><font size=1 color=#5f5f5f face="sans-serif">Date: </font><font size=1 face="sans-serif">11/12/2012 11:03</font> <br><font size=1 color=#5f5f5f face="sans-serif">Subject: </font><font size=1 face="sans-serif">Re: Xpath</font> <br> <hr noshade> <br> <br> <br><tt><font size=2>In </font></tt><a href="http://search.cpan.org/~shlomif/XML-LibXSLT-1.79/LibXSLT.pm"><tt><font size=2>http://search.cpan.org/~shlomif/XML-LibXSLT-1.79/LibXSLT.pm</font></tt></a><tt><font size=2><br> <br> "register_function" and "register_element", which do indeed allow you to<br> call a Perl function on either XPath functions or XSL elements.<br> <br> InputCallback is something completely different.<br> <br> /Tim.<br> <br> On Tue, 2012-12-11 at 10:48 +0000, Daniel Perrett wrote:<br> > "XML::LibXSLT also supports callbacks into Perl space, so you can mix<br> > and match XSLT and Perl in the same template." <br> > Wow, I've been using LibXSLT on a weekly to daily basis for several<br> > years and I never knew that. The POD is very cryptic on the matter: <br> > <br> > "To define XML::LibXSLT or XML::LibXSLT::Stylesheet specific input<br> > callbacks, reuse the XML::LibXML input callback API as described in<br> > XML::LibXML::InputCallback(3)." <br> > <br> > ... which tells me nothing about what an input callback is in this<br> > context, let alone why I might want to use it. <br> > <br> > So does this mean I can create custom XSLT functions that pass a value<br> > (or better, a DOM node) to Perl and get a result back? That would be<br> > *very* handy, not least to et around my occasional need to translate<br> > what ought to be a series of regex replacements into a template that<br> > recurses through a flat list and then does string replacements that<br> > approximate the reex. Or does it mean something else? <br> > <br> > Daniel <br> > <br> > <br> > <br> > From: Tim Brody <[email protected]> <br> > To: [email protected] <br> > Cc: Perl XML List <[email protected]> <br> > Date: 11/12/2012 10:25 <br> > Subject: Re: Xpath <br> > Sent by: [email protected] <br> > <br> > ______________________________________________________________________<br> > <br> > <br> > <br> > To use an analogy, XSLT is to XML what regexps are to text. Yes, it<br> > takes some time to get your head around but once you do it makes XML<br> > transformations quick to achieve. XSLT is flexible enough to be used<br> > procedurally or as pattern matching - "foreach" vs. "template".<br> > <br> > XML::LibXSLT also supports callbacks into Perl space, so you can mix<br> > and<br> > match XSLT and Perl in the same template.<br> > <br> > To work effectively with XML you should familiarise yourself with DOM,<br> > SAX and XSLT, then you can apply the best technology to the problem in<br> > hand. Otherwise, you can always use one of the modules that turns XML<br> > into native Perl structures ...<br> > <br> > --<br> > All the best,<br> > Tim.<br> > <br> > On Tue, 2012-12-11 at 00:23 -0500, Tod Harter wrote:<br> > > It is a bit of a thing to wrap your head around, and XSLT is<br> > certainly<br> > > not the most friendly example of a functional language, but once you<br> > > do get a grip on it its kind of elegant. Really I think mostly I'd<br> > > like a non-xml syntax to use, that would make it a lot more fun. The<br> > > other thing is XSLT2 is a LOT nicer, but unfortunately probably will<br> > > never have an implementation with perl bindings. <br> > > <br> > > On Mon, Dec 10, 2012 at 9:14 PM, Thomas Krichel<br> > <[email protected]><br> > > wrote:<br> > > Tod Harter writes<br> > > <br> > > > IF you know XSLT (or if you're going to learn it anyway<br> > > there's<br> > > > no time like the present). Its a useful language to know.<br> > > <br> > > <br> > > Coming from Perl, I found it hard to learn as you have<br> > > to unlearn procedural thinking.<br> > > <br> > > Cheers,<br> > > <br> > > Thomas Krichel<br> > > </font></tt><a href=http://openlib.org/home/krichel><tt><font size=2>http://openlib.org/home/krichel</font></tt></a><tt><font size=2><br> > > <br> > > </font></tt><a href=http://authorprofile.org/pkr1><tt><font size=2>http://authorprofile.org/pkr1</font></tt></a><tt><font size=2><br> > > skype:<br> > > thomaskrichel<br> > > <br> > > <br> > > <br> > > <br> > > -- <br> > > The Wise adapts himself to the world. The Fool adapts the world to<br> > > himself. Therefore, all progress depends on the Fool.<br> > > _______________________________________________<br> > > Perl-XML mailing list<br> > > [email protected]<br> > > To unsubscribe: </font></tt><a href=http://listserv.activestate.com/mailman/mysubs><tt><font size=2>http://listserv.ActiveState.com/mailman/mysubs</font></tt></a><tt><font size=2><br> > <br> > [attachment "signature.asc" deleted by Daniel<br> > Perrett/ELT/UK/cambridge]<br> > _______________________________________________<br> > Perl-XML mailing list<br> > [email protected]<br> > To unsubscribe: </font></tt><a href=http://listserv.activestate.com/mailman/mysubs><tt><font size=2>http://listserv.ActiveState.com/mailman/mysubs</font></tt></a><tt><font size=2><br> > <br> <br> [attachment "signature.asc" deleted by Daniel Perrett/ELT/UK/cambridge] </font></tt> <br> --=_alternative 003D7E0380257AD1_=-- --===============0725154560== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs --===============0725154560==--