Skip to content

Instantly share code, notes, and snippets.

@MarkTiedemann
Created May 3, 2025 18:46
Show Gist options
  • Save MarkTiedemann/0e6d36c337159a3e6d5072ccb7d7f6fe to your computer and use it in GitHub Desktop.
Save MarkTiedemann/0e6d36c337159a3e6d5072ccb7d7f6fe to your computer and use it in GitHub Desktop.
<?xml-stylesheet href="shared-templates.xsl" type="text/xsl" ?>
<html lang="en">
<shared-header title="About"/>
<h1>About</h1>
</html>
<?xml-stylesheet href="shared-templates.xsl" type="text/xsl" ?>
<html lang="en">
<shared-header title="Contact"/>
<h1>Contact</h1>
</html>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" doctype-system="about:legacy-compat"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="shared-header">
<title>
<xsl:value-of select="@title"/>
</title>
<nav>
<xsl:if test="@title = 'About'">
<a href="./contact.xhtml">Contact</a>
</xsl:if>
<xsl:if test="@title = 'Contact'">
<a href="./about.xhtml">About</a>
</xsl:if>
</nav>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment