Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm actually glad to have found this example as I've been looking for verification that this is actually the correct approach to a master/slave template setup. However the examples provided did not work out of the box on tomcat - so just to help others who only knows how to copy paste here are a working tomcat set of master / slave files.</p> <p>Master.xsl :</p> <pre><code>&lt;?xml version="1.0" encoding="iso-8859-1" ?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" encoding="iso-8859-15" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="no"/&gt; &lt;!-- http://stackoverflow.com/questions/646878/master-stylesheet-sharing-in-xslt --&gt; &lt;xsl:template match="ms247"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;test&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div style="border: 1px solid black; width: 200px; float: left; margin: 10px; padding: 5px;"&gt; &lt;xsl:call-template name="left"/&gt; &lt;/div&gt; &lt;div style="border: 1px solid black; width: 200px; float: left; margin: 10px; padding: 5px;"&gt; &lt;xsl:call-template name="content"/&gt; &lt;/div&gt; &lt;div style="border: 1px solid black; width: 200px; float: left; margin: 10px; padding: 5px;"&gt; &lt;xsl:call-template name="right"/&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; &lt;/xsl:template&gt; &lt;xsl:template name="content"&gt; &lt;span style="color: red"&gt;Content template is empty - overrule in page template.&lt;/span&gt; &lt;/xsl:template&gt; &lt;xsl:template name="left"&gt; &lt;span style="color: red"&gt;Left template is empty - overrule in page template.&lt;/span&gt; &lt;/xsl:template&gt; &lt;xsl:template name="right"&gt; &lt;span style="color: red"&gt;Right template is empty - overrule in page template.&lt;/span&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>And slave.xsl:</p> <pre><code>&lt;?xml version="1.0" encoding="iso-8859-1" ?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:import href="master.xsl"/&gt; &lt;xsl:template name="content"&gt; ... apply something page-specific &lt;/xsl:template&gt; &lt;xsl:template name="right"&gt; And we have RIGHT content! &lt;!-- Execute matching template which is NOT triggered automatically --&gt; &lt;xsl:apply-templates select="params/param"/&gt; &lt;/xsl:template&gt; &lt;!-- And we do not define any left template --&gt; &lt;!-- Example --&gt; &lt;xsl:template match="ms247/params/param"&gt; Paramters on page: &lt;xsl:value-of select="@name"/&gt;&lt;br/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Hope this can help others - do not be shy to drop me a note.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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