Multimobile Development: Building Applications for any Smartphone
Subclassed XPathNodeIterator not accepted by XslTransform?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.xml.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Gleb Holodov
GOOD ANSWER
Hi!

I'm making a custom XSLT extension object (to be used via XsltArgumentList.
AddExtensionObject) and one of its functions accessible from XSLT returns a
node iterator:

-----v
public XPathNodeIterator UniqueNodes( XPathNodeIterator nodes, string
keyXPath )
-----^

So far so good. Returning XPathNodeIterator acquired from the calls to
standard .NET XPath classes works OK, but trying to return my own custom
node iterator derived from XPathNodeIterator raises the next error:

-----v
System.NotSupportedException: XPathNodeIteratorOnCollection is an
unsupported type.
at System.Xml.XPath.XsltFunction.InvokeFunction(XPathNavigator qy)
-----^

My node iterator is defined as
-----v
public class XPathNodeIteratorOnCollection : XPathNodeIterator
-----^
and it implements all the methods described in the SDK. After playing with
ILDASM for awhile, I've figured out that an exception above is thrown after
unsuccessful attempt to cast my iterator to
System.Xml.XPath.ResetableIterator, which is marked as private and therefore
could not be inherited in user apps. So, it appears that all those
magnificent words in XPathNodeIterator docs like "When overridden in a
derived class, ..." are for MS-eyes only [sigh]... Obviously, currently it's
by-design. Will the situation change in the next release?

So, what I need is to make a C# XSLT function, which will return a node
set, for which members I can't generate an XPath query and then take a
standard iterator via XPathNavigator.Select.

Can anyone suggest any acceptable workaround? Any help would be greatly
appreciated!

--
Warmest regards, Gleb Holodov

Software Developer
ThinkWave Inc.
www.thinkwave.com
Click here to reveal e-mail address

Reply to this message...
Vote that this is a GOOD answer... (8 votes from other users already)
 
 
    
Dare Obasanjo
GOOD ANSWER
Thanks for the pointer, a bug for this has been filed which should be fixed
in a future release.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

"Gleb Holodov" <Click here to reveal e-mail address> wrote in message
news:O2pVUqUJCHA.3980@tkmsftngp10...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (12 votes from other users already)
 
 
    
Tomas Restrepo (VIP)
GOOD ANSWER
Hi Dare,

> Thanks for the pointer, a bug for this has been filed which should be
fixed
> in a future release.

Hope so! I got bitten by that problem a few weeks ago (see [1] and [2] for
the gory details), so I'd really like to see it fixed ;)

[1] http://www.winterdom.com/weblog/archives/000087.html
[2] http://www.winterdom.com/weblog/archives/000091.html

--
Tomas Restrepo
Click here to reveal e-mail address

Reply to this message...
Vote that this is a GOOD answer... (9 votes from other users already)
 
 
    
Leigh L. Klotz, Jr.
GOOD ANSWER
I have some code for working around this, which I posted to
microsoft.public.dotnet.xml on 17 Jun 2002. Briefly, you write an
extension object that does the calculation for the XmlNodeList and
returns an XPath expression that selects that unique node-set; you
then use the existing XPath operations in .NET for creating and
returning that object from the extension object.

See http://groups.google.com/groups?selm=c909239.0206171642.4b165c55%40posting.google.com

"Dare Obasanjo" <Click here to reveal e-mail address> wrote in message news:<e3HiFh6JCHA.1596@tkmsftngp13>...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (9 votes from other users already)
 
 
 
System.NotSupportedException
System.Xml.XmlNodeList
System.Xml.XPath.XPathNavigator
System.Xml.XPath.XPathNodeIterator
System.Xml.Xsl.XsltArgumentList




Multimobile Development: Building Applications for any Smartphone
Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734