<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="using-xsl" page="packaged-xslt" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Packaged Stylesheets</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Packaged Stylesheets"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Packaged Stylesheets</h1>
      <p>A new facility is available in Saxon 9.4 allowing an XSLT stylesheet to be distributed to users in a format
       such that the source code of the stylesheet is not readily visible. Creating a packaged stylesheet requires
       Saxon-PE or Saxon-EE; running the stylesheet only requires Saxon-HE, provided that it only uses features
       that are available with Saxon-HE.</p>
      <div class="boxed"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">This feature is not currently available on .NET</div>
      <p>The stylesheet is distributed in the form of a ZIP file; the format of the content is not strongly encrypted,
       but requires non-trivial effort to decompile. The ZIP package contains all the stylesheet modules that are needed.</p>
      <p>To create the package for distribution, use the following command:</p>
      <p class="command">java com.saxonica.ptree.StylesheetPackager stylesheet.xsl package.zip</p>
      <p>where <code>stylesheet.xsl</code> is the principal stylesheet module, and <code>package.zip</code>
       is the output file containing the packaged stylesheet.</p>
      <p>Running the stylesheet requires both the normal Saxon executable JAR file (HE or higher), and also the
       JAR file <code>saxon9-unpack.jar</code> which is included as standard in each Saxon edition. This contains
       Saxonica-proprietary code issued in compiled form only (not open source), but it does not require a license
       key to run. To run the stylesheet, use a command such as the following (on a single line):</p>
      <p class="command">java -cp saxon9he.jar;saxon9-unpack.jar net.sf.saxon.Transform
           -xsl:package.zip -s:source.xml -r:com.saxonica.ptree.PackageURIResolver -u:on</p>
      <p>In this command, the <code>-r</code> option sets a URIResolver that has the task of retrieving
       obfuscated stylesheet modules from the ZIP file, and the <code>-u</code> option ensures that this
       URIResolver is used for the main stylesheet module (here <code>package.zip</code>) as well as
       for resolving <code>xsl:include</code> and <code>xsl:import</code> references between modules.</p>
      <p class="subhead">Limitations</p>
      <p>Some care is needed with operations that depend on the static base URI. This is interpreted as
       the location of the packaged stylesheet at the time it is executed, not the original location at
       the time it was compiled. However, there is no limitation on the URIs that can be used in
       <code>xsl:include</code> and <code>xsl:import</code> declarations - the original URIs appearing
       in the source code will be replaced with references to the obfuscated modules within the generated ZIP file.</p>
      <p>Use of the <code>document('')</code> function to access the source stylesheet is best avoided.</p>
      <p>There is no special handling of schema documents referenced by the stylesheet. The packaged stylesheet
       does not include any imported schema; this must be distributed separately. The version of the schema used
       for validating documents at run-time must be consistent with the version used for compiling the stylesheet.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="xsltfromant.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>