Open Bug 230214 Opened 21 years ago Updated 2 years ago

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

Categories

(Core :: XSLT, defect)

x86
Windows XP
defect

Tracking

()

People

(Reporter: davey, Assigned: peterv)

References

()

Details

Attachments

(3 files, 1 obsolete file)

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
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. ***
Is Bug 303557 have a same reason ?
(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.
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 :)
(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").
pixelated-dreams.com doesn't use anything XSLT related afaics.
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.
Ah, yes. I don't think we'll support that, if you want to pipeline do it on the server.
(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.
Attached file Main XML for test case (obsolete) —
Attached file XSLT for test case
(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.
Attached file 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.
Attached file 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.
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
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.
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.

It seems this bug is fixed now. It isn't reproducible in Firefox 69.0.1.

Also document.createElement can create a proper HTML element (and proper namespace in namespaceURI) when media-type attribute of xsl:output is set to "application/xhtml+xml"

<xsl:output
  encoding="UTF-8"
  doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  media-type="application/xhtml+xml"
  omit-xml-declaration="yes"
  indent="no"
  method="xml"
/>
Severity: minor → S4

The severity field for this bug is relatively low, S4. However, the bug has 3 duplicates and 14 votes.
:peterv, could you consider increasing the bug severity?

For more information, please visit auto_nag documentation.

Flags: needinfo?(peterv)

The last needinfo from me was triggered in error by recent activity on the bug. I'm clearing the needinfo since this is a very old bug and I don't know if it's still relevant.

Flags: needinfo?(peterv)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: