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

Home Posts Topics Members FAQ

IXsltContextFun ction args seemingly passed wrong during Invoke

I have a user-defined XPath function implemented using a custom
context and the IXsltContextFun ction interface. For its arguments, it
accepts 3: { XPathResultType .Any, XPathResultType .Any,
XPathResultType .String }. The function is called datediff, which
converts the arguments to DateTimes, and gives args[0] - args[1] in
the units specified by args[2] (e.g., "days", "months"). Anyhow, as
an example, Let's say I have the following XML file:

<root>
<testnode DateVal="2008-12-05T00:00:00" TestName="Whate ver" />
</root>

And I execute the expression: ' /root/
testnode[datediff("2008-12-25T00:00:00",@D ateVal,"days") < 365]/
@TestName'
which should return the TestName attribute of any nodes whose DateVals
are within a year of 12/25/2008, give or take (for arguments sake,
let's just assume the function returns 0 if args[1] args[0]).

The issue is that when the XPath function (datediff) Invoke is
called, and I watch the args[] array, the second argument (@DateVal),
is an XPathNodeIterat or with one XPathNavigator (as it should be),
but:

The XPathNavigator is the testnode element not the DateVal attribute.
Is this the expected behavior? Why is an element node being passed in
as the argument, when, from the XPathExpression above, it's clearly
the attribute node that's being passed as an argument to the function?

By the way, I realize that I can pass "string(@EndDat e)" as the second
argument, which works fine, but a function I'm building now that
returns a set representing a cross-product of node sets will need the
ability to traverse through attribute nodes.
Dec 5 '07 #1
1 2075
That's really weird. I'd like to hear the answer too.
Btw, can you provide minimal repro?

--
Oleg

jakebbohio wrote:
I have a user-defined XPath function implemented using a custom
context and the IXsltContextFun ction interface. For its arguments, it
accepts 3: { XPathResultType .Any, XPathResultType .Any,
XPathResultType .String }. The function is called datediff, which
converts the arguments to DateTimes, and gives args[0] - args[1] in
the units specified by args[2] (e.g., "days", "months"). Anyhow, as
an example, Let's say I have the following XML file:

<root>
<testnode DateVal="2008-12-05T00:00:00" TestName="Whate ver" />
</root>

And I execute the expression: ' /root/
testnode[datediff("2008-12-25T00:00:00",@D ateVal,"days") < 365]/
@TestName'
which should return the TestName attribute of any nodes whose DateVals
are within a year of 12/25/2008, give or take (for arguments sake,
let's just assume the function returns 0 if args[1] args[0]).

The issue is that when the XPath function (datediff) Invoke is
called, and I watch the args[] array, the second argument (@DateVal),
is an XPathNodeIterat or with one XPathNavigator (as it should be),
but:

The XPathNavigator is the testnode element not the DateVal attribute.
Is this the expected behavior? Why is an element node being passed in
as the argument, when, from the XPathExpression above, it's clearly
the attribute node that's being passed as an argument to the function?

By the way, I realize that I can pass "string(@EndDat e)" as the second
argument, which works fine, but a function I'm building now that
returns a set representing a cross-product of node sets will need the
ability to traverse through attribute nodes.
Dec 6 '07 #2

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

Similar topics

2
2748
by: Pierre Fortin | last post by:
This quest for understanding started very innocently... A simple error on my part, passing on args as "args" instead of "*args" to os.path.join() led me to wonder why an error wasn't raised... def foo(*args): ... return os.path.join(*args) foo('a','b') # returns 'a/b'
1
1623
by: Colin Savage | last post by:
When creating a function in xpath with IXsltContextFunction, if the return type is nodeset, what do you actually return from the Invoke function? A XmlNodeList? XPathNodeIterator? public System.Xml.XPath.XPathResultType ReturnType {get{ return System.Xml.XPath.XPathResultType.NodeSet; }}
6
2939
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd have better luck here. So here goes! My program ignores any command line arguments, or at least it's supposed to. However, when I pass any command line arguments to the program, the behaviour of one of the functions changes mysteriously. I have...
33
5960
by: Kenneth Brody | last post by:
I know that passing printf() too few arguments, or arguments of the wrong type invokes UB. However, what about passing too many arguments, if the expected arguments are of the correct type? For example: char format1 = "foo %s bar %s baz %d"; char format2 = "foo %s bar %s no baz here"; char *strvar1 = "one", *strvar2 = "two";
2
1976
by: Tom Dacon | last post by:
I'm raising an event in a component, using ISynchronizeInvoke.Invoke, and my event args object contains a string as one of its members. If the string is longer than 63 bytes, the Invoke call pulls an unhandled exception in System.Windows.Forms.dll, to the effect that the string length must be less than 64. If I trim the string to 31 characters (62 bytes) everything's fine and the event goes as intended. But if the string length is 32 or...
1
1677
by: swartzbill2000 | last post by:
Hello, I wish to use Control.Invoke to make an inter-thread call to a sub that has ByRef args. How can I pass the ByRef args? Syntax like New Object() {byRefArg1, byRefArg2} in fact passes by value. Bill
42
3470
by: Holger | last post by:
Hi guys Tried searching for a solution to this, but the error message is so generic, that I could not get any meaningfull results. Anyways - errormessage: ---------------------------------------------------- TypeError: addFile() takes exactly 1 argument (2 given) ----------------------------------------------------
4
3218
by: Nathan Baker | last post by:
I have a JavaScript environment using IActiveScript and friends (via COM interop). At one point, the JavaScript passes me a function as a parameter to an object that has been inserted into the JavaScript using AddNamedItem. When I look at this object and ask it for its type, it says it is a System.__ComObject. What I want to do is invoke this function in the environment that I have using the engine I have instantiated. Is there a way to...
7
5433
by: codefragment | last post by:
Hi I want to use reflection to call a method which accepts "params string" as an argument I've searched this group and found a better idea than invoke, just cast to an interface and then call the method directly, but I would still like to know if this is possible, e.g. something like the below ta
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...
1
10341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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
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?
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.