Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > b3bdfe6d859a3d6920ff2c44b38e9a6f > files > 3124

saxon-manual-9.4.0.9-2.mga7.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="xsl-elements" page="result-document" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: xsl:result-document</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: xsl:result-document"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>xsl:result-document</h1>
      <p>The <code>xsl:result-document</code> element is new in XSLT 2.0, and replaces the previous extension element
<code>saxon:output</code>. It is used to direct output to a secondary output destination. </p>
      <p>The <code>format</code> attribute is optional. If present,
it gives the name of an <code>xsl:output</code> element that describes the serialization
format for this output document; if absent, the unnamed <code>xsl:output</code> declaration
is used.</p>
      <p>The <code>href</code> attribute gives the URI for the result document. If this is a relative
URI, it is interpreted relative to the base output URI. The base output URI is the systemID of the Result object
supplied as the destination for the transformation, or if you are using the command line, the value
of the <code>-o</code> flag. If the <code>href</code> attribute is omitted, the document is written
to the location identified by the base output URI: this will only work if all the output produced
by the stylesheet is within the scope of an <code>xsl:result-document</code> instruction.</p>
      <p>If the base output URI is not known, then the current directory is used, unless the configuration
disables calling of extension functions, in which case it is assumed that the stylesheet is not trusted to
overwrite files relative to the current directory, and an error is then reported.</p>
      <p>This base output URI must be a writable location. Usually it will therefore be a URI
that uses the "file:" scheme. However, Saxon attempts to open a connection whatever URI scheme
is used, and it should therefore work with any URI where the Java VM has the capability to open
a writable connection. Users have reported success in using "ftp:" and "mailto:" URIs.</p>
      <p>The optional <code>validation</code> and <code>type</code> attributes determine what
happens to any type annotations on element or attribute nodes. These values must not be used in 
the basic Saxon product.</p>
      <p>The <code>xsl:result-document</code> instruction may also take
serialization attributes such as <code>method</code>, <code>indent</code>, or <code>saxon:indent-spaces</code>.
These attributes may be AVTs, so the values can be decided at run-time. Any values specified on the
<code>xsl:result-document</code> instruction override the values specified on the <code>xsl:output</code>
declaration.</p>
      <p>Here is an example that uses xsl:result-document:</p>
      <div class="codeblock"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">
         <pre>
            <code>&lt;xsl:template match="preface"&gt;
    &lt;xsl:result-document href="{$dir}/preface.html" method="html"&gt;
        &lt;html&gt;&lt;body bgcolor="#00eeee"&gt;&lt;center&gt;
            &lt;xsl:apply-templates/&gt;
        &lt;/center&gt;&lt;hr/&gt;&lt;/body&gt;&lt;/html&gt;
    &lt;/xsl:result-document&gt;
    &lt;a href="{$dir}/preface.html"&gt;Preface&lt;/a&gt;
&lt;/xsl:template&gt;</code>
         </pre>
      </div>
      <p>Here the body of the preface is directed to a file called preface.html (prefixed
by a constant that supplies the directory name). Output then reverts to the previous destination,
where an HTML hyperlink to the newly created file is inserted.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="sequence.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>