c00ke
c00ke

Reputation: 2315

Xslt apply import for particular imported file?

Is there a way to apply import for a particular imported file and not all the files imported?

Basically only want to do apply import for a certain import based on some value evaluated.

For example in pseudo,

If value = "Medical" then Do Medical Imported File apply imports Else If value = "Transport" Then Do Transport Imported File apply Imports

Cheers

Upvotes: 2

Views: 537

Answers (3)

c00ke
c00ke

Reputation: 2315

Solved - Instead of doing apply import used include and call template and allow the include files dictate whether to process or not.

Upvotes: 0

Teun D
Teun D

Reputation: 5099

I think that maybe using a mode on apply-imports would help you out? But if you want to indicate templates from a specific source, you could maybe do this using modes.

Upvotes: 0

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243539

For XSLT 1.0 the answer is negative. However you may use modes to simulate similar behavior.

In XSLT 2.0 there is the xsl:use-when attribute that may be present on any XSLT instruction, including <xsl:import>, however the conditions that may be tested in it are severely limited. To quote the Spec:

"There are no syntactic constraints on the XPath expression that can be used as the value of the use-when attribute. However, there are severe constraints on the information provided in its evaluation context. These constraints are designed to ensure that the expression can be evaluated at the earliest possible stage of stylesheet processing, without any dependency on information contained in the stylesheet itself or in any source document"

Upvotes: 1

Related Questions