You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stéphane MOR <st...@yahoo.fr> on 2002/08/28 02:09:41 UTC

[jelly] , CDATA, '&' and '<'

Hi,

I would like to use <j:file/> to generate a Perl Script (this can look 
weird, but anyway ...).

The file I want to generate could look like (this VERY simple script):

<j:file name="myscript.pl" omitXmlDeclaration="true">
#!/usr/bin/perl
sub CheckName{
  my ($name, $age);

  if ( $name != "Stéphane" && $age < 22) {
      $return = &Foo();
      $return .= "you're not the one I expected";
      return $return;
  }else{
      return "welcome !"
  }
}
</j:file>

I solved the problem of the '$' being removed by Jelly when I doubled 
them, ie:
my ($$name, $$age);

I tried to get it running and it said "org.xml.sax.SAXParseException: 
The entity "Foo" was referenced, but not declared."

So, I enclosed the whole thing in a <![CDATA[]]> section.
All run well, but the resulting output file was:

#!/usr/bin/perl
sub CheckName{
  my ($name, $age);

  if ( $name != "Stéphane" &amp;&amp; $age &lt; 22) {
      $return = &amp;Foo();
      $return .= "you're not the one";
      return $return;
  }else{
      return "welcome !"
  }
}

So, I'd like to know how i can output '&', '<' and '>' nicely in a 
<j:file/>, if possible.

Thanx!
Stéphane

PS: This occured while trying to make a Maven Wiki Plugin, using Maven 
HEAD (and the Jelly SNAPSHOT) on a Linux
box under JDK1.3.1.

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

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


Re: [jelly] , CDATA, '&' and '<'

Posted by James Strachan <ja...@yahoo.co.uk>.
Hi Stéphane

Using either CDATA sections, or escaping & as &amp; in the jelly script is
fine.

This is that old chestnut, XML encoding. There's an attribute of <j:file> to
set the encoding type. So far the only ones understood are 'xml' and 'html'.
See if the HTML encoding works for you. If not I'll try add a 'text'
encoding that matches what you need.

<j:file name="myscript.pl" omitXmlDeclaration="true" outputMethod="html">...

James
-------
http://radio.weblogs.com/0112098/
----- Original Message -----
From: "Stéphane MOR" <st...@yahoo.fr>
To: <co...@jakarta.apache.org>
Sent: Wednesday, August 28, 2002 1:09 AM
Subject: [jelly] <j:file>, CDATA, '&' and '<'


> Hi,
>
> I would like to use <j:file/> to generate a Perl Script (this can look
> weird, but anyway ...).
>
> The file I want to generate could look like (this VERY simple script):
>
> <j:file name="myscript.pl" omitXmlDeclaration="true">
> #!/usr/bin/perl
> sub CheckName{
>   my ($name, $age);
>
>   if ( $name != "Stéphane" && $age < 22) {
>       $return = &Foo();
>       $return .= "you're not the one I expected";
>       return $return;
>   }else{
>       return "welcome !"
>   }
> }
> </j:file>
>
> I solved the problem of the '$' being removed by Jelly when I doubled
> them, ie:
> my ($$name, $$age);
>
> I tried to get it running and it said "org.xml.sax.SAXParseException:
> The entity "Foo" was referenced, but not declared."
>
> So, I enclosed the whole thing in a <![CDATA[]]> section.
> All run well, but the resulting output file was:
>
> #!/usr/bin/perl
> sub CheckName{
>   my ($name, $age);
>
>   if ( $name != "Stéphane" &amp;&amp; $age &lt; 22) {
>       $return = &amp;Foo();
>       $return .= "you're not the one";
>       return $return;
>   }else{
>       return "welcome !"
>   }
> }
>
> So, I'd like to know how i can output '&', '<' and '>' nicely in a
> <j:file/>, if possible.
>
> Thanx!
> Stéphane
>
> PS: This occured while trying to make a Maven Wiki Plugin, using Maven
> HEAD (and the Jelly SNAPSHOT) on a Linux
> box under JDK1.3.1.
>
> ___________________________________________________________
> Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
> Yahoo! Mail : http://fr.mail.yahoo.com
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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