Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Include and Import

 
Hari babu
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Whats the difference bertween xsl:include and xsl:import ?

Hari
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a beginner in XML. Let me try to answer the question.
�The xsl:include element is basically a macro substitution - the element is replaced by the contents of stylesheet it references
�With xsl:include the stuff that is macro-substituted into the stylesheet has the same precedence as the rest of the stylesheet. It is as though you had one stylesheet.
�With xsl:import the stuff that is macro-substituted into the stylesheet has lower precedence than the rest of the stylesheet.
 
Vasudha Deepak
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<xsl:include> is used when you want to use the contents of the stylesheet you are including,as is is no modifications are made to it.
The precedence of the included stylesheet is the same and the stylesheet including it.
<xsl:import> is used when the content you are importing from another stylesheet,may be modified in the stylesheet importing it.The precedence of the imported stylesheet is lower than the stylesheet importing it.Example::If Stylesheet A imports B, then precedence of B is lower than A's precedence.But if B imports C,then precedence of C will be higher than B,but lower than A.So it's going to be A C B,in the order of decresing precedence.
Hope this helps.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more main difference is that <xsl:include> can include a stylesheet anywhere in between templates within the scope of <xsl:stylesheet/>, whereas <xsl:import> can be inserted only as an immediate child of the <xsl:stylesheet> element;
Hence if we want the templates of a foreign stylesheet to take control of the transformations, we need to have <xsl:include> AFTER their respective template counterparts in the including stylesheet;
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vasudha Deepak
I don't think you are correct here according to the w3 spec:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic