Kraz
Kraz

Reputation: 7090

Is it possible to split a xslt file into multiples file?

I have a (currently) 3000 lines XSLT file, containing a bunch of templates. I have to add even more stuff to it and it's becoming pretty much unmanageable.

So could I split it and add includes of some sort?

Upvotes: 1

Views: 129

Answers (3)

pav
pav

Reputation: 480

You could create the new stuff you need to add in a separate XSL file and use xsl:include to give the templates, variables & params the same priority/precedence as in the main file. You could also then go on to refactor the existing templates into a few more manageable files and use xsl:include.

There is also xsl:import, which is similar to xsl:include, but gives the included files' templates, params, etc., a lower precendence than those in the xsl file including them.

If you use xsl:import, make sure this is what you mean to do, as any variables/params in the imported transform will be overridden by any of the same name defined in the main xsl file.

Upvotes: 0

Mike Sulyaev
Mike Sulyaev

Reputation: 96

"Refactoring" is it what you need, I believe, not just splitting and importing. At any moment refactoring takes twice as much time as you think it will.

Upvotes: 0

Christopher Creutzig
Christopher Creutzig

Reputation: 8774

That's what xsl:import is there for. (Note that it is not a simple textual file include, though.)

Upvotes: 2

Related Questions