Closed Bug 271838 Opened 20 years ago Closed 20 years ago

XSLT engine fails to handle <xsl:comment> correctly

Categories

(Core :: XSLT, defect)

x86
Windows 2000
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: lmbrtgrg, Assigned: peterv)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.7.5) Gecko/20041110 Firefox/1.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.7.5) Gecko/20041110 Firefox/1.0

... Normal Simple <head> element containing ...
<script type="text/javascript">
<xsl:comment><xsl:text>
function initPage(){ initMyHandlers();}
// </xsl:text></xsl:comment>
<head>
<body onload="initPage()">
... Rest of <body> ...

JavaScript console reports:
Error: initPage is not defined

Removing the <xsl:comment> tags, or commenting them out with <!-- --> allows the
javascript to be seen.


Reproducible: Always
Steps to Reproduce:
1. Constrcut a simple XSLT file with some JavaScript commented out as in "Details"
2. Construct a simple XML input file, with the file in "1." set as style sheet
3. Use Firefox to read the XML file

Actual Results:  
As in "Details"
JavaScript console reports:
Error: initPage is not defined

or fails to find any JavaScript when enclosed in <xsl:comment> elements


Expected Results:  
The behaviour with other transformer engines (e.g. Xalan) is:
The <xsl:comment> element should place HTML comment markers in the output, and
not act as comments within the XSLT text, thus preventing the transform from
being applied.
Ordinary HTML comments are used in the XSLT script to comment out XSLT text that
is not to be output.

Thought:
XML Transform processing would be useful as a separate component, as the
behaviour is different from HTML (I think).

Although not a serious fault it prevents immediate display of XML files to check
their consistency, and means that the intermediate step using Xalan or similar
must always be used.
Same as bug 221862 ?

->XSLT anyway.
Assignee: firefox → peterv
Component: General → XSLT
Product: Firefox → Core
QA Contact: firefox.general → keith
Version: unspecified → Trunk
Read your HTML spec. Parsing inside script tags doesn't have html comments,
thus, <script><!-- --></script> does not generate a comment, but a text.

When generating output with XSLT, you want to generate a text as well, but not a 
comment.

If you really want the <!-- --> in there, you should do 

<script type="text/javascript">
 &lt;!--
 some js
 --&gt;
</script>

(Note, both CSS and js specs are made such they actually handle a preceeding 
"<!--" fine.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Also, the purpose of "commenting out" the contents of <script>s and <style>s was
so that old browsers that didn't support these tags wouldn't display the
contents. However I seriously doubt that there's a browser out there that
supports XSLT but doesn't support <script> or <style>.

So just save yourself the effort and don't bother with the "commenting out".
You need to log in before you can comment on or make changes to this bug.