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: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Tim Brody &lt;[email protected]&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">To: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Daniel Perrett &lt;[email protected]&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Perl XML List &lt;[email protected]&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">11/12/2012 11:03</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject: &nbsp; &nbsp;
&nbsp; &nbsp;</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>
&quot;register_function&quot; and &quot;register_element&quot;, 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>
&gt; &quot;XML::LibXSLT also supports callbacks into Perl space, so you
can mix<br>
&gt; and match XSLT and Perl in the same template.&quot; <br>
&gt; Wow, I've been using LibXSLT on a weekly to daily basis for several<br>
&gt; years and I never knew that. The POD is very cryptic on the matter:
<br>
&gt; <br>
&gt; &quot;To define XML::LibXSLT or XML::LibXSLT::Stylesheet specific
input<br>
&gt; callbacks, reuse the XML::LibXML input callback API as described in<br>
&gt; XML::LibXML::InputCallback(3).&quot; <br>
&gt; <br>
&gt; ... which tells me nothing about what an input callback is in this<br>
&gt; context, let alone why I might want to use it. <br>
&gt; <br>
&gt; So does this mean I can create custom XSLT functions that pass a value<br>
&gt; (or better, a DOM node) to Perl and get a result back? That would
be<br>
&gt; *very* handy, not least to et around my occasional need to translate<br>
&gt; what ought to be a series of regex replacements into a template that<br>
&gt; recurses through a flat list and then does string replacements that<br>
&gt; approximate the reex. Or does it mean something else? <br>
&gt; <br>
&gt; Daniel <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; From: &nbsp; &nbsp; &nbsp; &nbsp;Tim Brody &lt;[email protected]&gt;
<br>
&gt; To: &nbsp; &nbsp; &nbsp; &nbsp;[email protected] <br>
&gt; Cc: &nbsp; &nbsp; &nbsp; &nbsp;Perl XML List &lt;[email protected]&gt;
<br>
&gt; Date: &nbsp; &nbsp; &nbsp; &nbsp;11/12/2012 10:25 <br>
&gt; Subject: &nbsp; &nbsp; &nbsp; &nbsp;Re: Xpath <br>
&gt; Sent by: &nbsp; &nbsp; &nbsp; &nbsp;[email protected]
<br>
&gt; <br>
&gt; ______________________________________________________________________<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; To use an analogy, XSLT is to XML what regexps are to text. Yes, it<br>
&gt; takes some time to get your head around but once you do it makes XML<br>
&gt; transformations quick to achieve. XSLT is flexible enough to be used<br>
&gt; procedurally or as pattern matching - &quot;foreach&quot; vs. &quot;template&quot;.<br>
&gt; <br>
&gt; XML::LibXSLT also supports callbacks into Perl space, so you can mix<br>
&gt; and<br>
&gt; match XSLT and Perl in the same template.<br>
&gt; <br>
&gt; To work effectively with XML you should familiarise yourself with
DOM,<br>
&gt; SAX and XSLT, then you can apply the best technology to the problem
in<br>
&gt; hand. Otherwise, you can always use one of the modules that turns
XML<br>
&gt; into native Perl structures ...<br>
&gt; <br>
&gt; --<br>
&gt; All the best,<br>
&gt; Tim.<br>
&gt; <br>
&gt; On Tue, 2012-12-11 at 00:23 -0500, Tod Harter wrote:<br>
&gt; &gt; It is a bit of a thing to wrap your head around, and XSLT is<br>
&gt; certainly<br>
&gt; &gt; not the most friendly example of a functional language, but once
you<br>
&gt; &gt; do get a grip on it its kind of elegant. Really I think mostly
I'd<br>
&gt; &gt; like a non-xml syntax to use, that would make it a lot more fun.
The<br>
&gt; &gt; other thing is XSLT2 is a LOT nicer, but unfortunately probably
will<br>
&gt; &gt; never have an implementation with perl bindings. <br>
&gt; &gt; <br>
&gt; &gt; On Mon, Dec 10, 2012 at 9:14 PM, Thomas Krichel<br>
&gt; &lt;[email protected]&gt;<br>
&gt; &gt; wrote:<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Tod Harter writes<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; IF you know XSLT (or if you're
going to learn it anyway<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; there's<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &gt; no time like the present). Its
a useful language to know.<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Coming from Perl, I found
it hard to learn as you have<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; to unlearn procedural thinking.<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cheers,<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thomas Krichel<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</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>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; </font></tt><a href=http://authorprofile.org/pkr1><tt><font size=2>http://authorprofile.org/pkr1</font></tt></a><tt><font size=2><br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;skype:<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; thomaskrichel<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; -- <br>
&gt; &gt; The Wise adapts himself to the world. The Fool adapts the world
to<br>
&gt; &gt; himself. Therefore, all progress depends on the Fool.<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Perl-XML mailing list<br>
&gt; &gt; [email protected]<br>
&gt; &gt; 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>
&gt; <br>
&gt; [attachment &quot;signature.asc&quot; deleted by Daniel<br>
&gt; Perrett/ELT/UK/cambridge]<br>
&gt; _______________________________________________<br>
&gt; Perl-XML mailing list<br>
&gt; [email protected]<br>
&gt; 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>
&gt; <br>
<br>
[attachment &quot;signature.asc&quot; 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==--