You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Scott Ellsworth <sc...@alodar.com> on 2002/01/31 03:44:03 UTC

Perhaps simple xsl question

On the advice of many here, I am trying to generate a build.xml from a 
stylesheet.  In this process, I want to do some replacements, but to end 
up with a build file containing some ANT ${} variables.

(I am posting this here, rather than to a more general XSL list as this 
_has_ to be something that many here have already handled correctly.  
Also, I tried seaching the archives for virtually every combination of 
"style", "escaping", "variable", and similar words.)

Assume I have just done a for-each on "project" with the source
<project-list>
	<project name="metagraph" cvs.packages="org" />
</project-list>

I am trying to produce

         <target name="cvs-checkout-{@name}" >
           <cvs cvsroot="${cvs.root}"
             package="org"
             dest="${basedir}"
             passfile="${cvs.passfile}"
             quiet="true"
           />
         </target>

using

         <target name="cvs-checkout-{@name}" >
           <cvs cvsroot="${cvs.root}"
             package="{@cvs.packages}"
             dest="${basedir}"
             passfile="${cvs.passfile}"
             quiet="true"
           />
         </target>

Of course, I am getting

   <target name="cvs-checkout-metagraph">
     <cvs
       quiet="true"
       passfile="$"
       dest="$"
       package="org"
       cvsroot="$"/>
   </target>

In other words, @cvs.packages is getting replaced just fine, but in the 
process, all of my ANT variables are getting vaporized.

So, how should I have written this?

Scott


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Perhaps simple xsl question

Posted by Scott Ellsworth <sc...@alodar.com>.
On Thursday, January 31, 2002, at 10:15  AM, Frank E. Weiss wrote:

> You'll be happy to hear that XSLT also allows escaping the curly braces 
> by doubling them.

I had thought that should be possible, but missed it when looking in my 
references.  (Good references, inexperienced hand at XSLT.)

Thanks!

Scott


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Perhaps simple xsl question

Posted by "Frank E. Weiss" <fr...@well.com>.
You'll be happy to hear that XSLT also allows escaping the curly braces by doubling them. It might be nicer to write

<cvs cvsroot="${{cvs.root}}" ...

This is covered in 7.6.2 Attribute Value Templates (http://www.w3.org/TR/xslt)

Cheers!

Scott Ellsworth wrote:

> On Wednesday, January 30, 2002, at 07:07  PM, Bevan Arps wrote:
>
> > <cvs cvsroot="{'${cvs.root}'}" ...
> >
> > Ie the cvsroot attribute is to contain the results of evaluating the
> > expression '${cvs.root}', which is simply a string constant.
> >
> > Hope this helps,
>
> It did indeed!
>
> Thanks much,
>
> Scott
>
> ps - for the search engine: escaping variable in style sheet
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Perhaps simple xsl question

Posted by Scott Ellsworth <sc...@alodar.com>.
On Wednesday, January 30, 2002, at 07:07  PM, Bevan Arps wrote:

> <cvs cvsroot="{'${cvs.root}'}" ...
>
> Ie the cvsroot attribute is to contain the results of evaluating the 
> expression '${cvs.root}', which is simply a string constant.
>
> Hope this helps,

It did indeed!

Thanks much,

Scott

ps - for the search engine: escaping variable in style sheet


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Perhaps simple xsl question

Posted by Bevan Arps <be...@actfs.co.nz>.
At 18:44 30/01/2002 -0800, Scott Ellsworth wrote:

>In other words, @cvs.packages is getting replaced just fine, but in the 
>process, all of my ANT variables are getting vaporized.

You're running afoul of a useful "feature" of XSLT.

Realising that creating attribute values dynamicly would be a common event, 
the designers provided a shortcut.

Instead of having to write

<outputNode>
   <xsl:attribute name="foobar">
     <xsl:value-of select="myExpression"/>
   </xsl:attribute>
</outputNode>

you can write this

<outputNode foobar="{myExpression}"/>

In your original template, this line

<cvs cvsroot="${cvs.root}" ...

is handled by the stylesheet extracting {cvs.root}, evaluating the 
expression and replacing it with the appropriate content.

Instead, you could use an expression giving ${cvs.root} as the result; I 
think this should work:

<cvs cvsroot="{'${cvs.root}'}" ...

Ie the cvsroot attribute is to contain the results of evaluating the 
expression '${cvs.root}', which is simply a string constant.


Hope this helps,
Bevan.


--
"Programming is an Art Form that Fights Back"

Bevan Arps (<ma...@actfs.co.nz>bevan.arps@actfs.co.nz)
Senior OO Analyst, ACT Financial Systems

This communication  is confidential  to ACT  Financial  Systems  (Asia 
Pacific)  and is intended for  use only by the  addressee.   The  views and 
opinions  expressed in  this email  are the senders  own and do not 
represent  the  views  and  opinions of  ACT  Financial  Systems  (Asia 
Pacific).