Failure to write to implicit (body) destination if it is XHTML
xsl:apply-templates selects an element for which no template is specified, an error is thrown:
#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.
#3 Updated by Manfred Staudinger over 8 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.
#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:
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
#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.
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
Please register to edit this issue