XslWebMaker Advanced Instructions - Subdirectories
First Published (Original Date):
2005-11-09%
Last Modified (Date):
2021-11-08 21:01
Datetime Format:
EDTF with spaces.
In your source directory you may want to organise your website by including subdirectories. Pages within your subdirectories well need special handling. For example, when these pages reference a common navigation menu system, the links within that menu will be slightly different.
-
In your source
.html
files that are within source subdirectories add<xwm:subDirectoryFlag />
... <xwm:commonHead /> <xwm:subDirectoryFlag /> <xwm:directoryDependantHead /> </head> <body> <xwm:navigation /> ...
-
In your
xwmToXhtml.xslt
define a variable, heredirectoryLevel
, that returns a string "../" if the<xwm:subDirectoryFlag />
element is in your source .html files.Wherever you need to have different urls depending on whether the page is in a subdirectroy or not, reference the
directoryLevel
variable.<xsl:variable name="directoryLevel" xml:space="no"> <xsl:choose> <xsl:when test="//*[local-name()='subDirectoryFlag']">../</xsl:when> <xsl:otherwise></xsl:otherwise> </xsl:choose> </xsl:variable> <!-- Needed to allow the subDirectoryFlag in the source doc --> <xsl:template match="*[local-name()='subDirectoryFlag']" xml:space="preserve"> </xsl:template> ... <xsl:template match="*[local-name()='directoryDependantHead']" xml:space="preserve"> <xsl:comment> directoryDependantHead start </xsl:comment> <link type="text/css" rel="stylesheet" href="{concat($directoryLevel, 'minimalist.css')}" /> <script type="text/javascript" src="{concat($directoryLevel, 'webDateTime.js')}"></script> <xsl:comment> directoryDependantHead Finish </xsl:comment> </xsl:template> ... <xsl:template match="*[local-name()='navigation']" xml:space="preserve"> <div id="navigation"> <ul> <li><a href="{concat($directoryLevel, 'index.html')}">Home</a></li> <li>Calendar <ul> <li><a href="{concat($directoryLevel, 'pastCalendar.html')}">Past</a></li> </ul> </li> <li><a href="{concat($directoryLevel, 'examplePlainPage.html')}">Example Plain Page</a></li> </ul> </div> </xsl:template>