The default bug view has changed. See this FAQ.

doesn't implement the HTML-DOM for XHTML created as the result of an XSLT Transformation

NEW
Assigned to

Status

()

Core
XSLT
--
minor
13 years ago
2 years ago

People

(Reporter: Davey Shafik, Assigned: peterv)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(3 attachments, 1 obsolete attachment)

(Reporter)

Description

13 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 MultiZilla/1.6.0.0e
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 MultiZilla/1.6.0.0e

When transforming using XSLT client-side to XHTML, the HTML-DOM is not
implemented for the result tree. This is not the case when XHTML is served directly.

This means, for example, you cannot access document.body in XHTML results of
XSLT Transformations, but you CAN access document.body when the document is
served as XHTML.

Reproducible: Always

Steps to Reproduce:
1. Transform an XML document to XHTML
2. Try to access the DOM

Actual Results:  
Error: document.body has no properties
Source File: http://pixelated-dreams.com/p-d.js
Line: 13

Expected Results:  
It should have created the DOM and the document.body node should have been there.

You can work around this problem in particular by putting an id on the body
element and using:

document.getElementById('bodys_id')
we should instantiate a real xhtml-document when the root element is an
xhtml:html element. Same goes for svg-documents.
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 2

12 years ago
There appears to be no workaround for document.cookie , at least until
DOMImplementation.getFeature() is implemented.

This means a choice between client-side transformation, and client-side scripts
using cookies. Tbh, I'd rather have both.
*** Bug 325835 has been marked as a duplicate of this bug. ***
*** Bug 346886 has been marked as a duplicate of this bug. ***

Comment 5

10 years ago
Is Bug 303557 have a same reason ?

Comment 6

10 years ago
(In reply to comment #2)
> There appears to be no workaround for document.cookie , at least until
> DOMImplementation.getFeature() is implemented.

Just to clear this up, the getfeature method is implemented. However, there is no access to cookies using that interface.

This is the only bug that's preventing me from migrating the whole controlled environment (internal application) from XML/XSLT/HTML to XML/XSLT/XHTML. The workaround to most everything except cookies - i.e. not using HTML DOM, even though theoretically possible, is not practical especially when existing applications are written to the HTML DOM.

Finally, Mozilla already renders the XHTML generated this way as HTML - e.g. HTML forms, elements, etc. are all there. Why can't the logic that decides how to render the document and the logic that decides what DOM objects to instantiate as a result of it be consistent with each other? And if the way it currently works is wrong (i.e. it should not be rendering as HTML because it doesn't "recognize" the HTML document) then why can't the logic be based on xsl:output method (xml), media-type (application/xhtml+xml) and the existence of the root xhtml:html element?

It seems like a relatively easy solution to a bug that's been open for almost 3 years.

Comment 7

10 years ago
Also, there can be used doctype-system attribute of xsl:output element to generate DOCTYPE (for example, see attachment https://bugzilla.mozilla.org/attachment.cgi?id=233758 of Bug 346886).

BTW, I would have been expecting a recursive transformation when the output XML have a stylesheet reference :)
(Assignee)

Comment 8

10 years ago
(In reply to comment #7)
> BTW, I would have been expecting a recursive transformation when the output XML
> have a stylesheet reference :)

No, see http://www.w3.org/TR/xslt#data-model ("Processing instructions and comments in the stylesheet are ignored").
(Assignee)

Comment 9

10 years ago
pixelated-dreams.com doesn't use anything XSLT related afaics.

Comment 10

10 years ago
Example of recursive transformation.

Source xml document, fragment:
<?xml version="1.0" encoding="ascii" ?>
<?xml-stylesheet type="text/xsl" href="struct-pre.xsl"?>
<root>...


The struct-pre.xsl document, fragment:

<xsl:output omit-xml-declaration="no" />
<xsl:template match="/" >
  <xsl:processing-instruction name="xml-stylesheet">
    <xsl:text>type="text/xsl" href="struct-second.xsl"</xsl:text>
  </xsl:processing-instruction>
  <xsl:apply-templates />
</xsl:template>

Тow, the output xml document will get xml-stylesheet instruction and may have next transformation with struct-second.xsl.
(Assignee)

Comment 11

10 years ago
Ah, yes. I don't think we'll support that, if you want to pipeline do it on the server.

Comment 12

10 years ago
(In reply to comment #11)
> Ah, yes. I don't think we'll support that, if you want to pipeline do it on the
> server.

We can do it on the client by using JavaScript. But sometimes such pipelining without JavaScript is more elegant and traffic less.

Comment 13

10 years ago
Created attachment 249764 [details]
Main XML for test case

Comment 14

10 years ago
Created attachment 249765 [details]
XSLT for test case

Comment 15

10 years ago
(In reply to comment #9)
> pixelated-dreams.com doesn't use anything XSLT related afaics.
> 

So that we don't have to rely on original reporter's URLs remaining the same throughout, I uploaded the XML and XSLT files that can be used to reproduce the behavior described.

Comment 16

10 years ago
Created attachment 249777 [details]
Main XML for test case

Modified stylesheet URI in the XML so that it points to the uploaded XSL on bugzilla.
Attachment #249764 - Attachment is obsolete: true
Attachment #249765 - Attachment mime type: text/x-xslt → text/xml
Pipelineing has nothing to do with this bug. Feel free to file a separate bug on it.

Comment 18

9 years ago
Created attachment 327530 [details]
Workaround example

One way to work around the issue is to grab an HTML DOM from a nested HTML object and add the setter and getter for document.cookie.

Comment 19

9 years ago
I should clarify that the attached workaround is only for document.cookie, not for all of the missing HTML DOM properties and methods.
QA Contact: keith → xslt

Updated

7 years ago
Duplicate of this bug: 561083

Comment 21

6 years ago
I also ran into this issue trying to serve xhtml as xml documents. To render them in IE it requires a dummy XSLT transformation, which in turn breaks firefox as it does not add HTML DOM to the transformed output, making this approach useless as it breaks pretty much all javascript.

Comment 22

2 years ago
I can't believe this bug is still not fixed. It should be simple. Cmon Mozilla. Chrome has done it. IE is in even worse shape, as expected.
You need to log in before you can comment on or make changes to this bug.