note that I copied your example and the xsl-value-of should read as xsl:value-of
Main Topics
Browse All TopicsHi,
values in a "textarea" on a web form is stored in a database and retrived from database by xml and xslt. What we want to achieve is to write text with html code (to format the text), save it in the database and show it on the same web page. In the textarea we can write "This text shows <b>bold text</b>". The string with <b> tag is stored in the database, but when retrived in xsl file by <xsl-value-of> then the text is written as we wrote it with html tags and text is not formatted inside the textarea.
How can we write/modify the text with html tags in a textarea and show it afterwards when it's saved in the database within the same textarea? Is it possible or do we need to do it in another way?
Reg
Stian
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
CDATA will have the opposite effect.
Everything inside the CDATA in the XSLT will be considered a textnode and the data will be escaped
from how I understand the question, this is what the original poster does not want
> then the text is written as we wrote it with html tags and text is not formatted
but reading the question again, I am not sure anymore
I have added 'disable-output-escaping="
xsl-file
<textarea rows="4" cols="60">
<xsl:value-of select="@comment" disable-output-escaping ="yes"/>
</textarea>
output
This
If I move
<xsl:value-of select="@comment" disable-output-escaping ="yes"/>
outside the <textarea>, ie in a <div> then it shows ok, formatted correctly
@serrutom, no that is not the point.
You are right that you can not have CDATA inside an attribute, but in this case that simply doesn't matter
Whether this is CDATA or an escaped text node does not matter for the XSLT
The parser will make the CDATA an escaped text-node before it even reaches the XSLT
Obviously abgsc has access to the correct escaped text node, but is unable to unescape it in the text area
That is the real issue
Your problem is not the text area, but your xml source data file.
If you don't escape the content coming from your server, you will get errors or.
<node>
<comment><![CDATA[<b>test</b>]]></c
</node>
is not the same as
<node>
<comment><b>test</b></comment>
</node>
and this is not allowed
<node comment="<b>test</b>">
</node>
Your <b> tas is seen as a node of the xml and your xml will not be well-formed
well, my last statement is somewhat vague
using disable-output-escaping abgsc can unescape the text node in the text area,
but this doesn't have the desired layout effect
I checked, you simply can not layout text in a text area.
So you should go from my earlier suggestion, have two divs,
one with the text area that contains the html code
and one with the layouted view of what is originally in the text area
you can add a button that allows you to "preview" the content of the text area in the "preview" pane
@serrutom, mmh, somewhere you diverted from the issue and you seem to be a bit slow in getting back on track
read this
>If I move
> <xsl:value-of select="@comment" disable-output-escaping ="yes"/>
> outside the <textarea>, ie in a <div> then it shows ok, formatted correctly
which indicates the problem is not in the storage but in the view
and then reread my two last posts
@abgsc... can you post your input xml file and the part of your xslt file?
@Gertone... You assume that the data is escaped, i haven't seen a post that told us the data is escaped, or haven't seen an example. Abgsc wrote: In the comment field I write this text "This is <b>bold text</b>". This means to me that the data isn't escaped as it get to the parser.
@Gertone... i think i'm not realy slow to get on my track...!
First note that this is a question in the threads: HTML, XSLT and ASP
If I then read the word "textarea", I automatically assume a HTML form with a text area input field
http://www.w3schools.com/T
just to make sure that we get the semantics right
If I then read the part you quoted
abcsg> I write this text "This is <b>bold text</b>".
I understand writing as typing text in the text area.
There is no parser touching this, and when it is sent to the server, it will be sent as a text stream, escaped to make it a legal html text stream
serrutom> i haven't seen a post that told us the data is escaped
yes you have seen a post that proves the data is escaped
combine this statement from the original question
abgsc> <xsl-value-of> then the text is written as we wrote it with html tags
with this later statement
abgsc> <xsl:value-of select="@comment" disable-output-escaping ="yes"/>
abgsc> outside the <textarea>, ie in a <div> then it shows ok, formatted correctly
Now think:
data goes in as tags (in a text area, actually then I allready know it will be escaped when sent back to the server, but anyhow)
data comes back as a literal string containing the tags
tell me which XSLT processor will spit out the tags using <xsl:value-of> if it were real tags, not an escaped string.
You could be right if abgsc used <xsl:copy-of> but he claimed he used <xsl:value-of>
xsl:value-of will only concatenate all the text nodes, and drop the tags... so if the tags reappear... they must have been in the text node
This is I think enough proof as a foundation to my claims
I assume you never came accross disable-output-escaping, I usually recommend not to use it anyway, but here is meets its proper use case
@Gertone...
Some respect, friendlyness and respect for other poster would be nice... You might be a hot-shot, but other people have some knowledge to.
I thought we just want to find a good solution for abgsc, and don't start a war here.
I want to enjoy myself on Experts Exchange and learn from other peoples problems and situations.
While doing this I don't like to be called a dumb-nut, and be shouted at.
@abgsc...
Sorry it got this far, but i just wanted to help
With this said... I withdraw.
Have a nice day
PS: I have been writing XML/XSLT transformations for the past 10 year... I know what I'm talking about.
@serrutom,
sorry, if you felt that I was trying to start a war, and if one way or another I offended you, my sincere apologies.
I just felt misunderstood and all I tried to do is build up my case to explain to you what I think is happening.
I don't feel like a hot-shot at all, and had not a single intention at all to shout at you or call you a dumb-nut.
Sorry if my words gave you that impression, you must have understood them in another way the I intended them
(let us say that they juqt came out wrong, to meant well, English is not my mother tongue)
Yes, I am just trying to find a good solution for the original poster,
and would be happy to be proven not right, no problem with that
Again, my apologies
Geert
serrutom, the problem is as gertone describes. What I want to achieve is to edit and show text with html in the same textarea tag, but that is not possible I guess.
As I understand, the solution is to have one input field (can be a <textarea>) where the text with html tags is entered. This info is then saved in the database, incl tags as plain text. To show this text rendered as html I need a second field, but it is not possible to use a <textarea> since html code is not working inside this tag (I have tried it and it do not work).
Maybe the TinyMCE editor an option:
http://tinymce.moxiecode.c
double pane:
Basically. add a div above the text area. give the div an identifier (id attribute), also give the text area a id attribute
put a button on the page with a java script action that pushes the value of the textarea to the div (some sort of overwrite of the html innerHtml) Not sure what will happen to the code
Note that if you use client XSLT for this... disable-output-escaping is NOT supported by Mozilla based browsers
TinyMCE:
have no real experience with these editors. Seems like a plausible one.
Just make sure that if you need browser independence, you need to test for that when evbaluating.
I have come accross a couple that use ActiveX, and as such can only be used for IE
Business Accounts
Answer for Membership
by: GertonePosted on 2009-11-05 at 02:54:31ID: 25748222
use es" select=".">
<xsl-value-of disable-output-escaping="y
instead of
<xsl-value-of select=".">
the output escaping is disabled this way an a < will not be escaped as an entity