Custom xpath function, ResolveFunction called but not Invoke...

Hi...

We have an XsltContext object on our code to support some custom functions.  
I just went to add one and oddly I find XsltContext.ResolveFunction() is 
being called but Invoke() isn't.

ResolveFunction returns
return new XPathExtensionFunction(name, 2, 4, new XPathResultType[] { 
XPathResultType.String, XPathResultType.String, XPathResultType.String, 
XPathResultType.Boolean }, XPathResultType.Boolean);

where class XPathExtensionFunction : IXsltContextFunction.

From what's returned, I see that the ReturnType property is called a couple 
times but it's never followed up with an Invoke() and I haven't figured out 
why.

We have other functions in the same object that are getting invoked, but for 
some reason this new one never quite gets there.  No exceptions are thrown.

XPathUtil Ctx = new XPathUtil(new XmlNamespaceManager(confDoc.NameTable));
Ctx.AddNamespace("ptx", "urn:prospero.xpath");  // and our special helpers

confSection = confDoc.DocumentElement.SelectSingleNode(
"/configuration/types[@name=/choices/choice[ptx:myfunc(string(@appliesTo), 
string('myType'))]/@type]", Ctx);

Is how I'm trying to invoke it.

Any ideas?

Thanks
Mark

0
mmodrall1 (25)
9/30/2009 5:56:01 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
1606 Views

Similar Articles

[PageSpeed] 13

Mark wrote:
> Hi...
> 
> We have an XsltContext object on our code to support some custom functions.  
> I just went to add one and oddly I find XsltContext.ResolveFunction() is 
> being called but Invoke() isn't.
> 
> ResolveFunction returns
> return new XPathExtensionFunction(name, 2, 4, new XPathResultType[] { 
> XPathResultType.String, XPathResultType.String, XPathResultType.String, 
> XPathResultType.Boolean }, XPathResultType.Boolean);
> 
> where class XPathExtensionFunction : IXsltContextFunction.
> 
> From what's returned, I see that the ReturnType property is called a couple 
> times but it's never followed up with an Invoke() and I haven't figured out 
> why.
> 
> We have other functions in the same object that are getting invoked, but for 
> some reason this new one never quite gets there.  No exceptions are thrown.
> 
> XPathUtil Ctx = new XPathUtil(new XmlNamespaceManager(confDoc.NameTable));
> Ctx.AddNamespace("ptx", "urn:prospero.xpath");  // and our special helpers
> 
> confSection = confDoc.DocumentElement.SelectSingleNode(
> "/configuration/types[@name=/choices/choice[ptx:myfunc(string(@appliesTo), 
> string('myType'))]/@type]", Ctx);
> 
> Is how I'm trying to invoke it.

Consider to post a minimal but complete code sample that allows us to 
reproduce the problem.
The only odd thing I see is your XPath, you have two absolute paths:
   /configuration/types
and then inside the predicate
   /choices/choice
If you use XmlDocument then there is only one root node and one root 
element meaning you can either have
   /configuration
select an element or
   /choices
select an element in the same document but not both in the same document.


-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/
0
mahotrash (1777)
9/30/2009 6:07:47 PM
Thanks Martin...

As you noted, it was the bad pathing on the argument to the function; when I 
add /configuration to /choices/... it works.

so
1) the original invocation wouldn't have found anything and would have 
returned null.

2) ResolveFunction was probably called in the parsing of the expression but 
not invoked because there was no nodelist to work on to start with...

Mark


"Martin Honnen" wrote:

