Perl Lecture Notes - June 1, 2002 - XML take 2
- Questions
- Summary of (3) perl assignments for this trimester
- May 4: GUI / LDAP
- May 18: perl-ish XML
- June 1: - optional - AxKit (this week)
- June 15: SOAP-Lite
- June 28: - optional -
- July 13: - optional -
- July 27: Capstone Presentations
- web publishing with AxKit
- What it is
- Apache/mod_perl handler that transforms XML to
HTML or whatever.
- Does several kinds of transformations:
XSLT, XPathScript, XSP, custom SAX
- Installation and Configuration
- AxKit.pm is just a perl module - but
it has a lot of dependencies on other XSL transform
engines and what-not.
- installation details
- Configuration is from with apache's httpd.conf,
like the mod_perl handler stuff we've seen before.
- axkit.conf ("Include"-ed from httpd.conf)
- All and all this is is a PITA (as Brandt would say).
In particular, the documentation is not at all clear,
and the examples didn't work easily.
I had to
do a lot of trial-and-error and staring at the source,
and turning on the debugging, and looking at
/home/httpd/logs/error_log .
- To work with this system you really need to
have a feel for the Apache/mod_perl stuff.
- How it works
- Browser requests http://..../file.xml
- A transformation mechanism(s) is set by
axkit.conf or <?xml-stylesheet...> or agent type
(browser vs phone)
Transformations include
- XSL - as specified in some file.xsl
- XPathScript - perl-ish language similar to XSL,
mostly specific to AxKit - as specified in some file.xps
- XSP - ASP/JSP-like tag libraries of functions
(including user-defined ones) to generate dynamic
content, including session management, cookies,
authorization, SQL database queries, and so on.
(XSP is from the Cocoon Apache/Java project;
this is a perl implementation that uses perl syntax
for the <xsp:logic ...> tags. )
- other SAX filters or pipes or custom transformations
- Final output is .html or .txt or .pdf or .jpeg or
whatever, depending on the nature of the original xml
source and transformation.
- Examples
- Configuration for all these is
axkit.conf.
- Note that all URI's with /axkit/ go through AxKit.
I have aliases /not-axkit/ to the same directory,
giving a second URI path that avoids AxKit.
- Camel - xml to html conversion
- using XSL (yet another language to learn, eh?)
- using XPathScript - a perl-ish XPath and XSL
- XSP - eXtensible Server Pages.
This example shows a pipeline: xsp -> xsl -> html
- docbook and WAP/WML
- A more realistic example.
DocBook is an established xml format for
books. Here we can display that in several ways:
screen, printer, handheld.
This example uses XPathScript for the transformation.
The stylesheet version is chosen either by
(1) ?title=printer URI arguments, or
(2) by the HTTP request parameters.
-
docbook xml source
- screen (i.e. web browser) :
output |
XPathScript
- print (i.e. all on one page) :
output |
XPathScript
- handheld :
poor-mans-handheld |
wapalizer |
XPathScript
- AxPoint
- Another fairly realistic example. This one
converts an xml syntax into a .pdf
slideshow presentation, using a SAX processor
which can be called from AxKit.
- source
- pdf presentation
(Best viewed with Acrobat's Reader.
Save this link as example.pdf if your browser
doesn't launch a .pdf viewer correctly.)
- XML-Handler-AxPoint.pm - perl SAX handler code that does the transformation
- Resources and Documentation
- acronyms
- General XML and Perl
- AxKit
- SAX
- AxPoint - PDF presentations from XML
- DocBook
- an XML system for structured documents
- WAP and WML - HTTP and HTML for handhelds
- Assignmnent
- Work on capstones
- Browse through the articles and documentation above.
- Some suggested things to do to get familiar with
some of this.
**Entirely optional**
- Install AxKit
- Work though - install, alter - any of the online examples.
- Play around with AxKit on bob (any directory with /axkit/ in path).
You can, I think, add configuration instructions in
an .htaccess file.
- Write a SAX filter to do some XML processing on your data.
- Write some pages that can be displayed on a handheld or phone,
similar to what I did with docbook.
So there.