This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

xsl:import vs xsl:include


Pranav wrote:
>           Can anyone please tell me the difference between <xsl:include> and
> <xsl:import> ?
>           I am also interested to know that in what situation we should use
> <xsl:include> and in what situation we should use <xsl:import>.

xsl:include just helps you modularize your stylesheets as far as splitting
them into separate files. The templates in these files all match with the
same precedence, so you can't have in one file, say,

  <xsl:include href="file2.xsl"/>
  <xsl:template match="foo">

and in file2.xsl
  <xsl:template match="foo">

because there would be a conflict.

xsl:import works the same way, but using imports you can have template rules
that match the same nodes:

  <xsl:import href="file2.xsl"/>
  <xsl:template match="foo"> <!-- overrides file2.xsl's version -->

So when you do an apply-templates select="foo", this one will match.
If you don't want to use that one, you do apply-imports.

So what imports do is gives you a way to put, in your imported stylesheets,
the "default" templates for various nodes, and in the stylesheets containing
the xsl:import you are providing the "overriding" templates.

   - Mike
____________________________________________________________________________
  mike j. brown, fourthought.com  |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  personal: http://hyperreal.org/~mike/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]