all groups > dotnet xml > december 2004 >
You're in the

dotnet xml

group:

How to pass a Nodeset to an XPath extension function?


How to pass a Nodeset to an XPath extension function? Damien Goutte-Gattat
12/31/2004 1:19:06 AM
dotnet xml:
I am using the .NET framework v2.0.40607 with Visual C# Express and I would
like to create some custom XPath functions to use directly in a XSLT
stylesheet.

I called System.Xml.Query.XmlArgumentList.AddExtensionObject(string, object)
to register the functions I've written.

The functions that take a String, Boolean or Number parameter work
perfectly. However, I do not know how to create a function that will accept a
Nodeset as a parameter.

I tried writting a function taking a XPathNavigator object, but it does not
work for all XPath queries that return a Nodeset: I get an error "Xml type
'item' does not support a conversion from a Clr
'MS.Internal.Xml.XmlQuerySequence', which contains multiple items, to a
single item."

Is this a bug or the normal, expected behavior? If it is normal, then how to
write a function that will accept a Nodeset parameter?

RE: How to pass a Nodeset to an XPath extension function? Damien Goutte-Gattat
12/31/2004 1:55:01 AM
I think I've figured out the solution.

I've written a function that takes an ARRAY of XPathNavigator, and it seems
to work. Each XPathNavigator object represents one of the node present in the
Nodeset.

[quoted text, click to view]
AddThis Social Bookmark Button