Bug #1675
closedTransforming parentless element on .NET
100%
Description
From Max Toro maxtoroq@gmail.com on the Saxon help list:
I'm using Saxon-HE 9.4.0.6 for .NET
I'm having trouble with a transformation that uses a root element node
(doesn't have a parent document node) as initial context node. I get a
NullReferenceException on Saxon.Api.XsltTransformer.Run(XmlDestination
destination), looking with reflector I suspect the issue might be with
one of these lines:
DocumentInfo doc = this.initialContextNode.getDocumentRoot();
this.controller.registerDocument(doc, (doc.getBaseURI() ==
null) ? null : new DocumentURI(doc.getBaseURI()));
I think it's trying to get the root node as a document node, which it
isn't. This element node is constructed in an XSLT transformation,
passed as argument to an integrated extension function which uses it
as initial context node in a new transformation, which is the one that
fails.
Besides the NullReferenceException, does XSLT allow you to start a
transformation with a parentless element?
Updated by Michael Kay over 11 years ago
My response: Yes, the specification allows a parentless element to be supplied as the
initial context node, and it's an oversight in the implementation (and
the test cases) that this isn't working. We'll treat it as a bug.
Note: I've checked that this works on Java (with an amended version of the unit test TestQueryToTransform. We need a similar test on .NET.
Updated by O'Neil Delpratt over 11 years ago
- Status changed from New to In Progress
So far I have managed to reproduce the exception with a test case. Currently investigating.
Updated by O'Neil Delpratt over 11 years ago
- Status changed from In Progress to Resolved
A parentless element returns null on a getDocumentRoot()
call, therefore I have added a conditional statement to the code in question: @this.controller.registerDocument(doc, (doc.getBaseURI() == null) ? null : new DocumentURI(doc.getBaseURI()));@, which prevents the NullReferenceException from being thrown.
Bug fixed and committed to subversion. Thanks to Max for the pointer.
Updated by O'Neil Delpratt about 11 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in version set to 9.4.0.7
Bug closed. Fixed in Saxon maintenance release 9.4.0.7
Please register to edit this issue