You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Bill Milbratz <mi...@gmail.com> on 2008/02/07 18:44:22 UTC

well-defined ant/xslt problem: (how) can I do this?

Hi,

i have a problem which I don't know if I can solve elegantly with ant.

The problem: I'd like to use the xslt task to transform these inputs into
the following outputs;

inputs:

 v10/changes.xml
 v11/changes.xml
 v12/changes.xml

outputs:
 v10/changes.out
 v11/changes.out
 v12/changes.out


To clarify: the inputs lie in subdirectories. I would like the xslt/ant to
send the outputs to "corresponding subdirectories".

In reviewing the xslt docs, it looks like I can only send the xslt output to
one directory (destdir attribute).

I've looked at using 'subant', but this gets pretty complex and hard to
follow.

any suggestions?

thanks,

bill

Re: well-defined ant/xslt problem: (how) can I do this?

Posted by Bill Milbratz <mi...@gmail.com>.
Thanks for the feedback everyone.

I used the 'for' with 'sequential' to get get iteration working. Yet Klaus'
answer provides what I was looking for.  The ant documentation of the xslt
task suggests 'destdir' is a specific directory. I didn't realize the
destdir would automatlically map the input directory structure.

bil l

Re: well-defined ant/xslt problem: (how) can I do this?

Posted by Martin Ficker <m....@googlemail.com>.
xslt does support a nested mapper. Something like this should work:

        <xslt includes="v*" style="transform.xsl" destdir=".">
            <mapper type="glob" from="*.xml" to="*.out"/>
        </xslt>         




Bill Milbratz schrieb:
> Hi,
>
> i have a problem which I don't know if I can solve elegantly with ant.
>
> The problem: I'd like to use the xslt task to transform these inputs into
> the following outputs;
>
> inputs:
>
>  v10/changes.xml
>  v11/changes.xml
>  v12/changes.xml
>
> outputs:
>  v10/changes.out
>  v11/changes.out
>  v12/changes.out
>
>
> To clarify: the inputs lie in subdirectories. I would like the xslt/ant to
> send the outputs to "corresponding subdirectories".
>
> In reviewing the xslt docs, it looks like I can only send the xslt output to
> one directory (destdir attribute).
>
> I've looked at using 'subant', but this gets pretty complex and hard to
> follow.
>
> any suggestions?
>
> thanks,
>
> bill
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: well-defined ant/xslt problem: (how) can I do this?

Posted by Brian Bassett <bb...@insightful.com>.
<foreach> requires that all the tasks to be nested within a <sequential>
element:

  <foreach list="v10,v11,v12" param="myVersion">
     <sequential>
       <antcall target="gen-changes">
          <param name="version" value="@{myVersion}"/>
       </antcall>
     </sequential>
  <foreach>

Brian

-----Original Message-----
From: Bill Milbratz [mailto:milbratz@gmail.com] 
Sent: Thursday, February 07, 2008 10:55 AM
To: user@ant.apache.org
Subject: Re: well-defined ant/xslt problem: (how) can I do this?

A follow-up:

I tried the using the ant-contrib for each, and manually specifying the
versions in a list, but came across a limitation:

pe\build-developer.xml:1217: foreach doesn't support the nested "antcall"
element.

