[Yanel-dev] CDATA and comments problem

Michael Wechner michael.wechner at wyona.com
Wed Mar 5 09:16:22 CET 2008


Evaldas Taroza wrote:

> Michael Wechner wrote:
>
>> Evaldas Taroza wrote:
>>
>>> Hi,
>>> I have a problem when trying to pipe an XML through jelly and XSLTs.
>>> consider a jelly which has a script tag:
>>> <script>
>>>  if(1<2){
>>>   alert("OK");
>>>  }
>>> </script>
>>>
>>> This jelly won't work. So we change it into:
>>> <script>
>>> <![CDATA[
>>>  if(1<2){
>>>   alert("OK");
>>>  }
>>> ]]>
>>> </script>
>>>
>>> After this passes the jelly engine I get:
>>> <script>
>>>  if(1 &lt; 2){
>>>   alert("OK");
>>>  }
>>> </script>
>>>
>>> This is illegal javascript. So it won't work. We change the initial 
>>> script a bit:
>>> <script>
>>> &lt;!--
>>>  if(1 < 2){
>>>   alert("OK");
>>>  }
>>> //--&gt;
>>> </script>
>>>
>>> This passes the jelly fine and we get:
>>> <script>
>>> <!--
>>>  if(1 < 2){
>>>   alert("OK");
>>>  }
>>> //-->
>>> </script>
>>>
>>> This script would work in html world. Now the problem that this 
>>> output should also get through I18nTransformer2 and 
>>> XIncludeTransformer of Yanel. So afterwards I get:
>>> <script>
>>>
>>> </script
>>
>>
>>
>> I guess it's a bug that either the I18nTransformer2 or the 
>> XIncludeTransformer are stripping comments.
>
>
> I haven't debugged that, but looks like it's one of them. However, I 
> wouldn't call that a bug.


so what about introducing a flag strip-comments="true/false", whereas 
default is true?

> In the world of XSLT transformers usually strip comments (allthough 
> you can match it with comment() and copy it again).
> But in this specific case it is really a problem, and since the two 
> transformers are kind of "hidden" they should really do full copy of 
> every node.
>
>>
>> Have you debugged which transformer is actually stripping the comment?
>>
>> As a workaround you might want to reference the Javascript <link 
>> .../> or does it need to generated dynamically?
>
>
> In some places I need to generate it dynamically. And I don't want to 
> create *.js files for such small script snippets.


ok, that means we need to "fix" it.

Maybe Josias has an idea, because AFAIK he wrote most of the transformer 
code ;-)

Cheers

Michi

>
> Evaldas
>


-- 
Michael Wechner
Wyona      -   Open Source Content Management - Yanel, Yulup
http://www.wyona.com
michael.wechner at wyona.com, michi at apache.org
+41 44 272 91 61



More information about the Yanel-development mailing list