> Mark wrote:
> > Hi...
> > 
> > We have an XsltContext object on our code to support some custom functions.  
> > I just went to add one and oddly I find XsltContext.ResolveFunction() is 
> > being called but Invoke() isn't.
> > 
> > ResolveFunction returns
> > return new XPathExtensionFunction(name, 2, 4, new XPathResultType[] { 
> > XPathResultType.String, XPathResultType.String, XPathResultType.String, 
> > XPathResultType.Boolean }, XPathResultType.Boolean);
> > 
> > where class XPathExtensionFunction : IXsltContextFunction.
> > 
> > From what's returned, I see that the ReturnType property is called a couple 
> > times but it's never followed up with an Invoke() and I haven't figured out 
> > why.
> > 
> > We have other functions in the same object that are getting invoked, but for 
> > some reason this new one never quite gets there.  No exceptions are thrown.
> > 
> > XPathUtil Ctx = new XPathUtil(new XmlNamespaceManager(confDoc.NameTable));
> > Ctx.AddNamespace("ptx", "urn:prospero.xpath");  // and our special helpers
> > 
> > confSection = confDoc.DocumentElement.SelectSingleNode(
> > "/configuration/types[@name=/choices/choice[ptx:myfunc(string(@appliesTo), 
> > string('myType'))]/@type]", Ctx);
> > 
> > Is how I'm trying to invoke it.
> 
> Consider to post a minimal but complete code sample that allows us to 
> reproduce the problem.
> The only odd thing I see is your XPath, you have two absolute paths:
>    /configuration/types
> and then inside the predicate
>    /choices/choice
> If you use XmlDocument then there is only one root node and one root 
> element meaning you can either have
>    /configuration
> select an element or
>    /choices
> select an element in the same document but not both in the same document.
> 
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://msmvps.com/blogs/martin_honnen/
> 
0
mmodrall1 (25)
9/30/2009 7:15:01 PM
Reply:

Similar Artilces:

Calling function pointers
Hello all, I was looking at the Dynamic Array functions exported by commctl32.dll (prefixed DPA_ and DSA_) http://msdn.microsoft.com/en-us/library/ff485930%28VS.85%29.aspx Although there doesn't seem to be anything there that really couldn't be achieved in VB, I was still slightly disappointed that some of the more interesting functions (DPA_Merge for example) are exported by ordinal only. I'm assuming that this means those ones aren't callable from straight VB. Robert As far as I know, we can call API using ordinal number. Example: Private Declare Fun...

New so-called features in Outlook 2002 -- can they be defeated?
Hello all. Our office recently got "upgraded" to Outlook 2002. It has a couple of so-called "features" which I find incredibly annoying and impossible to defeat. I'd be interested if anyone has found a way, other than the ridiculous workarounds listed on Microsoft's website. The two features which annoy me most are: Displaying both the name and the email address in email message headers; Displaying two entries in the "Select Names" dialog box for everyone who has both a fax and an email address, that is, virtually everybody. If anyone can te...

Customize Products HTML Custom Field?
I'm looking for a way to add a formatted description to my products. I'm thinking of using an html doc per each Product. I will then be able to dynamically update my web site and create catalogs on the fly using Quark. I've noticed that the contol in the Email Activity might be useful. Another issue I've encountered is that I'm only able to add simple custom fields to a form (string, number, pick list etc.) through the Schema Manager. Any suggestions on how I should go about this would be greatly appreciated. []P. []V[]. ...

customizing charts
I am trying to customize a vertical bar chart, where the x axis is the areas being measured and the y axis is the units of measurement. I have been trying to shade a particular range within the overall plot area, not the entire area. Specifically, the y axis range goes from 40 all the way to 160. I just want to shade or fill in a specific range (85 to 115) within that overall range. Is there a way to have that range (85-115) shaded only and the other ranges (116 and higher, and 84 and lower) left untouched? Any help would be appreciated. Thanks! Hi, The technique describe here w...

Custom Tailoring An Access Report to fit an Existing Form Fed Printer Receipt Fo
I work for a State Correctional Facility as the Mailroom Supervisor and Computer Help Desk Representative. While Inmate receipts are still being written by hand there is a Stand-Alone- Computer Receipt System, consisting of a Stand-Alone-Computer, Okaidata 321 Impact Printer, 3 color part copy form fed preprinted/number receipt form, and Lotus Approach Software, that generates Inmate receipts. The flaw with the Stand-Alone-Computer is that when it is used each following day the following days receipt information is lost instead of being captured in a database. I am in the proces...

specific rank in column value
Hi I have a column of names, with a column of values next to it that corresponds. The column is about 100 values long. I want a table that says Highest Value / name 2nd Highest Value / name 3rd Highest Value / name 3rd Lowest Value / name 2nd Lowest Value / name Lowest Value / name I don't want to use the rank function because i don't want a seperate column next to my data with its ranks, also because the column is always being added to I just want a function that does "look in column B, find rank x, return name from column a", that ignores blank values. Thanks! Hannah ...

