You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Tom Copeland <to...@infoether.com> on 2003/05/15 16:33:11 UTC

Does Jelly support CDATA blocks?

I'm trying to generate a web page that has some example code in it -
like these pages:

http://pmd.sourceforge.net/rules/basic.html

Those pages were generated using Maven b7 and some DVSL that looks like
this:

=======================
<p>
    Here's an example of code that would trigger this rule:
</p>
<source>
<![CDATA[ $node.get("./example").value() ]]>
</source>
=======================

I've tried to do something similar with Jelly, but the CDATA delimiter
thingies keep disappearing.  Any ideas?

Thanks much,

tom
-- 
Tom Copeland <to...@infoether.com>
InfoEther


Re: Does Jelly support CDATA blocks?

Posted by Tom Copeland <to...@infoether.com>.
> Isn't it exactly what your jelly is outputting from the source element ?
> At least, I would expect.

Unfortunately, it's all getting glommed together. 

> 
> You may be trapped within the arcanes of whitespace handling... And 
> these I wouldn't know how to solve. Maybe try defining a variable with 
> <x:parse trim="no"> but then, again, the outputter may have the fun to 
> actually want to indent things again (you can adjust this) and then 
> again you're trapped. This can only be... experimented with, I have the 
> impression.

Yup, I'll try fiddling with it some more... if I can figure it out, I'll
post back here.

Thanks,

Tom



Re: Does Jelly support CDATA blocks?

Posted by Paul Libbrecht <pa...@activemath.org>.
Tom Copeland wrote:
> I guess what I'm looking for is to end up with this:
> 
> =================
> <pre>
>   // this is bad
>   public void bar() {
>       try {
>           int x=2;
>       } finally {
>       }
>   }                  
> </pre>
> =================
> 
> in my HTML.  Is there another way to do this?


Isn't it exactly what your jelly is outputting from the source element ?
At least, I would expect.

You may be trapped within the arcanes of whitespace handling... And 
these I wouldn't know how to solve. Maybe try defining a variable with 
<x:parse trim="no"> but then, again, the outputter may have the fun to 
actually want to indent things again (you can adjust this) and then 
again you're trapped. This can only be... experimented with, I have the 
impression.

Paul


Re: Does Jelly support CDATA blocks?

Posted by Tom Copeland <to...@infoether.com>.
> But why would you want to keep them ?

Having the code in a CDATA block makes it look like this:

http://pmd.sourceforge.net/rules/basic.html

i.e., all nice and spread out and such.  If it's just in a <source>
element it gets all crammed together on the same line.

> It is normal XML to consider the CDATA section as simple text. The only 
> practical restriction is when re-toutputting the document: then if you put
> <![CDATA[ $node.get("./example").value() < 3 ]]>
> It should become (without CDATA):
> $node.get("./example").value() &lt; 3

Yup, that's exactly what's happening :-(

> PS: note that it is often an error that people use CDATA sections hoping 
> they stay along an xml-pipeline. Most XML-parsing APIs however, don't 
> offer that (for example SAX doesn't, and Jelly is based on SAX, only an 
> extension thereof (the LexicalHandler)).

Guilty :-)

I guess what I'm looking for is to end up with this:

=================
<pre>
  // this is bad
  public void bar() {
      try {
          int x=2;
      } finally {
      }
  }                  
</pre>
=================

in my HTML.  Is there another way to do this?

Thanks much,

Tom



Re: Does Jelly support CDATA blocks?

Posted by Paul Libbrecht <pa...@activemath.org>.
Tom Copeland wrote:
> I'm trying to generate a web page that has some example code in it -
> like these pages:
> http://pmd.sourceforge.net/rules/basic.html
> Those pages were generated using Maven b7 and some DVSL that looks like
> this:
> 
> =======================
> <p>
>     Here's an example of code that would trigger this rule:
> </p>
> <source>
> <![CDATA[ $node.get("./example").value() ]]>
> </source>
> =======================
> 
> I've tried to do something similar with Jelly, but the CDATA delimiter
> thingies keep disappearing.  Any ideas?

But why would you want to keep them ?
It is normal XML to consider the CDATA section as simple text. The only 
practical restriction is when re-toutputting the document: then if you put
<![CDATA[ $node.get("./example").value() < 3 ]]>
It should become (without CDATA):
$node.get("./example").value() &lt; 3

And these forms are equivalent.


As long as you have the <source> element around there is nothing to 
worry about, or ?


Hope that helps.

Paul

PS: note that it is often an error that people use CDATA sections hoping 
they stay along an xml-pipeline. Most XML-parsing APIs however, don't 
offer that (for example SAX doesn't, and Jelly is based on SAX, only an 
extension thereof (the LexicalHandler)).