[xsl] Split files with XSLT2.0 xsl:result-document

Subject: [xsl] Split files with XSLT2.0 xsl:result-document
From: "Robert Soesemann" <rsoesemann@xxxxxxxxxxx>
Date: Mon, 6 Dec 2004 15:46:39 +0100
Hello,

I am sure that <xsl:result-document> is perfect for my purpose. But I
still struggle with the following task. I have a (deep) folder structure
${in_dir} with xml files. Each file might hold multiple elements of type
contentitem
e.g. the fictious file bar.xml.

<root>
  <contentitem>
	...
  </contentitem>
  <contentitem>
	...
  </contentitem>
  <contentitem>
	<anchor name="xyz"/>	<--- NOT ALL CONTENTITEM HAVE A <anchor>
	...
  </contentitem>
</root>

I need to split this in a way that I get one file per <contentitem>. But
I need to preserve the folder structure plus modify the resulting
filename based on node values.

E.g. the input file:

\in_dir
	\foo
		\bar.xml

Needs to be splitted to

\out_dir
	\foo
		\bar1.xml		<-- number unnamed fragments
		\bar2.xml		<-- number unnamed fragments
		\bar#xyz.xml	<-- use /anchor/@name for name extension

Can anybody help me to solve this? Thanks in advance!

Robert

Current Thread