Polymorphism in XSL
Note the bold-faced part
- PageFrm.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="x.xsl"/>
<xsl:template match="/">
<html>
<head>
<title>Test</title>
</head>
<body>
<h1>Current page is</h1>
<xsl:call-template name="Content"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
- PageA.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="PageFrm.xsl"/>
<!-- Invoked by PageFrm.xsl -->
<xsl:template match="Content">
PageA
</xsl:template>
</xsl:stylesheet>
- PageB.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="PageFrm.xsl"/>
<!-- Invoked by PageFrm.xsl -->
<xsl:template match="Content">
PageB
</xsl:template>
</xsl:stylesheet>
Run PageA.xsl and PageB.xsl, you will see the different result.