http://www.zorba-xquery.com/modules/languages/xslt

Description

Before using any of the functions below please remember to import the module namespace:

import module namespace xslt = "http://www.zorba-xquery.com/modules/languages/xslt";
This module provides XSLT 1.0 transformation functionality.

For details on XSLT see XSLT 1.0 specification.

This module implements the invoking of an XSLT transformation from XQuery described in Michael Kay's proposal.

Example:

import module namespace
        xslt = "http://www.zorba-xquery.com/modules/languages/xslt";
 let $source :=
     <catalog>
         <cd>
           <title>Empire Burlesque</title>
           <artist>Bob Dylan</artist>
           <country>USA</country>
           <company>Columbia</company>
           <price>10.90</price>
           <year>1985</year>
         </cd>
         <cd>
           <title>Hide your heart</title>
           <artist>Bonnie Tyler</artist>
           <country>UK</country>
           <company>CBS Records</company>
           <price>9.90</price>
           <year>1988</year>
         </cd>
     </catalog>
 let $stylesheet :=
   <xsl:stylesheet version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="/">
       <html>
       <body>
       <h2>Music Collection&lt;/h2>
         <table border="1">
           <tr bgcolor="lightblue">
             <th>Title&lt;/th>
             <th>Artist&lt;/th>
           </tr>
           <xsl:for-each select="catalog/cd">
            <tr>
              <td>&lt;xsl:value-of select="title"/></td>
              <td>&lt;xsl:value-of select="artist"/></td>
           </tr>
           </xsl:for-each>
         </table>
       </body>
       </html>
     </xsl:template>
   </xsl:stylesheet>
 return
   xslt:transform( $source, $stylesheet)

Module code

Here is the actual XQuery module code.

Authors

Cezar Andrei

Version Declaration

xquery version "1.0" encoding "utf-8";

Namespaces

verhttp://zorba.io/options/versioning
xslthttp://www.zorba-xquery.com/modules/languages/xslt

Function Summary

transform($source as node(), $stylesheet as node()) as node() external

Invokes an XSLT transformation.

Functions

transform#2

declare function xslt:transform(
    $source as node(),
    $stylesheet as node()
) as node() external

Invokes an XSLT transformation.

Parameters

  • $source

    the input document to the transformation

  • $stylesheet

    the XSLT stylesheet module

Returns

  • node()

    the result tree produced by the transformation

Errors

  • xslt:XSLT001

    if $stylesheet is not a valid XSLT stylesheet

  • xslt:XSLT002

    if result can not be imported

Examples