Blog  |   Sitemap  |   Search  |   Language:  eng рус
Home
JavaScript GUI FrameworkMostbet AzerbaycanBug TrackerBug details

Bug Data

ID: #0164
Status: Accepted
Severity: Normal
Reporter: Leif Halvard Silli
Submitted: 01-02-10 10:55

Product Data

Product: Ample SDK
Component: DOM Core
Version: 0.8.x
OS: Windows XP
Browser: > Internet Explorer 8.0

Description

Compatibility with HTML4 (four) - aka SGML syntax

This bug relates to version 6, 7 and 8 of Internet Explorer.

CHALLENGE: Embedding SVG via <script type="application/ample+xml"> is invalid HTML4 (four) because any "</" in the breaks the SGML rules that HTML4 is based on.

POSSIBLE SOLUTIONS:

(ALT. 1) For JavaScript, then it is customary to place the script inside a HTML comment.
<script type="application/ample+xml"><!-- <svg:svg></svg:svg>--></script>

(ALT. 2) Another option is to escape the "/" in the end tags - this makes it valid SGML:
<script type="application/ample+xml"><svg:svg><\/svg:svg></script>

(ALT. 3) A third option is to place the SVG code inside a <![CDATA[ ]]> tag.

<script type="application/ample+xml"><!----><![CDATA[
<svg:svg><svg:text>lorum ipsum</svg:text></svg:svg>
<!---->]]></script>

EXPLANATION OF ALT. 3: the <!---> will makes sure that the rest of the line is interpretated as a (JavaScript) comment, while at the same time being valid as mark-up. There should also

EVALUATION: My preference is for ALT 3. Then we do not need to escape the SVG code itself. However, ALT. 1 is also possible, I guess. But the question is: You use the code <script type="application/ample+xml">. Is it compatible with the design of the AML language to use <!-- --> and even <![CDATA[ ... ]]> ?

BUG: Regardless of whether it is formally compatible with the design of AML, the fact is that ALT 3 works fine in Webkit, Firefox and Opera. ** BUT NOT IN IE 6, 7 and 8! **

The bug in IE is however appears to be possible to fix. Because, the text of the SVG code is visible. It is only the SVG styling that fails.

TEST CASE: I read your article in O'Reilly InsideRIA (http://www.insideria.com/2009/07/yes-you-can-now-use-quite-a-bi.html )

Then I created my own test case, where I use the above escaping method with <![CDATA[ .... ]]>

URL to test page: http://www.målform.no/ample/ample2

NOTE: Please note that the W3 validator has a bug with regard to <![CDATA[ ]]> inside <script> element in HTML4 documents: For some reason the validator *still* believes that we must escape each "/", despite that I have used <![CDATA[ ]]>. I filed a bug against the W3C validator today, as a result of my experiments with AmpleSDK. In the bug I ask them to correct the validator in accordance with the HTML4 specification: http://www.w3.org/Bugs/Public/show_bug.cgi?id=8852

Hope you find this useful and that you pick up and solve the issue. ;-) Marvelous things, this AmpleSDK!

Messages written for this bug

Reporter: Rob Krueger
Submitted: 01-02-10 18:34
Message: Leif Halvard,

1) I checked out your page http://www.målform.no/ample/ample2 and here is what I think happened: By using CDATA section you simply escaped content supposed for Ample SDK from processing by the engine and passed content directly to the browser native renderer (that is why you did not see any actual SVG drawing in IE!). It has worked with SVG but it would not work with XUL!

2) Regarding Compatibility with HTML4
I implemented following escaping mechanism (http://github.com/clientside/amplesdk/commit/28c9ef3cf4964f3e98d4e2804a24584a952b8c6c):
<script type="application/ample+xml"><![CDATA[
<svg:svg><svg:text>lorum ipsum</svg:text></svg:svg>
]]></script>

Is the above enough for compatibility you are looking for, or the comment tags are also necessary, like in your suggested snippet?
<script type="application/ample+xml"><!----><![CDATA[
<svg:svg><svg:text>lorum ipsum</svg:text></svg:svg>
<!---->]]></script>

A test build will be available tonight.

Reporter: Leif Halvard Silli
Submitted: 01-02-10 21:33
Message: Hi Rob, thanks for your follow-up!

Note to self: The subject of this bug is compatibility with HTML4 when using the <script> element. I will file another bug about how to be HTML4 compatible when placing the <SVG> code _(in)directly_ the HTML code (outside <script>)

PART I: formal compatibility with the required HTML4 syntax
=====================================

(A) Yes, I understand that I did something that Ample did not anticipate ... It is of course kind of logical that the AML language doesn't expect <![CDATA[]]>

(B) I had some responses in the mailinglist for the W3C Validator. Basically, I can now say that the bug I filed against Validator is not 100% accurate ... To put it bluntly, I was wrong. ;-) The thing is that, for compatibility with HTML4, then <![CDATA[ ]]> inside <script></script> is irrelevant. What is relevant is that each end tag is escaped.

<script type="application/ample+xml">
<aa>
<bb>
<\/bb>
<\/aa>
</script>

(C) So, the use of <![CDATA[ ]]> is only relevant if compatibility with BOTH XHTML and HTML4 is needed. In that case, then one must use BOTH <![CDATA[ ]]> AND escaping the end tags:

<script type="application/ample+xml">
<![CDATA[
<aa>
<bb>
<\/bb>
<\/aa>
]]></script>

CONCLUSIONS
=========

PART 1: HTML4 syntax
------------------
* I would like that AML/AmpleSDK accepts that authors escape the end tags - like this: <\/endtag>


PART II: XHTML syntax
------------------

* I would like that AML/AmpleSDK accepts that authors wrap the SVG code inside <![CDATA[ script ]]>, as demonstrated above. Unless one do this, then the new elements will not formally be accepted by the W3C XHTML validator.

(In theory, the new elements would/could be accepted, by using the AML namespace correclty, I guess. So, in a way, <![CDATA[ ]]> comes in as an alternative to the namespace ... may be.)


PART III: compatibility with user agents - including Webkit and IE
========================================

You asked if it was necessary to use the HTML comments:

<script type="application/ample+xml">
<!----><![CDATA[
<aa>
<bb>
<\/bb>
<\/aa>
<!---->]]></script>

The answer is that I did several tests, with text/javascript scripts and with application/ample+xml scripts, and my experience was that this was more compatible.

User Agents will interpret this,

<!----><![CDATA[

as a one line JavaScript comment. Of course, one may instead do this:

//<![CDATA[

However, it looks to me as if // has even less to do with the AML language than <!----> has. <!----> should be fully compateible with AML. But, you should perhaps accept both <!----> and //.

SUMMARY: By implementing support for Part 1 (especially) and also preferrably Part 2 and Part 3, then AmpleSDK will allow authors to always insert SVG (and other mark-up) with (I hope) 100% compatibility with both HTML4 and XHTML and with text/HTML user agents/parsers.

Over to you ;-)

Add a message
BugTracker