FUNCTION problem, Please Advise
I have "IF" formula... =IF(C67=G69;M4;0) c69 - number. m4 result if c67=c69 0 if not. When I'm copying that formula (dragging with mouse.. autopaste) I'm getting autochanging in formula =IF(C68=G70;M5;0) ,, =IF(C69=G71;M6;0) a problem is I dont wanna that G69 will change, so it will be in all others functions. How can I do it? Hi =IF(C$67=G69;M4;0) Arvi Laanemets "Nison Maksumov" <maksumov@hotmail.com> wrote in message news:uoCprFxVDHA.452@TK2MSFTNGP10.phx.gbl... > I have "IF" formula... > > =IF(C67=G69;M4;0) > > c69...

Custome Label sizing
I am using Publisher 2002 SP3 I have a custom label made in Publisher 98 which does not print properly. I have A4 as default paper size. Page information is: 3 across 10 down Side 0.47cm Top 0.8cm Horizontal 0.31 \Vertical 0.0cm Page size 6.67 x 2.54 I need this to be 7.0 x 2.5 but it is grayed out. How can I change that? Thanks, Robin Chapple What are the dimensions of your labels? -- JoAnn Paules MVP Microsoft [Publisher] "Robin Chapple" <robinski@ANTI_SPAMmelbpc.org.au> wrote in message news:5c4n311f9tdkkqqk0ndg1l1r3irp3rlfpb@4ax.com... >I am using Publis...

Function relating to merged cells #2
Thanks for that Ji -- Chise ----------------------------------------------------------------------- Chisel's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=935 View this thread: http://www.excelforum.com/showthread.php?threadid=26677 ...

Econnect Custom Requesters
One of my developers created an econnect custom requester for an application. The application is moving from development to production. How can I move the custom requester? ...

Looking for a specific Excel function/formula
Hello-I am looking for the function/formula that will give me th following data: Cell D4 has a numerical figure-it is a percent I want cell D6 to show the following: If Cell D4 is 30% or less, then D6 shows 0 If Cell D4 is >=31% but <=35%, D6 must show 15% (or .15) If Cell D4 is >=36% but <=41%, D6 must show 25% (or.25) If Cell D4 is =>42%, D6 shows 3% (or .30) Thank You Pete -- Message posted from http://www.ExcelForum.com Peter =IF(D4<=30%,0,IF(D4<=35%,15%,IF(D4<=41%,25%,30%))) Regards Trevor "petern >" <<petern.15hpf1@excelforum-nospam.co...

Screen size is too small when customizing
For some reason, when I try to edit the Account form and customize it, I can't get the entire form to fit on my screen. If I resize the window, it still cuts off the bottom part and there is no scroll bar available to scroll down. I'm runnning a laptop with Win XP with resolution set at 1024x768. Any ideas? Never mind. I did a ctrl+N and got a scroll bar. "James" wrote: > For some reason, when I try to edit the Account form and customize it, I > can't get the entire form to fit on my screen. > > If I resize the window, it still cuts off the bottom...

Customizing Excel toolbar to add Median function
Is there a way to add the Median function to an Excel toolbar? All I've been able to add is the Insert Function which takes me to all functions -- I would like a button that I could click that would take me automatically to only the Median function. Thank you. -- ksham ------------------------------------------------------------------------ ksham's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=16681 View this thread: http://www.excelforum.com/showthread.php?threadid=318931 ...

Is there a way to control the height of a row via an excel function?
I'm trying to control the height of a row determined by the contents o a cell... I can't seem to find a function or command that is available to me t allow this. Alternatively, is there a way that I can 'hide' or 'unhide' a row base on a cell's contents? Best to you! Larry Seye -- Message posted from http://www.ExcelForum.com The only way I know of controling the height of a row is by using the Format/Row/Autofit, it might be possible uing VBA, try posting the question under programing see what answer you get. However, for the second part of your questio...

Customizing RMS customer statements
Does anyone know how to add verbage to the customer statements? ie. I want to note what our finance charge policy is on the bottom of the customer statements. In our Store Misc Utility we have many features one of which is enhancement to A/R Statement that allows you to configure different Duning notices for customer that have balanace over 30, 60, 90 etc... As well as allowing you to soft configure and type hearder and footer messages. If you want to know more contact me. Afshin Alikhani - [afshin@retailrealm.co.uk] CEO - Retail Realm -- URL http://www.retailrealm.co.uk "jord...

Cannot customize Outlook today #2
I have outlook 2000 on some XP pro machines and when they click on customize outlook today nothing happens ...

