[Melbourne-pm] Using perl libraries to apply XSL to XML
daniel at rimspace.net
Tue Mar 24 05:39:28 PDT 2009
Ben Marsh <blmarsh at gmail.com> writes:
> I am writing a www bot that gets xml from a website that includes a
> xsl stylesheet to apply to the xml to give html. Browsers seem to do
> this for us when browsing the site.
Well, modern ones do. I still remember the days before XSLT support was
> WWW::Mechanize does not seem to?
No, although you could theoretically write a plugin...
> I wrote some code but hit a conundrum.? How do I get the url of the
> xsl from the xml content, fetch it via http and apply it to the xml
> using XML::LibXSLT?
> the xml starts with:
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xsl" href="/something.xsl"?>
See that line? That is a standard and all, so you can (reasonably)
robustly rely on that stylesheet declaration together with the standard
HTTP rules for URL combination to locate and fetch the stylesheet.
More information about the Melbourne-pm