ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Agnew <>
Subject Re: Split XML file into seperate files with XSLT and ANT
Date Fri, 03 Dec 2004 16:06:30 GMT
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
  <b id="1" attr="n1">Number 1</b>
  <b id="2" attr="n2">Number 2</b>

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


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="${}"/>

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

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

Robert Soesemann wrote:

>Sounds perfect. Thanks for this hint. Did you every do something like this? Do you have
sample snippets ;-)
>Best regards,
>-----Original Message-----
>From: Brian Agnew [] 
>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 
>Robert Soesemann wrote:
>>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 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: <>  

Brian Agnew        
OOPS Consultancy Ltd         brian @
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message