Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project


   







ELEMENT:  xsl:import

<xsl:import
  href="uri"
/>

 
The xsl:import element is used to add (import) one stylesheet to another. You can repeat this element in order to import more than one stylesheet.
 
The definitions and template rules of the importing stylesheet are treated as having greater importance that the definitions and template rules of the imported stylesheet. Using a formal definition, the importing stylesheet is said to have a greater "import precedence" over the imported stylesheet.
 
One very important aspect of the xsl:import element is that it allows you to access a library of reusable stylesheets to create a desired appearance for the output.
 
The xsl:import element can only be a child of the xsl:stylesheet or the xsl:transform elements. Further, the xsl:import element must be the first element to occur after the xsl:stylesheet element (for example, before any xsl:include elements). If there is more than one stylesheet being imported, the one that is imported first has a lower import precedence than the one that is imported second, the second has lower import precedence than the third, and so on.
 
The similar xsl:include element can also be used to add (include) a stylesheet to another, but the definitions and template rules of the included stylesheet are treated equal to the definitions and template rules of the including stylesheet.
 
The xsl:apply-imports element is used to invoke (apply) any definitions and template rules of the imported stylesheet that have been overridden by the importing stylesheet.
 
A stylesheet should not import itself.
 
This is a self-closing element and it cannot contain any child elements or any content.
 
href="uri"
 
The mandatory href attribute is either a relative or absolute URI (Uniform Resource Identifier) address of a valid stylesheet to be imported. A relative URI is resolved against the base URI of the XML source document.
 
We use the DevGuru Staff List XML file for our example with the following header:
<?xml-stylesheet type="text/xsl" href="xslt_example_import.xsl"?>
and we name it: xslt_example_import.xml
 
We import and apply: xslt_example_choose.xsl
(will appear in separate window - use "view source" to see code)
 
Code for xslt_example_import.xsl:
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="xslt_example_choose.xsl" />
<xsl:template match="/">
<html>
<body>
<xsl:apply-imports />
</body>
</html>
</xsl:template>
</xsl:stylesheet>

 
Output:
 
Click to view output in separate window - requires Internet Explorer

 
 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information