Project

Profile

Help

Bug #1482

Failure to write to implicit (body) destination if it is XHTML

Added by Manfred Staudinger over 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Sprint/Milestone:
Start date:
2012-04-19
Due date:
% Done:

100%

Estimated time:

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
svg-t5-011.svg (516 Bytes) svg-t5-011.svg Manfred Staudinger, 2012-04-19 11:02
svg-t5-011.xhtml (2.48 KB) svg-t5-011.xhtml Manfred Staudinger, 2012-04-19 11:02
svg-t5-browser-v2.xsl (1016 Bytes) svg-t5-browser-v2.xsl Manfred Staudinger, 2012-04-19 11:02
svg-t5-tab.xml (1.5 KB) svg-t5-tab.xml Manfred Staudinger, 2012-04-19 11:02

History

#1 Updated by Philip Fearon over 8 years ago

  • Status changed from New to In Progress
  • Assignee set to Philip Fearon
  • Priority changed from Low to Normal

#2 Updated by Philip Fearon over 8 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.

#4 Updated by Philip Fearon over 8 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

#5 Updated by Philip Fearon over 8 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:

#6 Updated by Philip Fearon over 8 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

#7 Updated by Manfred Staudinger over 8 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.

#8 Updated by Philip Fearon over 8 years ago

  • Fixed in version set to Beta 0.2

#9 Updated by Philip Fearon over 8 years ago

  • Sprint/Milestone set to Beta 0.2

#10 Updated by Philip Fearon over 8 years ago

  • Found in version set to Beta 0.1

#11 Updated by Michael Kay over 8 years ago

  • Subject changed from Default element template to Failure to write to implicit (body) destination if it is XHTML

#12 Updated by O'Neil Delpratt over 7 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

#13 Updated by O'Neil Delpratt over 7 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

Also available in: Atom PDF