473,804 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pass a Nodeset to an XPath extension function?

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.Quer y.XmlArgumentLi st.AddExtension Object(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.Xm l.XmlQuerySeque nce', 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?

Any help will be appreciated. Thanks.
Nov 12 '05 #1
1 2465
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.

"Damien Goutte-Gattat" wrote:
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.Quer y.XmlArgumentLi st.AddExtension Object(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.Xm l.XmlQuerySeque nce', 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?

Any help will be appreciated. Thanks.

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
16661
by: Sebastian Petzelberger | last post by:
Hi group, please give me an example of a xpath with regex or better a link with examples. Thanks in advance, Sebastian
4
3525
by: Brad | last post by:
Help, I have a really complicated XPATH request I can't wrap my head around I have an XML nodeset like this: <a> <a1 attr="key">Use</a1> <a1 attr="val">Value1</a2> </a> <a> <a1 attr="key">DontUse</a1>
2
1342
by: Bryan Galvin | last post by:
Hi all, I posted a message on this topic before, but now I have a request for help. Previously "A. Bolmarcich" answered this query for me, but the problem has changed slightly... I have two node-sets a= <values> <value>A</value>
1
1506
by: ssvendsen | last post by:
Hi, In my XML dialect I got elements on the form of XPath expressions, which refer to nodesets located in other fragments in the same document. Is there a way to validate that the XPath expression actually evaluates to what I expect (e.g. expected element names)? I can easily write a script which does the job, but would be happy to solve the problem with XSD, XSL or another 'standard' tool.
0
1251
by: Hoi-Polloi | last post by:
Hi all I want to use an xpath query to get a set of xmlNodePtr , but I don't want to keep the xmlXPathObject around. See the function below. I want to: * make xpath query and get an xmlXPathObjectPtr back * get a pointer (np) to the XPathObjectPtr->nodesetval->nodeTab * free XPathObjectPtr * return the pointer np ... but I'm not sure if np is still valid
2
1487
by: bignass04 | last post by:
Hi all, I'm a newbie to XSLT working on my first project with it and I'm stuck on a particular thing. I want to create a document that will write the PCDATA from a given <Lineelement, then, in the next table cell, I want to insert the text within the element pointed to by the "xpath" attribute. <Line num="1" xpath="Income/Additions/CashFlow">Cash Flow for 2005</Line> <Line num="2" xpath="Additions/AddDeductions/Total">Total Deductions
2
1685
by: Yarik | last post by:
Hello, I am not sure the subject of my post adequately describes the problem I am trying to solve, so I think a specific example would be helpful. Let's say there are XML descriptions of products like this one: <!-- File: Products.xml --> ... <Product id="p1">
14
1566
by: eric.goforth | last post by:
Hello, Is there any way to directly access an element in a nodeset? For example, if working with: <blahs rec_count="16"> <blah> <yada>abc</yada> </blah>
4
3331
by: vaibhavp | last post by:
Hi, I am new to coding in Xslt and am stuck up on a problem for a very long time. I have to convert an xml file to html using xslt. I am using javax.xml.transform API for this. The xml file i have contains data in the following format <person> <name>PERSON_NAME</name> <addressXML> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10089
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9171
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5530
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.