Send comment and bugs to:
Geert Josten and
Egon Willighagen
last modified on January 25th 2000.
XSA doc:
xslt-parser.xsa.
This discussion list is archived at
http://xmlxslt.listbot.com/.
|
You wrote some XML, and have a XSL Template. You want
to use this on your website, but want to use Perl with your webserver.
No Problem!
Remember that this project is Work in Progress! Rome wasn't build in
one day! Any comment is welcome! Any programming effort as well! This
modules *is* great stuff, but it isn't finished yet! However, if you need
a xsl command urgently, please email us your request and place it in our
high priority to-do list.
Egon
XML::XSLT will
convert the XML doc on basis of the template. It is written in Perl
and works. Not all xsl commands are implemented yet. Nor is it fast. But meanwhile
it works: watch it
in action.
At this moment we need a lot of input. So try this script and give us
your comment on it. Missing/needed xsl elements, bugs, anything...
This document gives some explanation on this project. Other
Stuff to read is the Specification of XSLT and the
XSL(T)-by-example page (see links). Below, given
is a list of XSLT-command's that are supported.
command |
supported |
comment |
xsl:apply-templates |
limited |
attribute select is supported as far as xsl:value-of
supports path selections |
xsl:call-template |
yes |
takes attribute name which selects xsl:template by name |
xsl:choose |
limited |
tests sequentially all xsl:whens until one succeeds or
until an xsl:otherwise is found. |
xsl:copy |
experimental in v0.16 |
takes no attributes, ignores content |
xsl:copy-of |
experimental in v0.16 |
takes attribute select, which selects likewise
apply-templates select |
xsl:for-each |
experimental in v0.16 |
most requested since 0.15 |
xsl:include |
yes |
takes attribute href, which can be relative-local
absolute-local as well as an URL (preceded by identifier http:) |
xsl:otherwise |
yes |
|
xsl:output |
no |
will be added if anyone needs it |
xsl:processing-instruction |
yes |
  |
xsl:stylesheet |
limited |
Just has to be present |
xsl:sub-template |
depricated! |
this used to implement nesting of template
instead of the use of apply-templates |
xsl:template |
limited |
attributes match and name are supported to some extend |
xsl:value-of |
limited |
attribute selection, element values.
Examples:
<xsl:value-of select="."/>
<xsl:value-of select="/root-elem"/>
<xsl:value-of select="elem"/>
<xsl:value-of select="//elem"/>
<xsl:value-of select="elem[n]"/>
<xsl:value-of select="//elem[n]"/>
<xsl:value-of select="@attr"/>
and combinations of these; |
xsl:when |
limited |
Only inside xsl:choose
Examples:
<xsl:when test="@attr='value'">
<xsl:when test="elem='value'">
<xsl:when test="path/[@attr='value']">
<xsl:when test="path/[elem='value']">
<xsl:when test="path/elem">
<xsl:when test="path/@attr"> |
xsl:if |
limited |
See xsl:when, except for the required xsl:choose context
|
xsl:text |
very limited |
Text is inserted as is, except for the entities <
and > which are translated to < and >
|
Oke, let's see it work. The script takes a project name
<project>. The files <project>.xml and <project>.xsl are
read and converted to an internal object tree with XML::DOM. Then the
XSL template is parsed against the XML tree, which results in a new doc
that is redirected to STDOUT. That's all.
Ofcourse, it need not be HTML. With XSLT you can convert any XML document
with any XSL doc you like.
NB! These are the updated examples. They only work with version
0.13 or higher.
This is the CML project:
- This project makes old CML files of the
Dictionary
on Organic Chemistry conform the newest CML DTD.
- 91-22-5.cml (old cml file)
- cml2cml.xsl (for cml to cml conversion)
- resulting 91-22-5.xml
- Please note that is you use IE 5.0 to view the result you
it gets parsed by the IE XSL parser for a XML2HTML conversion
due to the xsl stylesheet below. If so, use right mouse button
and view source to see the underlying xml file when viewing
the xml file with the stylesheet.
- cml.xsl
- The rest of the new CML files are served at the Dictionary
on Organic Chemistry project as Physical Properties
(example)
and at xmltree.com.
The Agenda project:
The script can be used as an CGI script, but also as a command-line
utility. Also accepts a XSL Template other than <project>.xsl.
These behaviours are selected with some options. Run xslt-parser
without options or parameters at the commandline to view its syntax.
the -n option
When a script is to be used with a web-server, its output must be preceeded
with a Content-type line. The xslt-parser script does this by default.
It can be turned off with the -n(oweb) option.
the -s option
By default the script uses the <project>.xsl XSLT template. With the
-s(tylesheet) <template.xsl> option other templates can be used.
The latest release is v0.18
which has experimental support for xsl:for-each, which needs testing.
Download version 0.15 of the script here. Both require
the modules XML::Parser (version 2.23 or higher) and XML::DOM (version 1.25 or higher)
which can be obtained from CPAN. Our module also depends on
the module LWP::UserAgent as was pointed out by a user. This module can also be downloaded from
CPAN.
A changelog is also available. Older version can be downloaded
from this page.
- xsl:template matches only /fullpath/elem, /fullpath/@attr, elem, @attr, * and @*
- xsl:value-of selects only any sequence of elem and elem[n] seperated and/or preceded by a slash '/' and/or followed by @attr
- xsl:apply-templates and xsl:for-each select-attribute do not support the selection of children of a node-set, instead fragment the
selection path into multiple (auxiliary-)templates.
Bugs can be submitted here.
To do:
- first implementation of xsl:param/xsl:variable/xsl:with-param
- mode attribute support for xsl:template and xsl:apply-templates
- POD-documentation and SVC file
- debugging ofcourse
- integration of the new XPath module (?)
- implementation of advanced template matches (better pattern matches and support of | [or])
- implementation of advanced value selections
- and at the end full support of XSL-T
XSL-T
Other
|