Using XSLT to Format Output
VS-X-3 Using xslt() in VSPs
An alternative of the http_xslt()
Example
- This example displays user data using XSLT to customize the look.
- The result is the same as in VS-X-2, but XSL-T transformation is done in the VSP.
- The http_xslt() can be replaced (for main functionality) by the following:
- xml_tree_doc() over an XML document
- xslt() with XSL-T stylesheet URI and result from xml_tree_doc()
- http_value() with result from xslt()
- The above describes the steps that the web server makes in the VSP execution when http_xslt() is called. This is not a direct equivalent, because Content-Type is not manipulated, as it is with http_xslt(). This means that web server can setup a Content-Type if it's not specified, otherwise it is specified in xsl:output element.
- The same is true for encoding. If it is necessary to manipulate content-type with xsl:output, then use xml_tree_doc_media_type() to retrieve the media type from the XML entity, produced from xml-tree_doc(), and manually set 'Content-Type' header with http_header(). The above steps are useful for VSP&XSLT understanding, but in practice the http_xslt() is more suitable. The http_xslt() is most appropriate if all content that produces a VSP should be transformed.
- In the case where a piece of XML data is to be inserted in the middle of the HTML part of VSP, it cannot be done with http_xslt(). It may only be done with the step-by-step way above.
| View the source | Action |
|---|---|
| 1. shippers.vsp | Run |
| 2. shippers.xsl |
OpenLink Home
Technical Support