How to prevent the XSLT processor from escaping quotes and double quotes?

Poster Content
nk4um User
Posts: 168
January 18, 2011 14:15
Thanks! And yes I''m using NetKernel 4.
Like · Post Reply
nk4um Administrator
Posts: 607
January 18, 2011 12:50
Yep, I''ll give this change a try and check it doesn''t break anything and then send you a patched module to try out to see if it helps you. If that''s all ok we can roll it into a distribution. Can you confirm you are using NetKernel 4.*

Cheers, Tony
Like · Post Reply
nk4um User
Posts: 168
January 18, 2011 10:32
Hi Tony!

Thanks for the idea, but I cannot easily add comments because the JS code is automatically generated. I am using XSLTForms and I want to do the XSLT transformation on the server-side (that''s why I''ve encountered this escaping problem and the lack of xsltproc''s --path option as in the other thread).

So do you think that you will modify the "writeEscaped" function so that it does the escaping according to the XML specification?

Thanks!

Gregoire
Like · Post Reply
nk4um Administrator
Posts: 607
January 17, 2011 14:26
One simple workaround for this situation is to use comment sections around javascript. I''ve done that in the past and it works.

Cheers, Tony
Like · Post Reply
nk4um User
Posts: 168
January 17, 2011 12:47
s/IMAO/IMHO
Like · Post Reply
nk4um User
Posts: 168
January 17, 2011 12:46Yes
Hi!

Yes I believe it would work with the standard escaping of XML. The problem I am experiencing is that quotes used in JavaScript "texts" are escaped, and browsers don''t recognize JavaScript code if they are. Sticking to the standard may be the best idea here IMAO.

Thanks!
Gregoire
Like · Post Reply
nk4um Administrator
Posts: 607
January 17, 2011 12:10Possible bug
Hi Gregoire, sorry about loosing track of this one. The code that does the escaping is very old and not been touched for a long time.

I''ve just reread the XML spec (http://www.w3.org/TR/2008/REC-xml-20081126/) and it appears to say this:

1) Escaping for attributes should be for quote and less-than. Where quote is either single or double depending on the type wrapping the value.

2) Escaping for text should be ampersand and less-than.

Currently the escaping implemented in writeEscaped is more zealous than this. Is the above description what you were expecting?

Cheers, Tony
Like · Post Reply
nk4um User
Posts: 168
January 17, 2011 09:47Is this a bug?
Hi,

I would like to know if the behaviour discribed above is a bug. Please help!

Thanks!
Gregoire
Like · Post Reply
nk4um User
Posts: 168
November 29, 2010 15:40A bug?
Hi Menzo!

Thanks for the link. This "writeEscaped" method seems to do more than what''s needed. It does seem like a bug to me. I hope 1060''s team will tell us.

G
Like · Post Reply
nk4um User
Posts: 111
November 29, 2010 15:05
Sorry, of course the output method is HTML ... your examples show exactly that.

Feature request: can the NK forum Post Reply form show me a copy of the post/thread I''m replying to ;-)

Menzo
Like · Post Reply
nk4um User
Posts: 111
November 29, 2010 15:02
Hi, Gregoire,

This isn''t really due to the XSLT processor, in NK3 at least ;-) It''s a ''feature'' of the NK HTML serialization of a DOMXDA. See my last post in the following thread http://www.1060.org/forum/topic/442/1.

So you might try if the escapes don''t happen if the output method of your XSLT is XML not HTML (if it is that at the moment).

Hope this helps (a bit),

Menzo
Like · Post Reply
nk4um User
Posts: 168
Hi!

I''m trying to use XSLT in NetKernel and I notice that the XSLT processor escapes quotes and double quotes to their UTF-8 equivalents (39 and 34). When I use "xsltproc" (from libxml) they are not escaped, which is the expected behaviour.

I have this in my XSL:

<xsl:output method="html" encoding="utf-8" omit-xml-declaration="no" indent="no" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>


I serve the result as text/html with:

<header name="mime">text/html</header>


in "module.xml". Is it normal, and if so, how can I tell the XSLT processor to output the quotes "as is"?

Thanks!

Gregoire
Like · Post Reply