You should be able to do something like the below (from the sourcecode download tests/examples). This creates named xml files output-n1.out.xml, output-n2.out.xml from the input
<a>
<b id="1" attr="n1">Number 1</b>
<b id="2" attr="n2">Number 2</b>
</a>


Any more queries drop me a line direct or there's an xmltask mailing list. See the web page for more details.

Brian

Ant invocations follow.....

<target name="test">
   <!-- call subtargets using 78.xml as the driver -->
   <xmltask source="78.xml">
     <call path="/a/b" target="ab" buffer="b_ab" inheritAll="true">
       <param name="1" path="text()"/>
       <param name="2" path="@attr"/>
       <param name="3" value="${os.name}"/>
     </call>
   </xmltask>
 </target>

 <target name="ab">
   <xmltask dest="output-${2}.out.xml">
     <insert path="/">
       <![CDATA[
         <root/>
       ]]>
     </insert>

     <insert path="/root">[1 = ${1}]</insert>
     <insert path="/root">[2 = ${2}]</insert>
     <insert path="/root">[3 = ${3}]</insert>
   </xmltask>
 </target>


Robert Soesemann wrote:

Sounds perfect. Thanks for this hint. Did you every do something like this? Do 
you have sample snippets ;-)

Best regards,

Robert

-----Original Message-----
From: Brian Agnew [mailto:[EMAIL PROTECTED] Sent: Freitag, 3. Dezember 2004 16:03
To: Ant Users List
Subject: Re: Split XML file into seperate files with XSLT and ANT



You can use xmltask with the <call> instruction. See http://www.oopsconsultancy.com/software/xmltask


Robert Soesemann wrote:



Hello,

I don't know if there is a standard way to do this, but maybe you have an idea.

I have many XML files which hold multiple XML fragments of a specific type <contentitem>..</contentitem> For an easy import of those seperate contentitems into a CMS it would be better to split those fragments up into different file (one contentitem per file).

As I am doing this inside an ant pipeline, I wonder if there is an elegant way to do this with a mixture of XSLT and other file tasks?

Can you help,

Robert
--
Robert Sösemann
Associate, Technology | Sapient

Kellerstr. 27
81667 München, Deutschland
Tel.: +49 89/552 987-143
Mobil: +49 162/2773-143
Fax: +49 89/552 987-100
Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>











-- Brian Agnew http://www.oopsconsultancy.com OOPS Consultancy Ltd brian @ oopsconsultancy.com Tel: +44 (0)7720 397526 Fax: +44 (0)20 8682 0012



Reply via email to