|Version 22 (modified by 13 years ago) ( diff ),|
Table of Contents
S3XML On-the-fly Transformation
At a glance
S3XRC can perform XSLT transformation of XML/JSON sources on-the-fly upon data export and import.
The XSLT stylesheets to use for this transformation can be either (fallback cascade in this order):
- a static file on the server or a web URL
- a file attached to the request (at import)
- an integrated stylesheet of Eden (folder static/formats)
- formats *.xml and *.json will not be attempted to transform
- PDF, CSV and XLS formats do not (yet) support on-the-fly transformation (subject to change in future versions)
Eden comes with a number of integrated XSLT stylesheets for various formats. These will be automatically used if no other stylesheet is specified (fallback). The integrated stylesheets reside in:
- static/formats/<format>/export.xsl for export transformation (S3XML into other format)
- static/formats/<format>/import.xsl for import transformation (other format into S3XML)
- pfif/import.xsl transforms from *.pfif
- pfif/export.xsl transforms to *.pfif
If the HTTP content type of the respective format is not
application/xml, then it must be configured in
models/00_settings.py (see there).
As of version S3XRC-2.2.0, internal stylesheets still have to be configured in
models/00_settings.py in order to be properly applied. This is subject to change in future versions.
XSLT Stylesheets on the Server
You can use the URL variable
?transform= to specify a transformation stylesheet at a file location on the server, e.g.:
...to use the stylesheet from
/use/share/stylesheets/export.pfif for this export.
- the Eden web server must be permitted to access this location
- you must not specify "xml" or "json" as data format of the resource, otherwise this will suppress any transformation attempt
- this currently assumes that the data format is an XML format and not JSON (subject to change in the near future)
XSLT Stylesheets on the Web
You can use the URL variable
?transform= to specify a transformation stylesheet at a web URL, e.g.:
...to use the stylesheet at
http://vita.sahanafoundation.org/eden/static/xslt/export/pfif.xsl for this export.
- you must not specify "xml" or "json" as data format of the resource, because that will suppress any transformation attempt
- this currently assumes that the data format is an XML format and not JSON (subject to change in the near future).
This feature is especially useful to create custom feeds to integrate into remote sites, e.g. RSS:
- create your own
rss.xslto transform S3XML into RSS
- place it on a public (e.g. your own) web server, say
- provide a link to Eden resources using your RSS stylesheet:
Basically that means, that a remote site do not need to implement their own XSLT transformation engine in order to integrate with Eden. They just need to have the XSLT stylesheet, and then let the Eden engine transform the data from/into the format they want/have.
Of course this does work with other formats as well, e.g. KML (if you want to provide a map rather than a feed link) etc
Attached XSLT Stylesheets
For data import, an XSLT stylesheet to transform foreign XML into S3XML can be attached to the request.
The filename of the attached stylesheet is expected to be
<resourcename> is the name of the target resource (without application prefix, e.g.
xsl:importwill need absolute paths in this case (safer to avoid these)