You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Dave Pawson <da...@gmail.com> on 2008/04/11 09:42:15 UTC

arg and jvmarg

http://ant.apache.org/manual/using.html#arg

mentions using <arg value in preference to <arg line=

For an xslt task I want to specify
-o filename

Trying this

 <arg value="-l"/>
    <arg value="-o ${out.dir}/${main.outfile}"/>

The single '-l' works OK,
but the -o option causes a problem with the processor.

How can I specify '-o filename' for <arg/> please?

<arg line='-o filename'/>  works fine.


TIA

-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

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


Re: arg and jvmarg

Posted by Dave Pawson <da...@gmail.com>.
On 16/04/2008, Steve Loughran <st...@apache.org> wrote:

> > I've given up with the xslt task now;
> > Need it to handle a different parser (xercesImpl) for xIncludes
> > and Apache resolver.jar for catalogs - I don't think
> > the xslt task can hack that?
> >
>
>  -you should be using xercesImpl from ANT_HOME/lib anyway...drop in a new
> version if you want to change that.
>  -resolver.jar is used for catalog resolution; I dont know what happens with
> xincludes
>
>  if xinclude doesnt work when resolver.jar is on the classpath, that's a
> feature to fix...

See the <java example earlier.
Saxon needs the parser specifying with -x command line option?
 <arg line="-x org.apache.xml.resolver.tools.ResolvingXMLReader"/>
   <arg line="-y org.apache.xml.resolver.tools.ResolvingXMLReader"/>
   <arg line="-r org.apache.xml.resolver.tools.CatalogResolver "/>
I don't think (I'm not 100% sure though) it is available using a -D
system property.
Since <xslt/> task doesn't allow for 'command line' arguments of this type,
I don't think I can get it to work?

There is also an outsanding bug relating to Saxon
linked from a page with a solution
http://vocaro.com/trevor/blog/2007/01/08/how-to-use-saxon-with-ant/
so it's all looking a bit messy?

I tried it with Xalan but that seems not to support the parser selection using
the <factory/> child :-)

regards



-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

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


Re: arg and jvmarg

Posted by Steve Loughran <st...@apache.org>.
Dave Pawson wrote:
> On 16/04/2008, Steve Loughran <st...@apache.org> wrote:
> 
>>> Saxon XSLT processor.
>>> -o filename is the parameter. I'd always thought of it as one param.
>>> Name (-o)
>>> value (filename)
>>> Ant seems to view it differently.
>>>
>>  Its two separate parameters when you break up the command line by spaces,
>> which is what C main(char **argv)  does by the time every native program
>> gets a look in. And The Java Runtime exec() call takes the same list of
>> arguments, which is what ant sets up
>>
>>  When you go <arg line> ant splits up the line by spaces, and gets it wrong
>> when there are spaces in filenames -just as the shell would. When you build
>> it up using <arg value>, spaces in filenames get handled correctly.
>>
>>  If you build on on unix, you may not notice these problems, but other
>> developers may hit the problem. Its safest, therefore, to use arg value,
>> except in the special case that you want people who override your build file
>> to include a whole list of custom arguments (like custom JVM
>> properties/options).
> 
> 
> I can see the simpler interpretation Steve, just looks odd from
> the user perspective? Saxon does just the same as you say,
> but processes arg pairs (for such as -o, -x etc).

