Bug #1482
closedFailure to write to implicit (body) destination if it is XHTML
100%
Description
When xsl:apply-templates
selects an element for which no template is specified, an error is thrown:
SEVERE: XPathException com.google.gwt.core.client.JavaScriptException:
(TypeError): Cannot convert 'b' to object
Files
Updated by Philip Fearon over 12 years ago
- Status changed from New to In Progress
- Assignee set to Philip Fearon
- Priority changed from Low to Normal
Updated by Philip Fearon over 12 years ago
I've tried reproducing this, using xsl:apply-templates for elements within the page.
Perhaps there's something specific you're doing with the result that is causing this error?
If you can send us a simple case (html, xml and xslt) that reproduces this, it will help narrow down the issue.
Updated by Manfred Staudinger over 12 years ago
- File svg-t5-011.svg svg-t5-011.svg added
- File svg-t5-011.xhtml svg-t5-011.xhtml added
- File svg-t5-browser-v2.xsl svg-t5-browser-v2.xsl added
- File svg-t5-tab.xml svg-t5-tab.xml added
I've uploaded a test:
The files are attached.
Updated by Philip Fearon over 12 years ago
I've run the test files you sent on Opera, and - with the latest internal Saxon-CE build - I'm getting a more informative error message:
SEVERE: XPathException in invokeTransform: An empty sequence is not allowed as the value of variable $svg
To get a bit more context, I tried running this in Trace mode (included in the next Saxon-CE release), I get this:
This error is what you would expect if the expression in the $svg variable defintion returned an empty sequence (because of @as="element()@")
Looking closer at your XSLT - there are no namespace declarations for XHTML or SVG, so I added these:
@xmlns:svg="http://www.w3.org/2000/svg"
xpath-default-namespace="http://www.w3.org/1999/xhtml"@
And then changed the $svg XPath to:
<xsl:variable name="svg" select="ixsl:page()/html/body/svg:svg" as="element()"/>
This now runs with no error:
One thing to note is that I'm using the latest build of Saxon (because this build has your XHTML workaround for GWT)which is fully namespace aware, in Beta 0.1 there were probably cases where namespace issues such as those I've corrected weren't picked up.
Now this part of the XSLT runs I will check things a bit further - to check what apply-templates is actually doing here with those g elements
Updated by Philip Fearon over 12 years ago
Right, I'm on track again - after clearing up that namespace issue which, as suspected, wasn't the root cause. I now get the same error message as you do:
Updated by Philip Fearon over 12 years ago
- Status changed from In Progress to Resolved
The cause for this issue has now been found and it's fixed for the next release. More details:
When xsl:apply-templates is called (in the supplied repro), it isn't within an xsl:result-document instruction. The result tree should therefore be appended by the receiver to the end of the HTML body element. The issue is that the tag name for the body element is assumed to be @BODY@, however, for XHTML the tag name is actually @body@. The target node for the receiver is therefore null, an exception is therefore thrown when an attempt is made to create nodes with this as the owner.
The cryptic error message was caused by the error being unexpected and therefore unhandled, so a GWT error message was reported.
With the fix in place, the XSLT runs without error and the 8 text nodes created by apply-tempates (each with content of a single number from 0 to 7) are appended at the end of the body element.
Workaround:¶
To add nodes directly to the body of an XHTML document, the xsl:result-document instruction can be used with the method
set to ixsl:append-content
and the href to either #body-id (where body-id is the id of the body element) or ?select=ixsl:page()/body
Updated by Manfred Staudinger over 12 years ago
Thanks, this makes perfect sense! I must confess, I ignored the title
and thought circle
as an empty element. What I found as a workaround
- <xsl:template match="circle" mode="initial-attr"/>
now turns out to be necessary code.
Updated by Michael Kay over 12 years ago
- Subject changed from Default element template to Failure to write to implicit (body) destination if it is XHTML
Updated by O'Neil Delpratt almost 12 years ago
- Status changed from Resolved to Closed
- Fixed in version changed from Beta 0.2 to 1.0
Fixed in Saxon-CE version 1.0
Updated by O'Neil Delpratt almost 12 years ago
- Sprint/Milestone changed from Beta 0.2 to Release 1.0
- % Done changed from 0 to 100
Please register to edit this issue