(I've implemented the internals for the for-each using antcall);

can anyone comment on limitation of the ant-contrib looping mechanism?

  <foreach list="v10,v11,v12" param="myVersion">
    <antcall target="gen-changes">
       <param name="version" value="@{myVersion}"/>
    </antcall>
  <foreach>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: well-defined ant/xslt problem: (how) can I do this?

Posted by James Fuller <ja...@gmail.com>.
u might have luck having the foreach call a macrodef (just make the
target into a macrodef)

hth, Jim Fuller

On Feb 7, 2008 7:55 PM, Bill Milbratz <mi...@gmail.com> wrote:
> A follow-up:
>
> I tried the using the ant-contrib for each, and manually specifying the
> versions in a list, but came across a limitation:
>
> pe\build-developer.xml:1217: foreach doesn't support the nested "antcall"
> element.
>
> (I've implemented the internals for the for-each using antcall);
>
> can anyone comment on limitation of the ant-contrib looping mechanism?
>
>   <foreach list="v10,v11,v12" param="myVersion">
>     <antcall target="gen-changes">
>        <param name="version" value="@{myVersion}"/>
>     </antcall>
>   <foreach>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: well-defined ant/xslt problem: (how) can I do this?

Posted by Barry Pape <bp...@netspend.com>.
There is a target attribute for the foreach task. So I'm thinking you
would want to do something like this:
  <foreach target="gen-changes" list="v10,v11,v12" param="myVersion"/>



-----Original Message-----
From: Bill Milbratz [mailto:milbratz@gmail.com] 
Sent: Thursday, February 07, 2008 12:55 PM
To: user@ant.apache.org
Subject: Re: well-defined ant/xslt problem: (how) can I do this?

A follow-up:

I tried the using the ant-contrib for each, and manually specifying the
versions in a list, but came across a limitation:

pe\build-developer.xml:1217: foreach doesn't support the nested
"antcall"
element.

(I've implemented the internals for the for-each using antcall);

can anyone comment on limitation of the ant-contrib looping mechanism?

  <foreach list="v10,v11,v12" param="myVersion">
    <antcall target="gen-changes">
       <param name="version" value="@{myVersion}"/>
    </antcall>
  <foreach>

-----------------------------------------
Confidentiality Notice!
This electronic transmission and any attached documents or other
writings are confidential and are for the sole use of the intended
recipient(s) identified above. This message may contain information
that is privileged, confidential or otherwise protected from
disclosure under applicable law. If the receiver of this
information is not the intended recipient, or the employee, or
agent responsible for delivering the information to the intended
recipient, you are hereby notified that any use, reading,
dissemination, distribution, copying or storage of this information
is strictly prohibited. If you have received this information in
error, please notify the sender by return email and delete the
electronic transmission, including all attachments from your
system.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: well-defined ant/xslt problem: (how) can I do this?

Posted by Bill Milbratz <mi...@gmail.com>.
A follow-up:

I tried the using the ant-contrib for each, and manually specifying the
versions in a list, but came across a limitation:

pe\build-developer.xml:1217: foreach doesn't support the nested "antcall"
element.

(I've implemented the internals for the for-each using antcall);

can anyone comment on limitation of the ant-contrib looping mechanism?

  <foreach list="v10,v11,v12" param="myVersion">
    <antcall target="gen-changes">
       <param name="version" value="@{myVersion}"/>
    </antcall>
  <foreach>

Re: well-defined ant/xslt problem: (how) can I do this?

Posted by "Denis N. Antonioli" <an...@ifi.unizh.ch>.
Hi

Disclaimer: this tip assumes that you're using ant 1.7

The xsl task can pass to the xsl the name of the file being processed  
(see attributes filedirparameter  and filenameparameter)

You can then:
in ant:
- use a fileset to let the xsl task process all of the changes.xml;
- use filedirparameter and/or filenameparameter to let your xsl know  
the name of the file being processed;
- pass the name of the output directory as a parameter to the xsl

in xsl:
- derive the name of the output file from the name of the input file
- use xsl extension to redirect the output to a different file


The only downside to this method is that the xsl task will create an  
empty output file, which you can delete from ant.


This is the outline of an answer ;-)

Best
	dna

On 7 févr. 08, at 09:44, Bill Milbratz wrote:

> Hi,
>
> i have a problem which I don't know if I can solve elegantly with ant.
>
> The problem: I'd like to use the xslt task to transform these inputs  
> into
> the following outputs;
>
> inputs:
>
> v10/changes.xml
> v11/changes.xml
> v12/changes.xml
>
> outputs:
> v10/changes.out
> v11/changes.out
> v12/changes.out
>
>
> To clarify: the inputs lie in subdirectories. I would like the xslt/ 
> ant to
> send the outputs to "corresponding subdirectories".
>
> In reviewing the xslt docs, it looks like I can only send the xslt  
> output to
> one directory (destdir attribute).
>
> I've looked at using 'subant', but this gets pretty complex and hard  
> to
> follow.
>
> any suggestions?
>
> thanks,
>
> bill

-- 
The Laws of Computer Programming
* Cahn's Axiom *
When all else fails, read the instructions.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: well-defined ant/xslt problem: (how) can I do this?

Posted by Klaus Malorny <Kl...@knipp.de>.
Bill Milbratz wrote:
> Hi,
>
> i have a problem which I don't know if I can solve elegantly with ant.
>
> The problem: I'd like to use the xslt task to transform these inputs into
> the following outputs;
>
> inputs:
>
>   v10/changes.xml
>   v11/changes.xml
>   v12/changes.xml
>
> outputs:
>   v10/changes.out
>   v11/changes.out
>   v12/changes.out
>
>
> To clarify: the inputs lie in subdirectories. I would like the xslt/ant to
> send the outputs to "corresponding subdirectories".
>
> In reviewing the xslt docs, it looks like I can only send the xslt output to
> one directory (destdir attribute).
>
> I've looked at using 'subant', but this gets pretty complex and hard to
> follow.
>
> any suggestions?
>
> thanks,
>
> bill
>

Hi Bill,

I don't understand the problem. The destination directory is only the base 
directory to which the relative paths are appended. I just tried the following 
build file with Ant 1.6.5 (nothing newer at hand at the moment):

<project default="test">
   <target name="test">
     <xslt extension=".out" style="style.xsl" includes="**/changes.xml"
       destdir="."/>
   </target>
</project>

with the file structure:

./v10
./v10/changes.xml
./v11
./v11/changes.xml
./v12
./v12/changes.xml
./build.xml
./style.xsl

and this did exactly what I think you want. With 1.7.0 you can also define the 
input files via resource collections (i.e. <fileset> and so on), which gives you 
more freedom to select the individual input files. Also, with the help of the 
<mapper> subelement, you can map the input path to an output path, using a 
variety of operations.

Regards,

Klaus



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org