Re: Xpath

Tim Brody <[email protected]> Tue, 11 Dec 2012 11:03:11 +0000
Newsgroups gmane.comp.lang.perl.xml
Message-ID <EMEW3|778e0a06e172d6a4a854b9877195a4eeoBAB3D04tdb2|ecs.soton.ac.uk|[email protected]>
--===============0804197002==
Content-Type: multipart/signed; micalg="pgp-sha1";
	protocol="application/pgp-signature";
	boundary="=-rh5esDwzffPyQ2kSDcvv"


--=-rh5esDwzffPyQ2kSDcvv
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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."=20
> 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:=20
>=20
> "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)."=20
>=20
> ... which tells me nothing about what an input callback is in this
> context, let alone why I might want to use it.=20
>=20
> 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?=20
>=20
> Daniel=20
>=20
>=20
>=20
> From:        Tim Brody <[email protected]>=20
> To:        [email protected]=20
> Cc:        Perl XML List <[email protected]>=20
> Date:        11/12/2012 10:25=20
> Subject:        Re: Xpath=20
> Sent by:        [email protected]=20
>=20
> ______________________________________________________________________
>=20
>=20
>=20
> 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".
>=20
> XML::LibXSLT also supports callbacks into Perl space, so you can mix
> and
> match XSLT and Perl in the same template.
>=20
> 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 ...
>=20
> --
> All the best,
> Tim.
>=20
> 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.=20
> >=20
> > On Mon, Dec 10, 2012 at 9:14 PM, Thomas Krichel
> <[email protected]>
> > wrote:
> >           Tod Harter writes
> >        =20
> >         > 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.
> >        =20
> >        =20
> >           Coming from Perl, I found it hard to learn as you have
> >           to unlearn procedural thinking.
> >        =20
> >           Cheers,
> >        =20
> >           Thomas Krichel
> >          http://openlib.org/home/krichel
> >        =20
> >         http://authorprofile.org/pkr1
> >                                                        skype:
> >         thomaskrichel
> >        =20
> >=20
> >=20
> >=20
> > --=20
> > 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
>=20
> [attachment "signature.asc" deleted by Daniel
> Perrett/ELT/UK/cambridge]
> _______________________________________________
> Perl-XML mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>=20


--=-rh5esDwzffPyQ2kSDcvv
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAABAgAGBQJQxxLvAAoJECwwMWpSkLVc0kkIALMI16djXJzq9JykbePDjUC6
FJrZUHLDMS4IHV2bfseJb0Oe5nmU4/voF5DykVkSI4z5CFgkR+t+owDkTTnNuLCl
53mAlyFN2QNSmCUCVm9sLCcAbDaJOD7t4b9n6szcri27itrbzagm6KlMZmD8ulV6
PYMsTjPTRsTC5fL6hlD4GShGqsLkjBcvY5yArJuTD7HzJwaQ4C7HiTkqKSrgruOf
rFI0O7npPND7Sekv1vHQRtNFdLd/r6G88hI5MjC+Xsb9pxF07Z9O3vjYtLqwrD/e
qmE0/H/uKTYYAFG1lu3f6DJdSBwucLYUuYd7Da3QloDxvRNHDrnlveR2XdSt/GU=
=/bPJ
-----END PGP SIGNATURE-----

--=-rh5esDwzffPyQ2kSDcvv--


--===============0804197002==
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

--===============0804197002==--