The xsl:import Element

The <xsl:import> Element

Like <xsl:include> , <xsl:import> enables you to insert a stylesheet or stylesheet fragment in another stylesheet. And like <xsl:include> , <xsl:import> has only one attribute:

  • href (mandatory). The URI of the stylesheet you want to include.

Also like <xsl:include> , <xsl:import> is empty and has no content. So whats the difference between <xsl:include> and <xsl:import> ? The difference lies in import precedence .

Import precedence gives the XSLT processor a way to settle any conflicts that may arise when, for example, two rules match the same node. The precedence of an imported stylesheet or stylesheet fragment is lower than the precedence of the stylesheet thats importing it. And if you import several stylesheets or stylesheet fragments , the first one has lower precedence than the one imported next , which has lower precedence than the one imported after it, and so on.

Otherwise, though, importing a stylesheet or stylesheet fragment looks much like including it, although you use <xsl:import> rather than <xsl:include>:

Listing 2.11 Importing a Stylesheet
 <?xml version="1.0"?>  <xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">      <xsl:import href="rules.xsl"/>      <xsl:template match="/PLANETS">          <HTML>              <HEAD>                  <TITLE>                      The Planets Table                  </TITLE>              </HEAD>              <BODY>                  <H1>                      The Planets Table                  </H1>                  <TABLE BORDER="2">                      <TD>Name</TD>                      <TD>Mass</TD>                      <TD>Radius</TD>                      <TD>Day</TD>                      <xsl:apply-templates/>                  </TABLE>              </BODY>          </HTML>      </xsl:template>  </xsl:stylesheet> 


Inside XSLT
Inside Xslt
ISBN: B0031W8M4K
EAN: N/A
Year: 2005
Pages: 196

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net