You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Leszek Gawron <lg...@mobilebox.pl> on 2006/04/15 12:57:53 UTC

Re: jx:text

I am still catching up old threads...

Sylvain Wallez wrote:
> Daniel Fagerstrom wrote:
>> Ok. It would be nice if we could solve this in a way that doesn't 
>> require to much writing for the template author. Turning on and of 
>> whitespace skipping for all instructions for those who need formated 
>> output isn't that attractive.
>>
>> XSLT processors gives at least somewhat reasonable output compared to 
>> what JXTG does. Anyone who knows what kind of rules XSLT-processor 
>> uses for whitespace processing around instructions?
> 
> Yep. And for the sake of consistency and learning simplicity, it would 
> be good to use the same rules (see [1]).
> 
> The default behaviour is different for the XSLT program itself (i.e. the 
> template in JXTG) and the input document (which has no JXTG equivalent).
> 
> XSLT keeps a text node in the stylesheet if:
> - the text node containes at least one non-whitespace character,
> - the text node's parent element is <xsl:text>,
> - the closest ancestor having an "xml:space" attribute has the value 
> "preserve" for this attribute (this attribute is kept in the output)

> The <xsl:preserve-space> and <xsl:strip-space> instructions only apply 
> to the input document. I guess this difference is because the stylesheet 
> writer is supposed to know what it writes whereas input documents can 
> come from any source.
> 
>> Again I don't dispute that there could be a need for explicit 
>> whitespace skipping. But I would prefer if we could find a less 
>> verbose way to get reasonable default whitespace processing for macros.
> 
> +1000! And IMO the XSLT way is this "reasonable default whitespace 
> processing" as it simply removes all whitespace nodes used for 
> indenting, which are mostly those that are annoying us.
And which are those? How would you like to differentiate what is a 
"program" and what is "data" when they are both mixed in single 
document? Example:

<jx:forEach var="elem" items="${elems}">
     <elem>
         <jx:formatDate value="${elem.date}"/>
     </elem>
</jx:forEach>

What should the output look like?

> 
> A question though: what would be the difference between <jx:text> and 
> <jx:out>?
> 
> Sylvain
> 
> [1] http://www.w3.org/TR/xslt#strip
> 


-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65