well, ant itself looks for arguments that follow the previous one. But 
they shouldnt say
if(arg[index].startswith("-o ")) setOutputFile(arg[index].substring(2);

what normally happens is more
  if(arg[index].startswith("-o ")) {
   index++;
   if(index>=arg.length) throw new NotEnoughValuesException("expected 
something after -o");
   setOutputFile(arg[index]);
   index++;
}

this pulls in two arguments and checks that there are two before doing 
the work. Or they use commons-cli to do this part of the grunge work.

> 
> I've given up with the xslt task now;
> Need it to handle a different parser (xercesImpl) for xIncludes
> and Apache resolver.jar for catalogs - I don't think
> the xslt task can hack that?

-you should be using xercesImpl from ANT_HOME/lib anyway...drop in a new 
version if you want to change that.
-resolver.jar is used for catalog resolution; I dont know what happens 
with xincludes

if xinclude doesnt work when resolver.jar is on the classpath, that's a 
feature to fix...

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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


Re: arg and jvmarg

Posted by Dave Pawson <da...@gmail.com>.
On 16/04/2008, Steve Loughran <st...@apache.org> wrote:

> > Saxon XSLT processor.
> > -o filename is the parameter. I'd always thought of it as one param.
> > Name (-o)
> > value (filename)
> > Ant seems to view it differently.
> >
>
>  Its two separate parameters when you break up the command line by spaces,
> which is what C main(char **argv)  does by the time every native program
> gets a look in. And The Java Runtime exec() call takes the same list of
> arguments, which is what ant sets up
>
>  When you go <arg line> ant splits up the line by spaces, and gets it wrong
> when there are spaces in filenames -just as the shell would. When you build
> it up using <arg value>, spaces in filenames get handled correctly.
>
>  If you build on on unix, you may not notice these problems, but other
> developers may hit the problem. Its safest, therefore, to use arg value,
> except in the special case that you want people who override your build file
> to include a whole list of custom arguments (like custom JVM
> properties/options).


I can see the simpler interpretation Steve, just looks odd from
the user perspective? Saxon does just the same as you say,
but processes arg pairs (for such as -o, -x etc).


I've given up with the xslt task now;
Need it to handle a different parser (xercesImpl) for xIncludes
and Apache resolver.jar for catalogs - I don't think
the xslt task can hack that?

I have it working as a java task

  <java classname="${xslt.processor.class}"
	fork="yes"
	dir="${in.dir}"
	failonerror="true">
    <classpath refid="xslt.processor.classpath" />
    <jvmarg line="-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration"/>
    <jvmarg line="-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/>
    <jvmarg line="-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl"/>
    <arg value="-l"/>
    <arg value="-o"/>
    <arg value="${out.dir}/${main.outfile}"/>
    <arg line="-x org.apache.xml.resolver.tools.ResolvingXMLReader"/>
    <arg line="-y org.apache.xml.resolver.tools.ResolvingXMLReader"/>
    <arg line="-r org.apache.xml.resolver.tools.CatalogResolver "/>
    <arg line="${in.dir}/${main.infile} ${main.stylesheet}
${param.args.post}" />
  </java>

which will suffice!
(I'll stick with the <arg line/> notation till ant loses it, for readability.)


regards



-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

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


Re: arg and jvmarg

Posted by Steve Loughran <st...@apache.org>.
Dave Pawson wrote:
> On 11/04/2008, Rick Genter <rg...@silverlink.com> wrote:
> 
>>  > I seem to have found just the opposite?
>>  > line="-o filename" works fine, but as was pointed out,
>>  > if I want to use value I have to use two arg elements?
>>
>>
>> Your example has 2 arguments: '-o' and 'filename'. I recommend reading
>>  the documentation for the command line processor you are using for how
>>  it processes command lines and what the definition of an 'argument' is.
> 
> Saxon XSLT processor.
> -o filename is the parameter. I'd always thought of it as one param.
> Name (-o)
> value (filename)
> Ant seems to view it differently.

Its two separate parameters when you break up the command line by 
spaces, which is what C main(char **argv)  does by the time every native 
program gets a look in. And The Java Runtime exec() call takes the same 
list of arguments, which is what ant sets up

When you go <arg line> ant splits up the line by spaces, and gets it 
wrong when there are spaces in filenames -just as the shell would. When 
you build it up using <arg value>, spaces in filenames get handled 
correctly.

If you build on on unix, you may not notice these problems, but other 
developers may hit the problem. Its safest, therefore, to use arg value, 
except in the special case that you want people who override your build 
file to include a whole list of custom arguments (like custom JVM 
properties/options).

-steve

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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


RE: arg and jvmarg

Posted by Rick Genter <rg...@silverlink.com>.
> From: Dave Pawson [mailto:dave.pawson@gmail.com] 
> Sent: Friday, April 11, 2008 9:50 AM
> To: Ant Users List
> Subject: Re: arg and jvmarg
> 
> Saxon XSLT processor.
> -o filename is the parameter. I'd always thought of it as one param.
> Name (-o)
> value (filename)
> Ant seems to view it differently.

As does every command line processor I've ever dealt with: DOS, Win32
Command Prompt, sh, csh, bash, ksh, zsh, etc.

I'd say the Saxon XSLT processor is the one that seems to view it
"differently".
--
Rick Genter
Principal Software Engineer
Silverlink Communications
rgenter@silverlink.com
www.silverlink.com

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


Re: arg and jvmarg

Posted by Dave Pawson <da...@gmail.com>.
On 11/04/2008, Rick Genter <rg...@silverlink.com> wrote:

>  > I seem to have found just the opposite?
>  > line="-o filename" works fine, but as was pointed out,
>  > if I want to use value I have to use two arg elements?
>
>
> Your example has 2 arguments: '-o' and 'filename'. I recommend reading
>  the documentation for the command line processor you are using for how
>  it processes command lines and what the definition of an 'argument' is.

Saxon XSLT processor.
-o filename is the parameter. I'd always thought of it as one param.
Name (-o)
value (filename)
Ant seems to view it differently.


>
>  'line=' won't work if your filename has an embedded space. 'line=' does
>  simple parsing, splitting the arguments on space boundaries. 'line=-o
>  C:\Documents and Settings\user\My Documents\filename.out' generates 5
>  arguments:
>
>  -o
>  C:\Documents
>  and
>  Settings\user\My
>  Doucments\filename.out
>
>  which is almost certainly *NOT* what was wanted.

Not for saxon (http://saxonica.com)


>
>  'value=' explicitly specifies exactly one argument.

Different strokes, different folks I guess.

regards



-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

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


RE: arg and jvmarg

Posted by Rick Genter <rg...@silverlink.com>.
> From: Dave Pawson [mailto:dave.pawson@gmail.com] 
> Sent: Friday, April 11, 2008 7:35 AM
> To: Ant Users List
> Subject: Re: arg and jvmarg
> 
> On 11/04/2008, Rick Genter <rg...@silverlink.com> wrote:
> > > From: Dave Pawson [mailto:dave.pawson@gmail.com]
> >  > Sent: Friday, April 11, 2008 1:02 AM
> >  > To: Ant Users List
> >  > Subject: Re: arg and jvmarg
> >
> > >
> >  > Thanks Joe. I can see the logic, although 'line=' seems to
> >  > make more sense from
> >  > a user view? "-o filename"
> >
> >
> > 'line=' doesn't work if any of your arguments contain spaces, since
> >  internally 'line=' breaks the arguments on whitespace boundaries.
> 
> I seem to have found just the opposite?
> line="-o filename" works fine, but as was pointed out,
> if I want to use value I have to use two arg elements?

Your example has 2 arguments: '-o' and 'filename'. I recommend reading
the documentation for the command line processor you are using for how
it processes command lines and what the definition of an 'argument' is.

'line=' won't work if your filename has an embedded space. 'line=' does
simple parsing, splitting the arguments on space boundaries. 'line=-o
C:\Documents and Settings\user\My Documents\filename.out' generates 5
arguments:

-o
C:\Documents
and
Settings\user\My
Doucments\filename.out

which is almost certainly *NOT* what was wanted.

'value=' explicitly specifies exactly one argument. Specifying

<arg value="-o"/>
<arg value="C:\Documents and Settings\user\My Documents\filename.out"/>

will behave as expected.
--
Rick Genter
Principal Software Engineer
Silverlink Communications
rgenter@silverlink.com
www.silverlink.com

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


Re: arg and jvmarg

Posted by Dave Pawson <da...@gmail.com>.
On 11/04/2008, Rick Genter <rg...@silverlink.com> wrote:
> > From: Dave Pawson [mailto:dave.pawson@gmail.com]
>  > Sent: Friday, April 11, 2008 1:02 AM
>  > To: Ant Users List
>  > Subject: Re: arg and jvmarg
>
> >
>  > Thanks Joe. I can see the logic, although 'line=' seems to
>  > make more sense from
>  > a user view? "-o filename"
>
>
> 'line=' doesn't work if any of your arguments contain spaces, since
>  internally 'line=' breaks the arguments on whitespace boundaries.

I seem to have found just the opposite?
line="-o filename" works fine, but as was pointed out,
if I want to use value I have to use two arg elements?

regards




-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

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


RE: arg and jvmarg

Posted by Rick Genter <rg...@silverlink.com>.
> From: Dave Pawson [mailto:dave.pawson@gmail.com] 
> Sent: Friday, April 11, 2008 1:02 AM
> To: Ant Users List
> Subject: Re: arg and jvmarg
> 
> Thanks Joe. I can see the logic, although 'line=' seems to 
> make more sense from
> a user view? "-o filename"

'line=' doesn't work if any of your arguments contain spaces, since
internally 'line=' breaks the arguments on whitespace boundaries.
--
Rick Genter
Principal Software Engineer
Silverlink Communications
rgenter@silverlink.com
www.silverlink.com

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


Re: arg and jvmarg

Posted by Dave Pawson <da...@gmail.com>.
On 11/04/2008, Joe Schmetzer <jo...@exubero.com> wrote:

> <arg value="x"/> is interpreted as a single argument, even if "x" happens
>  to contain spaces. In your case, you actually have two arguments: "-o" and
>  "filename", so you need to specify it like this:
>
>   <arg value="-o"/>
>   <arg value="${out.dir}/${main.outfile}"/>


Thanks Joe. I can see the logic, although 'line=' seems to make more sense from
a user view? "-o filename"

I guess that's how it must be.

regards

-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

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


Re: arg and jvmarg

Posted by Joe Schmetzer <jo...@exubero.com>.
On Fri, April 11, 2008 8:42 am, Dave Pawson wrote:
> http://ant.apache.org/manual/using.html#arg
>
> mentions using <arg value in preference to <arg line=
>
> For an xslt task I want to specify
> -o filename
>
> Trying this
>
>  <arg value="-l"/>
>     <arg value="-o ${out.dir}/${main.outfile}"/>
>
> The single '-l' works OK,
> but the -o option causes a problem with the processor.
>
> How can I specify '-o filename' for <arg/> please?

<arg value="x"/> is interpreted as a single argument, even if "x" happens
to contain spaces. In your case, you actually have two arguments: "-o" and
"filename", so you need to specify it like this:

  <arg value="-o"/>
  <arg value="${out.dir}/${main.outfile}"/>

Cheers,
Joe


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