XSLT <xsl:import>
The <xsl:import> element is a top-level element that is used to import the contents of one style sheet into another.
Syntax
<xsl:import href="URI"/>Attributes
| Attribute | Value | Required/Optional | Description |
|---|---|---|---|
href |
URI | Required | Specifies the URI of the style sheet to import |
Example
Suppose you have a style sheet called "bookstore_style.xsl":
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>The bookstore</h2>
<table border="1">
<tr bgcolor="#6565d5">
<th>Title</th>
<th>Author</th>
</tr>
<tr>
<td><xsl:value-of select="bookstore/book/title"/></td>
<td><xsl:value-of select="bookstore/book/author"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>And a second style sheet called "bookstore_import.xsl" imports "bookstore_style.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="cdcatalog_ex3.xsl"/>
<xsl:template match="/">
<xsl:apply-imports/>
</xsl:template>
</xsl:stylesheet>