XSLT bug -- incorrectly added <meta> element to results tree

RESOLVED FIXED in mozilla1.6alpha

Status

()

Core
XSLT
P3
normal
RESOLVED FIXED
15 years ago
15 years ago

People

(Reporter: Ian Graham, Assigned: peterv)

Tracking

Trunk
mozilla1.6alpha
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

(Reporter)

Description

15 years ago
I start with XML data rawdata.xml

<?xml version="1.0" ?>
<?xml-stylesheet href="transform-raw.xsl" type="text/xsl"  ?>
<stuff>
   <data> data inside stuff </data> 
</stuff>

and the transform transform-raw.xsl

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns="http://www.w3.org/1999/xhtml" >
<xsl:output method="xml" indent="yes" />

<xsl:template match="/">
   <html> <head>
   <title> Namespace Fun and Frolic #1 </title>
     </head> <body>
       <xsl:value-of select="//data" />
    </body> </html>
</xsl:template>
</xsl:stylesheet>


I now load rawdata.xml into Mozilla (1.4), which automatically
loads the stylesheet transform-raw.xsl, and displays the generated
results (just the string 'data inside stuff').  

I now use Martin Honnen's javascript: bookmark trick [1] to display
the XML results tree. THe result is:

<a0:html xmlns:a0="http://www.w3.org/1999/xhtml"><a0:head>
<meta http-equiv="Content-Type" content="text/xml; charset=UTF-8"/>
<a0:title> Namespace Fun and Frolic #1 </a0:title>
</a0:head><a0:body> data inside stuff </a0:body></a0:html>

The question: where did the <meta> element come from?  As far
as I can tell, it shouldn't be there.  This looks like an XSLT
bug to me ....

I will attach the example files as a zipped attachment.
(Reporter)

Comment 1

15 years ago
Created attachment 127914 [details]
Zipped XML and XSLT files demonstrating the bug (with a readme)
OS: Windows 98 → All
Hardware: PC → All
There are two problems with the current code. First of all we should only add
the <meta> in html-output. Second we need to honor the mDocumentIsHTML-flag.
I'll whip up a patch
Assignee: peterv → bugmail
this was mostly fixed by bug 207377, in there i added a test to make sure that
the meta is only added during html-output. We still need test mDocumentIsHTML though
(Assignee)

Updated

15 years ago
Attachment #131032 - Flags: superreview?(jst)
Attachment #131032 - Flags: review?(bugmail)
(Assignee)

Comment 5

15 years ago
Taking.
Assignee: bugmail → peterv
Priority: -- → P3
Target Milestone: --- → mozilla1.6alpha
(Assignee)

Updated

15 years ago
Status: NEW → ASSIGNED
Comment on attachment 131032 [details] [diff] [review]
v1

- In txMozillaXMLOutput.h:

+    nsresult createHTMLElement(const nsAString& aName,
+				nsIDOMElement** aResult)
+    {
+	 if (mDocumentIsHTML) {
+	     return mDocument->CreateElement(aName,
+					     getter_AddRefs(aResult));
+	 }
+
+	 return
mDocument->CreateElementNS(NS_LITERAL_STRING(kXHTMLNameSpaceURI),
+					   aName, getter_AddRefs(aResult));
+    }

I'd uninline this code, for two reasons. It's not performance critical (at
least not to the point where wether this method is inlined or not matters), and
that NS_LITERAL_STRING expands to a non-trivial ammount of code on some
platforms. But either way works for me...

sr=jst
Attachment #131032 - Flags: superreview?(jst) → superreview+
(Assignee)

Comment 7

15 years ago
Created attachment 131038 [details] [diff] [review]
v1.1
Attachment #131032 - Attachment is obsolete: true
(Assignee)

Comment 8

15 years ago
Comment on attachment 131038 [details] [diff] [review]
v1.1

Transfering sr=jst.
Attachment #131038 - Flags: superreview+
Attachment #131038 - Flags: review?(axel)

Comment 9

15 years ago
Comment on attachment 131038 [details] [diff] [review]
v1.1

r=axel@pike.org, I prefer the non-inlined version, too. Esp. as this is going
to go thru more code, once Jonas does his output sink work (getting rid of the
argument to endElement, not calling document.createElement but using element
factories directly)
Attachment #131038 - Flags: review?(axel) → review+
(Assignee)

Updated

15 years ago
Attachment #131032 - Flags: review?(bugmail)
(Assignee)

Comment 10

15 years ago
Checked in.
Status: ASSIGNED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.