You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by werner <we...@gefi.at> on 2006/08/02 18:16:18 UTC
Re: [CFORMS] HTML in field
Thanks for your answer. But I found out that the contents of the fields
are already escaped before the stylesheets get applied. So the problem
is somewhere else.
Werner
Jeroen Reijn wrote:
> Hi Werner,
>
> i'm not sure, but you could modify the xsl that applies the output
> widget and add something like:
>
> <xsl:value-of select="fi:value" disable-output-escaping="yes"/>
>
> I hope this helps.
>
> Regards,
>
> Reijn
>
>
> werner wrote:
>
>> Dear Mailinglist!
>>
>> I know this has been asked before, but I could not find a clean
>> solution. How can I display HTML in a output widget and prevent
>> escaping? i.e. <br/> should not be converted to <br/>
>>
>> Thanks you
>> Werner
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [CFORMS] HTML in field
Posted by werner <we...@gefi.at>.
Jason Johnston wrote:
> werner wrote:
>
>> Jason Johnston wrote:
>>
>>> So what you're wanting is a way to take the String contents of a form
>>> widget and have it parsed into SAX events and inserted into the SAX
>>> stream, correct? Note that it's not as simple as just disabling
>>> escaping
>>> of XML characters, because that's just a serialization concern, whereas
>>> you want to actually have it parsed into SAX. AFAIK there is no way
>>> using
>>> the standard <ft:widget> mechanism or XSLT to achieve this.
>>>
>>> I think JXTemplate is going to be your best bet. I'm assuming you're
>>> already using JXTemplateGenerator in your display pipeline; if you're
>>> using FormsTemplateTransformer instead then I'd suggest switching to JX
>>> (it's the preferred method nowadays). Then you've got a couple
>>> choices:
>>>
>>> 1) If you're using the JX implementation from the 'template' block
>>> (cocoon
>>> 2.1.9+ only), then you can use the xmlize="true" attribute of jx:out:
>>>
>>> <jx:set var="xhtmlString"
>>> value='${widget.getChild("myOutputWidget").getValue()}' />
>>> <jx:out value="${xhtmlString}" xmlize="true" />
>>>
>>>
>>
>> Yes, I'm using 2.1.9 with the NewJXTemplategenerator. I didn't know
>> of the the xmlize feature. It looks like the right approach, but it
>> does not work because I use the widget in a repeater row. I get the
>> following errors:
>>
>> org.xml.sax.SAXParseException: Content is not allowed in prolog.
>>
>> *Fatal error parsing null (line 1 col. 1): Content is not allowed in
>> prolog.*
>> context://forms/firmenEditIITemplate.xml - 349:72 //
>>
>>
>> *Fatal error parsing null (line 1 col. 1): Content is not allowed in
>> prolog.*
>> resource://org/apache/cocoon/forms/generation/jx-macros.xml -
>> 241:27 //
>>
>>
>> *{http://apache.org/cocoon/forms/1.0#template}repeater-rows: Fatal
>> error parsing null (line 1 col. 1): Content is not allowed in prolog.*
>> context://forms/firmenEditIITemplate.xml - 336:29 //
>>
>>
>> *{http://apache.org/cocoon/forms/1.0#template}repeater-rows: Fatal
>> error parsing null (line 1 col. 1): Content is not allowed in prolog.*
>> resource://org/apache/cocoon/forms/generation/jx-macros.xml -
>> 232:23 //
>>
>>
>> *{http://apache.org/cocoon/forms/1.0#template}repeater:
>> {http://apache.org/cocoon/forms/1.0#template}repeater-rows: Fatal
>> error parsing null (line 1 col. 1): Content is not allowed in prolog.*
>> context://forms/firmenEditIITemplate.xml - 324:38
>
>
> It looks like maybe your user-entered content isn't able to be parsed
> as XML? I guess I assumed you'd be running some sort of cleanup on
> user-entered content to make sure it's well-formed and all. Also,
> remember an XML document can contain only a single root element, so
> you may need to wrap those contents in a <div></div> or something
> before parsing.
>
>
That's it! I had to wrap the user entered data in a DIV. It works now.
*Thank you* very very much! I would have never ever found the problem
myself.
Regards
Werner
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [CFORMS] HTML in field
Posted by Jason Johnston <co...@lojjic.net>.
werner wrote:
> Jason Johnston wrote:
>> So what you're wanting is a way to take the String contents of a form
>> widget and have it parsed into SAX events and inserted into the SAX
>> stream, correct? Note that it's not as simple as just disabling escaping
>> of XML characters, because that's just a serialization concern, whereas
>> you want to actually have it parsed into SAX. AFAIK there is no way using
>> the standard <ft:widget> mechanism or XSLT to achieve this.
>>
>> I think JXTemplate is going to be your best bet. I'm assuming you're
>> already using JXTemplateGenerator in your display pipeline; if you're
>> using FormsTemplateTransformer instead then I'd suggest switching to JX
>> (it's the preferred method nowadays). Then you've got a couple choices:
>>
>> 1) If you're using the JX implementation from the 'template' block (cocoon
>> 2.1.9+ only), then you can use the xmlize="true" attribute of jx:out:
>>
>> <jx:set var="xhtmlString"
>> value='${widget.getChild("myOutputWidget").getValue()}' />
>> <jx:out value="${xhtmlString}" xmlize="true" />
>>
>>
> Yes, I'm using 2.1.9 with the NewJXTemplategenerator. I didn't know of
> the the xmlize feature. It looks like the right approach, but it does
> not work because I use the widget in a repeater row. I get the following
> errors:
>
> org.xml.sax.SAXParseException: Content is not allowed in prolog.
>
> *Fatal error parsing null (line 1 col. 1): Content is not allowed in
> prolog.*
> context://forms/firmenEditIITemplate.xml - 349:72 //
>
>
> *Fatal error parsing null (line 1 col. 1): Content is not allowed in
> prolog.*
> resource://org/apache/cocoon/forms/generation/jx-macros.xml - 241:27 //
>
>
> *{http://apache.org/cocoon/forms/1.0#template}repeater-rows: Fatal error
> parsing null (line 1 col. 1): Content is not allowed in prolog.*
> context://forms/firmenEditIITemplate.xml - 336:29 //
>
>
> *{http://apache.org/cocoon/forms/1.0#template}repeater-rows: Fatal error
> parsing null (line 1 col. 1): Content is not allowed in prolog.*
> resource://org/apache/cocoon/forms/generation/jx-macros.xml - 232:23 //
>
>
> *{http://apache.org/cocoon/forms/1.0#template}repeater:
> {http://apache.org/cocoon/forms/1.0#template}repeater-rows: Fatal error
> parsing null (line 1 col. 1): Content is not allowed in prolog.*
> context://forms/firmenEditIITemplate.xml - 324:38
It looks like maybe your user-entered content isn't able to be parsed as
XML? I guess I assumed you'd be running some sort of cleanup on
user-entered content to make sure it's well-formed and all. Also,
remember an XML document can contain only a single root element, so you
may need to wrap those contents in a <div></div> or something before
parsing.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [CFORMS] HTML in field
Posted by werner <we...@gefi.at>.
Jason Johnston wrote:
>So what you're wanting is a way to take the String contents of a form
>widget and have it parsed into SAX events and inserted into the SAX
>stream, correct? Note that it's not as simple as just disabling escaping
>of XML characters, because that's just a serialization concern, whereas
>you want to actually have it parsed into SAX. AFAIK there is no way using
>the standard <ft:widget> mechanism or XSLT to achieve this.
>
>I think JXTemplate is going to be your best bet. I'm assuming you're
>already using JXTemplateGenerator in your display pipeline; if you're
>using FormsTemplateTransformer instead then I'd suggest switching to JX
>(it's the preferred method nowadays). Then you've got a couple choices:
>
>1) If you're using the JX implementation from the 'template' block (cocoon
>2.1.9+ only), then you can use the xmlize="true" attribute of jx:out:
>
> <jx:set var="xhtmlString"
>value='${widget.getChild("myOutputWidget").getValue()}' />
> <jx:out value="${xhtmlString}" xmlize="true" />
>
>
>
Yes, I'm using 2.1.9 with the NewJXTemplategenerator. I didn't know of
the the xmlize feature. It looks like the right approach, but it does
not work because I use the widget in a repeater row. I get the following
errors:
org.xml.sax.SAXParseException: Content is not allowed in prolog.
*Fatal error parsing null (line 1 col. 1): Content is not allowed in
prolog.*
context://forms/firmenEditIITemplate.xml - 349:72 //
*Fatal error parsing null (line 1 col. 1): Content is not allowed in
prolog.*
resource://org/apache/cocoon/forms/generation/jx-macros.xml - 241:27 //
*{http://apache.org/cocoon/forms/1.0#template}repeater-rows: Fatal error
parsing null (line 1 col. 1): Content is not allowed in prolog.*
context://forms/firmenEditIITemplate.xml - 336:29 //
*{http://apache.org/cocoon/forms/1.0#template}repeater-rows: Fatal error
parsing null (line 1 col. 1): Content is not allowed in prolog.*
resource://org/apache/cocoon/forms/generation/jx-macros.xml - 232:23 //
*{http://apache.org/cocoon/forms/1.0#template}repeater:
{http://apache.org/cocoon/forms/1.0#template}repeater-rows: Fatal error
parsing null (line 1 col. 1): Content is not allowed in prolog.*
context://forms/firmenEditIITemplate.xml - 324:38 //
Seams like the repeater makes it a little bit more complicated. Maybe I
should explain why I want to put raw HTML in a repeater-widget. I use
the repeater to let the user add comments to a form just like in the
daisy cms at the bottom of each page. The user can edit and delete his
comments. That is why I use the repeater to display the comment (=HTML)
with the necessary buttons to edit and delete each comment.
Thanks for your help Jason!
Regards
Werner
>2) If you're using the old JX implementation then you should be able to do
>something similar, but you have to manually create an XMLizable object
>from the String value first (cocoon provides a handy StringXMLizable class
>for this purpose):
>
> <jx:set var="xhtmlString"
>value='${widget.getChild("myOutputWidget").getValue()}' />
> <jx:out
>value="${Packages.org.apache.cocoon.xml.StringXMLizable(xhtmlString)}"
>/>
>
>Hope that helps
>--Jason
>
>
>
>
>>Thanks for your answer. But I found out that the contents of the fields
>>are already escaped before the stylesheets get applied. So the problem
>>is somewhere else.
>>
>>Werner
>>
>>
>>Jeroen Reijn wrote:
>>
>>
>>
>>>Hi Werner,
>>>
>>>i'm not sure, but you could modify the xsl that applies the output
>>>widget and add something like:
>>>
>>><xsl:value-of select="fi:value" disable-output-escaping="yes"/>
>>>
>>>I hope this helps.
>>>
>>>Regards,
>>>
>>>Reijn
>>>
>>>
>>>werner wrote:
>>>
>>>
>>>
>>>>Dear Mailinglist!
>>>>
>>>>I know this has been asked before, but I could not find a clean
>>>>solution. How can I display HTML in a output widget and prevent
>>>>escaping? i.e. <br/> should not be converted to <br/>
>>>>
>>>>Thanks you
>>>>Werner
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>>>For additional commands, e-mail: users-help@cocoon.apache.org
>>>>
>>>>
>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>>For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>>
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
Re: [CFORMS] HTML in field
Posted by Antonio Gallardo <ag...@agssa.net>.
Hi Jason,
You are right! It works as expected. For the records it works in both
ways with and without the <jx:out/>.
My problem seems to be more related to call the jxtemplate generator using:
PipelinesUtils.processToStream();
Sorry for the loud.
Best Regards,
Antonio Gallardo.
Jason Johnston escribió:
>> Jason Johnston escribió:
>>
>>>> Hi Jason,
>>>>
>>>> I tried this second option for the old JXTemplate and I was unable to
>>>> see it working: Here is a non working test:
>>>>
>>>> <jx:set var="xhtmlContentTest" value="<html> Hello <b>
>>>> world! </b> </html>"/>
>>>> <jx:out
>>>> value="${Packages.org.apache.cocoon.xml.StringXMLizable(xhtmlContentTest)}"/>
>>>>
>>>> What I am doing wrong?
>>>>
>>> Hmm, looks OK to me. The only thing I can think is that maybe you're
>>> using JX without flow(script?)... I seem to remember reading somewhere
>>> that you can only get access to Java classes if invoked from flow.
>>>
>>>
>> Hi Jason,
>>
>> Thanks for the quick response. :-)
>>
>> I am using flow for calling the jxtemplate.
>>
>
> Well that shoots down that theory ;-)
>
> I checked some of my own code where this is working and see only these
> differences:
>
> 1) The jx:set uses an expression to set its value rather than just a
> literal value. It seems both should produce a String, so this probably
> isn't significant.
>
> 2) I do not use jx:out, but just write the jexl expression out as a text
> node. I thought the two are intended to behave the same, but perhaps not.
>
> Here's my code snippet that is working:
>
> <jx:set var="content" value="#{concat('<div>', comment-content,
> '</div>')}" />
> ${Packages.org.apache.cocoon.xml.StringXMLizable(content)}
>
> --Jason
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [CFORMS] HTML in field
Posted by Jason Johnston <co...@lojjic.net>.
> Jason Johnston escribió:
>>> Hi Jason,
>>>
>>> I tried this second option for the old JXTemplate and I was unable to
>>> see it working: Here is a non working test:
>>>
>>> <jx:set var="xhtmlContentTest" value="<html> Hello <b>
>>> world! </b> </html>"/>
>>> <jx:out
>>> value="${Packages.org.apache.cocoon.xml.StringXMLizable(xhtmlContentTest)}"/>
>>>
>>> What I am doing wrong?
>>
>>
>> Hmm, looks OK to me. The only thing I can think is that maybe you're
>> using JX without flow(script?)... I seem to remember reading somewhere
>> that you can only get access to Java classes if invoked from flow.
>>
> Hi Jason,
>
> Thanks for the quick response. :-)
>
> I am using flow for calling the jxtemplate.
Well that shoots down that theory ;-)
I checked some of my own code where this is working and see only these
differences:
1) The jx:set uses an expression to set its value rather than just a
literal value. It seems both should produce a String, so this probably
isn't significant.
2) I do not use jx:out, but just write the jexl expression out as a text
node. I thought the two are intended to behave the same, but perhaps not.
Here's my code snippet that is working:
<jx:set var="content" value="#{concat('<div>', comment-content,
'</div>')}" />
${Packages.org.apache.cocoon.xml.StringXMLizable(content)}
--Jason
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [CFORMS] HTML in field
Posted by Antonio Gallardo <ag...@agssa.net>.
Jason Johnston escribió:
>> Hi Jason,
>>
>> I tried this second option for the old JXTemplate and I was unable to
>> see it working: Here is a non working test:
>>
>> <jx:set var="xhtmlContentTest" value="<html> Hello <b>
>> world! </b> </html>"/>
>> <jx:out
>> value="${Packages.org.apache.cocoon.xml.StringXMLizable(xhtmlContentTest)}"/>
>>
>> What I am doing wrong?
>>
>
>
> Hmm, looks OK to me. The only thing I can think is that maybe you're
> using JX without flow(script?)... I seem to remember reading somewhere
> that you can only get access to Java classes if invoked from flow.
>
Hi Jason,
Thanks for the quick response. :-)
I am using flow for calling the jxtemplate.
Best Regards,
Antonio Gallardo.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [CFORMS] HTML in field
Posted by Jason Johnston <co...@lojjic.net>.
>
> Hi Jason,
>
> I tried this second option for the old JXTemplate and I was unable to
> see it working: Here is a non working test:
>
> <jx:set var="xhtmlContentTest" value="<html> Hello <b>
> world! </b> </html>"/>
> <jx:out
> value="${Packages.org.apache.cocoon.xml.StringXMLizable(xhtmlContentTest)}"/>
>
> What I am doing wrong?
Hmm, looks OK to me. The only thing I can think is that maybe you're
using JX without flow(script?)... I seem to remember reading somewhere
that you can only get access to Java classes if invoked from flow.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [CFORMS] HTML in field
Posted by Antonio Gallardo <ag...@agssa.net>.
Jason Johnston escribió:
> So what you're wanting is a way to take the String contents of a form
> widget and have it parsed into SAX events and inserted into the SAX
> stream, correct? Note that it's not as simple as just disabling escaping
> of XML characters, because that's just a serialization concern, whereas
> you want to actually have it parsed into SAX. AFAIK there is no way using
> the standard <ft:widget> mechanism or XSLT to achieve this.
>
> I think JXTemplate is going to be your best bet. I'm assuming you're
> already using JXTemplateGenerator in your display pipeline; if you're
> using FormsTemplateTransformer instead then I'd suggest switching to JX
> (it's the preferred method nowadays). Then you've got a couple choices:
>
> 1) If you're using the JX implementation from the 'template' block (cocoon
> 2.1.9+ only), then you can use the xmlize="true" attribute of jx:out:
>
> <jx:set var="xhtmlString"
> value='${widget.getChild("myOutputWidget").getValue()}' />
> <jx:out value="${xhtmlString}" xmlize="true" />
>
> 2) If you're using the old JX implementation then you should be able to do
> something similar, but you have to manually create an XMLizable object
> from the String value first (cocoon provides a handy StringXMLizable class
> for this purpose):
>
> <jx:set var="xhtmlString"
> value='${widget.getChild("myOutputWidget").getValue()}' />
> <jx:out
> value="${Packages.org.apache.cocoon.xml.StringXMLizable(xhtmlString)}"
> />
>
Hi Jason,
I tried this second option for the old JXTemplate and I was unable to
see it working: Here is a non working test:
<jx:set var="xhtmlContentTest" value="<html> Hello <b>
world! </b> </html>"/>
<jx:out
value="${Packages.org.apache.cocoon.xml.StringXMLizable(xhtmlContentTest)}"/>
What I am doing wrong?
Best Regards,
Antonio Gallardo.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [CFORMS] HTML in field
Posted by Jason Johnston <co...@lojjic.net>.
So what you're wanting is a way to take the String contents of a form
widget and have it parsed into SAX events and inserted into the SAX
stream, correct? Note that it's not as simple as just disabling escaping
of XML characters, because that's just a serialization concern, whereas
you want to actually have it parsed into SAX. AFAIK there is no way using
the standard <ft:widget> mechanism or XSLT to achieve this.
I think JXTemplate is going to be your best bet. I'm assuming you're
already using JXTemplateGenerator in your display pipeline; if you're
using FormsTemplateTransformer instead then I'd suggest switching to JX
(it's the preferred method nowadays). Then you've got a couple choices:
1) If you're using the JX implementation from the 'template' block (cocoon
2.1.9+ only), then you can use the xmlize="true" attribute of jx:out:
<jx:set var="xhtmlString"
value='${widget.getChild("myOutputWidget").getValue()}' />
<jx:out value="${xhtmlString}" xmlize="true" />
2) If you're using the old JX implementation then you should be able to do
something similar, but you have to manually create an XMLizable object
from the String value first (cocoon provides a handy StringXMLizable class
for this purpose):
<jx:set var="xhtmlString"
value='${widget.getChild("myOutputWidget").getValue()}' />
<jx:out
value="${Packages.org.apache.cocoon.xml.StringXMLizable(xhtmlString)}"
/>
Hope that helps
--Jason
> Thanks for your answer. But I found out that the contents of the fields
> are already escaped before the stylesheets get applied. So the problem
> is somewhere else.
>
> Werner
>
>
> Jeroen Reijn wrote:
>
>> Hi Werner,
>>
>> i'm not sure, but you could modify the xsl that applies the output
>> widget and add something like:
>>
>> <xsl:value-of select="fi:value" disable-output-escaping="yes"/>
>>
>> I hope this helps.
>>
>> Regards,
>>
>> Reijn
>>
>>
>> werner wrote:
>>
>>> Dear Mailinglist!
>>>
>>> I know this has been asked before, but I could not find a clean
>>> solution. How can I display HTML in a output widget and prevent
>>> escaping? i.e. <br/> should not be converted to <br/>
>>>
>>> Thanks you
>>> Werner
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org