Jump to content

xsl:include


ckrudelux

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?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...