velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank_McLean" <Frank_McL...@natureserve.org>
Subject Creating a URL with ampersands (not &amp;s) for XML output
Date Wed, 22 Aug 2007 16:55:13 GMT
Hi,

 

I have a template which creates XML.  One of the elements is a URI to an
image.  This URI calls a servlet which generates the appropriate image.
It contains an ampersand delimited list of parameters, so my XML should
look something like:

 

<imageUrl>http://.../blah?param1&param2...&paramN</imageURL>

 

Now, try as I might, I CANNOT get velocity to STOP replacing the literal
'&' with the entity code '&amp;'.

 

I first create the $distCode (the parameter list) using '_' as a
separator.  Then I $distCode.replaceAll('_','&') and this seems to make
$distCode just what I want.  However, if I then write -

 

<imageUrl>http://.../blah?${distCode}</imageUrl
<http://.../blah?$%7bdistCode%7d%3c/imageUrl> >

 

- Velocity kindly butts in and escapes all my hard won '&'s. J

 

Right now, I just cannot see a way around this.  I would really rather
avoid any solutions like the following, if I can help it, as the whole
aim is to make this easy to use:

 

<image>

     <imageServlet>http://.../blah</imageServlet>

      <imageParam>param1</imageParam>

</image>

 

Any help gratefully received...

 

Frank


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