"Error" ODBC Call Failed
After I converted an Access97 Database to Access2K, some of the queries opened with no problems, some others gave me an error message "ODBC-- Call Failed [Microsoft][ODBC Visual FoxProDriver]Index does not accept Null (#886)" The database has Visual FoxPro link tables for which I used ODBC to link them. Please Help. Thanks a million. Check out the KB article at http://support.microsoft.com/default.aspx?scid=kb;EN-US;225861 Try relinking the tables as described. You should use a file DSN as well when building the link. -- Bill Ramos Lead Program Manager, Microsoft Office Acce...

SUMIF function
Hi, please help... I am trying to total up commission figures in a column that match a specific year. Each row contains a cell for the date it was entered, the customer details and commission earnt. I have used the SUMIF funtion so far but cannot find the correct criteria for it to identify the year in the date cell and include the commission in the SUM if the year matches the criteria. The formula I have used so far is: =SUMIF(Websites!B5:B31,F2,Websites!R5:R31). F2 refers to a cell with the current year automatically entered by using the TEXT function: =TEXT(TODAY(),"yyyy"...

customizing a field in customer maintenance screen
I have a field already on the customer maintenance screen that is a user defined field with a data type of string, but this field only allows 20 characters. This field is not long enough and I can't seem to figure out how to allow more characters. So, I created a new string field and added it into the customer maintenance screen. I can see the field and type text into the field but after I save it and go back in, the text is no longer there. I think I need to link this field to the table in some way but I'm not sure how to go about doing that or even what table to link it to...

Customizing and changing the default country in Contacts template?
When entering telephone or address information in Contacts in Outlook 2007, the 'Country' field defaults to 'United States'. Can this default setting be made a user option to customize and change to another country. For users outside of the US, it is tedious to continually have to override it. Outlook will use whatever you have set as the location for your operating system. -- Russ Valentine "djwallac" <djwallac@discussions.microsoft.com> wrote in message news:6B0C1448-EFB4-483D-BE9A-11F9723312F4@microsoft.com... > When entering telephone or ...

Office2007 Custom UI Editor and our Addins-How to show our Addin t
Need to know how to show our add-in tab when using the Office2007 Custom UI Editor. We know how to make the built-in tabs visible but not how to show our add-in's tab. Your addin will be on the addins tab. Other than that, you need to build a custom group or tab. -- __________________________________ HTH Bob "MB34" <MB34@discussions.microsoft.com> wrote in message news:63E2A7EA-6D7D-42FF-9937-F87476589DCF@microsoft.com... > Need to know how to show our add-in tab when using the Office2007 Custom > UI > Editor. > > We know how to make the built-in t...

Possibly an IF function?
this is a 2 part questionI have a list of 11 items in a drop down menu in column A that when selected I need to have a corresponding value appear in column B, C and D. I think I can only do 7 nestings and would like to do all 11, plus have the ability to register a 0 for anything not in the formula. For example: Column A B C D E Auto Single 10 1 0 Auto Multi 15 1 0 Life 0 0 1 $163 The 2nd part ...

Customize autoformat?
Is it possible to customize autoformat? I frequently used "LIST1" but want to change the default color. There's no way to change the items in the AutoFormat list. You could use a macro to change the colours after they've been applied. crapit wrote: > Is it possible to customize autoformat? I frequently used "LIST1" but want > to change the default color. > > -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html ...

@which function to use when
Sir, I have a row in excel with cells containing 88.23, 89.01, 72.39, 54.52 and I want to know which fuction/formula to use for making these as 88.25, 89.00, 72.40, 54.50. Please help. Thanks. On Sat, 9 Jan 2010 01:43:23 +0530, "Sandeep Lohchab" <sandeeplohchab@yahoo.com> wrote: >Sir, I have a row in excel with cells containing 88.23, 89.01, 72.39, >54.52 and I want to know which fuction/formula to use for making these as >88.25, 89.00, 72.40, 54.50. Please help. Thanks. > Try this formula: =MROUND(A1,0.05) Hope this helps / Lars-...

If function with color or bold face
Supposing I want to give a formula that if a particular cell is > 40, =if(c4>40) 1) make the color green else let it remain as it is 2) Highlight it in bold face in black itself else let it remain as it is Kindly let me have the answers for both 1) and 2). Thanks in advance Regards sh -- LEARNING MS OFFICE THOROUGHLLY Why not use conditional format Format/Conditional Format Larry -- keithl816 ------------------------------------------------------------------------ keithl816's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=21287 View this thread: ...