Note that there are some explanatory texts on larger screens.

plurals
  1. POmaster stylesheet sharing in XSLT
    primarykey
    data
    text
    <p>i would like to create a master template in XSLT, which could be stored in a separate file. Every other Page stylesheets share it, with xsl:import. </p> <p>master.xslt </p> <pre><code> &lt;xsl:template match="Page"&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;call-template name="Content"/&gt; &lt;/body&gt; &lt;/html&gt; &lt;/xsl:template&gt; &lt;xsl:stylesheet&gt; </code></pre> <p>page.xslt</p> <pre><code>&lt;xsl:stylesheet&gt; &lt;xsl:import href="master.xslt"/&gt; &lt;xsl:template match="/"&gt; &lt;apply-templates match="Page"/&gt; &lt;/xsl:template&gt; &lt;xsl:template name="Content"&gt; ... apply something page-specific &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>page.xml</p> <pre><code>&lt;Page&gt; ... something page-specific &lt;/Page&gt; </code></pre> <p>Can i improve this solution?</p> <ul> <li>i cannot start from master stylesheet, because i will need xsl:import everything. </li> <li>i dont want master.xslt contain references on each particular page.</li> </ul> <p>Another decision (which is against the xslt spirit) maybe such:</p> <p>master.xslt </p> <pre><code>&lt;xsl:template name="masterHead"&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;/xsl:template&gt; &lt;xsl:template name=masterEnd&gt; &lt;/body&gt; &lt;/html&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>page.xslt</p> <pre><code>&lt;xsl:stylesheet&gt; &lt;xsl:import href="master.xslt"/&gt; &lt;xsl:template match="/"&gt; &lt;call-template name=masterHead&gt; ... apply something page-specific &lt;call-template name=masterEnd/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>we don't need any general root <code>&lt;Page&gt;</code> element.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload