garlicDoge
garlicDoge

Reputation: 197

Copy XML file structure (incl.) directories with XSLT (2.0)

Meta

I want to write a stylesheet (XSLT 2.0) that simply copies a whole file structure (I use a XML root file with linked other files in it) and places the result(s) into a certain destination folder.

How can I do this? What would be the best and effective way of doing this?

Upvotes: 0

Views: 139

Answers (3)

DrMacro
DrMacro

Reputation: 656

To expand on Xephon's answer: you could generate an Ant script that then does the copying. If you have Oxygen then you also have the D4P net.sourceforge.dita4publishers.common.xslt plugin, which has code for generating an Ant copy script--it's used by the EPUB transform to manage the copying of resources from the source area to the EPUB temp directory from which the EPUB zip is created.

In that same plugin is the relpath_util.xsl module, which provides general XSLT functions for working with URLs and file paths in a Java-like way.

Mike's solution is obviously the easiest but is dependent on extensions.

Upvotes: 2

Michael Kay
Michael Kay

Reputation: 163312

Assuming that you have a good reason for doing this in XSLT (like, it's part of a larger task, or XSLT is your only programming language), you should take a look at the EXPath file module. The file:copy() function copies a directory.

http://expath.org/spec/file#fn.copy

It's available in Saxon-PE 9.6 or later/higher.

Upvotes: 2

Stefan Jung
Stefan Jung

Reputation: 1268

thank you for describing your toolset. If possible, you should simply do this using the Ant Copy Task. The DITA Open Toolkit uses Ant and Oxygen XML ships Ant as well.

Upvotes: 1

Related Questions