Jump to content

xsl:include


ckrudelux
 Share

Recommended Posts

then including an other xslt file with a body and head element would the xslt processor merge the elements making the style valid html or do you only want a small part of a template in the included file?

Edited by ckrudelux
Link to comment
Share on other sites

An XSLT file is a bunch of templates. xsl:include is applied on the top level (i.e. it's not part of templates) and merges the current set of templates with the templates in the pointed stylesheet.That's all it does... it's not like PHP's include which can be placed in arbitrary places around the code or XInclude which can be applied on arbitrary XML elements.So, with that in mind... I'm not sure I understand your question... it sounds like you're confusing it with XInclude.

Link to comment
Share on other sites

An XSLT file is a bunch of templates. xsl:include is applied on the top level (i.e. it's not part of templates) and merges the current set of templates with the templates in the pointed stylesheet.That's all it does... it's not like PHP's include which can be placed in arbitrary places around the code or XInclude which can be applied on arbitrary XML elements.So, with that in mind... I'm not sure I understand your question... it sounds like you're confusing it with XInclude.
I do know what I only can add the include in the beginning I was just thinking if the processor was so smart that it would know if I had two head element with different data in them if it would merge them or just ignore them, but I doubt it would work.. sure with some modification I suppose.
Link to comment
Share on other sites

What do you mean by "two head element"?Two different templates that target the head element, i.e(file1.xsl)

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

(file2.xsl)

<xsl:template match="head">...</xsl:template>

?If two templates end up matching a node, they will be prioritized and the one with the higher priority is going to win. Prioritization consist of analyzing the match pattern itself (more specific wins), and in case even that fails (as is the case above), the one that is furthest down in the source wins... in this case, the template in file1.xsl will win, because the template in file2.xsl is placed at the place of inclusion - above the template in file1.xsl.

Link to comment
Share on other sites

What do you mean by "two head element"?Two different templates that target the head element, i.e(file1.xsl)
<xsl:include href="file2.xsl"/><xsl:template match="head">..........</xsl:template>

(file2.xsl)

<xsl:template match="head">...</xsl:template>

?If two templates end up matching a node, they will be prioritized and the one with the higher priority is going to win. Prioritization consist of analyzing the match pattern itself (more specific wins), and in case even that fails (as is the case above), the one that is furthest down in the source wins... in this case, the template in file1.xsl will win, because the template in file2.xsl is placed at the place of inclusion - above the template in file1.xsl.

I will take that as a NO on my question. But the theories provided are always a good input thanks again on a greate anwser. :) I'm going to sleep now before I ask something else.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...