Project

Profile

Help

Bug #1675

Transforming parentless element on .NET

Added by Michael Kay over 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Category:
.NET API
Sprint/Milestone:
-
Start date:
2013-01-08
Due date:
% Done:

100%

Spent time:
-
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Found in version:
9.4
Fixed in version:
9.4.0.7

Description

From Max Toro <> 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?

History

#1 Updated by Michael Kay over 3 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.

#2 Updated by O'Neil Delpratt over 3 years ago

  • Status changed from New to In Progress

So far I have managed to reproduce the exception with a test case. Currently investigating.

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

#4 Updated by O'Neil Delpratt about 3 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

Also available in: Atom PDF