#### Why does this XPath not work

This XPath works fine:
(starts-with(./name,'J'))]

But this XPath :

ends-with() is standard XPath but I get the error: Namespace manager
or XsltContext needed.

??? - thanks - dave

david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm

 0
thielen (152)
7/21/2008 3:45:04 AM
dotnet.xml 7266 articles. 0 followers.

4 Replies
771 Views

Similar Articles

[PageSpeed] 17

Same issue with matches()

On Sun, 20 Jul 2008 21:45:04 -0600, David Thielen
<thielen@nospam.nospam> wrote:

>This XPath works fine:
>(starts-with(./name,'J'))]
>
>But this XPath :
>
>ends-with() is standard XPath but I get the error: Namespace manager
>or XsltContext needed.
>
>??? - thanks - dave
>
>david@at-at-at@windward.dot.dot.net
>Windward Reports -- http://www.WindwardReports.com
>me -- http://dave.thielen.com
>
>Cubicle Wars - http://www.windwardreports.com/film.htm

david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm

 0
thielen (152)
7/21/2008 3:50:42 AM


#XPath 1.0 Functions
--------------------
>From: David Thielen <thielen@nospam.nospam>
>Subject: Re: Why does this XPath not work
>Date: Sun, 20 Jul 2008 21:50:42 -0600

>
>Same issue with matches()
>
>
>
>On Sun, 20 Jul 2008 21:45:04 -0600, David Thielen
><thielen@nospam.nospam> wrote:
>
>>This XPath works fine:
>>(starts-with(./name,'J'))]
>>
>>But this XPath :
>>
>>ends-with() is standard XPath but I get the error: Namespace manager
>>or XsltContext needed.
>>
>>??? - thanks - dave
>>
>>david@at-at-at@windward.dot.dot.net
>>Windward Reports -- http://www.WindwardReports.com
>>me -- http://dave.thielen.com
>>
>>Cubicle Wars - http://www.windwardreports.com/film.htm
>
>
>david@at-at-at@windward.dot.dot.net
>Windward Reports -- http://www.WindwardReports.com
>me -- http://dave.thielen.com
>
>Cubicle Wars - http://www.windwardreports.com/film.htm
>


 0
stcheng1 (64)
7/21/2008 4:28:57 AM
Hi Dave,

Regarding on the error "Namespace manager or XsltContext needed." you
encountered, it is due to the "ends-with" function is not a standard
function in XPATH 1.0.( it is in XPATH 2.0).  Currently, .net framework XML
components only implemented XPATH 1.0 and XSLT 1.0 function set, here is
the list of supported functions:

#XPath 1.0 Functions
http://www.edankert.com/xpathfunctions.html

#4.2 String Functions
http://www.w3.org/TR/xpath#section-String-Functions

for your scenario, you may use some other built-in functions to replace the
ends-with call or define some .net custom extension functions:

============use substring to detect end of string============
private void btnQuery_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();

string xpath =
"/root/customers/customer[substring(./name,string-length(./name),1)='e']";

XmlNodeList nodes = doc.SelectNodes(xpath);

if (nodes != null && nodes.Count > 0)
{
foreach (XmlNode node in nodes)
MessageBox.Show(node.OuterXml);
}
}
=============================

Sincerely,

Steven Cheng

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: David Thielen <thielen@nospam.nospam>
>Subject: Re: Why does this XPath not work
>Date: Sun, 20 Jul 2008 21:50:42 -0600

>
>Same issue with matches()
>
>
>
>On Sun, 20 Jul 2008 21:45:04 -0600, David Thielen
><thielen@nospam.nospam> wrote:
>
>>This XPath works fine:
>>(starts-with(./name,'J'))]
>>
>>But this XPath :
>>
>>ends-with() is standard XPath but I get the error: Namespace manager
>>or XsltContext needed.
>>
>>??? - thanks - dave
>>
>>david@at-at-at@windward.dot.dot.net
>>Windward Reports -- http://www.WindwardReports.com
>>me -- http://dave.thielen.com
>>
>>Cubicle Wars - http://www.windwardreports.com/film.htm
>
>
>david@at-at-at@windward.dot.dot.net
>Windward Reports -- http://www.WindwardReports.com
>me -- http://dave.thielen.com
>
>Cubicle Wars - http://www.windwardreports.com/film.htm
>


 0
stcheng1 (64)
7/21/2008 4:38:14 AM
OK - thanks

On Mon, 21 Jul 2008 04:38:14 GMT, stcheng@online.microsoft.com (Steven
Cheng [MSFT]) wrote:

>Hi Dave,
>
>Regarding on the error "Namespace manager or XsltContext needed." you
>encountered, it is due to the "ends-with" function is not a standard
>function in XPATH 1.0.( it is in XPATH 2.0).  Currently, .net framework XML
>components only implemented XPATH 1.0 and XSLT 1.0 function set, here is
>the list of supported functions:
>
>#XPath 1.0 Functions
>http://www.edankert.com/xpathfunctions.html
>
>#4.2 String Functions
>http://www.w3.org/TR/xpath#section-String-Functions
>
>for your scenario, you may use some other built-in functions to replace the
>ends-with call or define some .net custom extension functions:
>
>============use substring to detect end of string============
>private void btnQuery_Click(object sender, EventArgs e)
>        {
>            XmlDocument doc = new XmlDocument();
>
>
>            string xpath =
>"/root/customers/customer[substring(./name,string-length(./name),1)='e']";
>
>            XmlNodeList nodes = doc.SelectNodes(xpath);
>
>            if (nodes != null && nodes.Count > 0)
>            {
>                foreach (XmlNode node in nodes)
>                    MessageBox.Show(node.OuterXml);
>            }
>        }
>=============================
>
>Sincerely,
>
>Steven Cheng
>
>
>
>Delighting our customers is our #1 priority. We welcome your comments and
>suggestions about how we can improve the support we provide to you. Please
>feel free to let my manager know what you think of the level of service
>provided. You can send feedback directly to my manager at:
>msdnmg@microsoft.com.
>
>==================================================
>http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>ications.
>
>Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
>where an initial response from the community or a Microsoft Support
>up response may take approximately 2 business days as the support
>professional working with you may need further investigation to reach the
>most efficient resolution. The offering is not appropriate for situations
>that require urgent, real-time or phone-based interactions or complex
>project analysis and dump analysis issues. Issues of this nature are best
>handled working with a dedicated Microsoft Support Engineer by contacting
>Microsoft Customer Support Services (CSS) at
>http://msdn.microsoft.com/subscriptions/support/default.aspx.
>==================================================
>This posting is provided "AS IS" with no warranties, and confers no rights.
>
>--------------------
>>From: David Thielen <thielen@nospam.nospam>
>>Subject: Re: Why does this XPath not work
>>Date: Sun, 20 Jul 2008 21:50:42 -0600
>
>>
>>Same issue with matches()
>>
>>
>>
>>On Sun, 20 Jul 2008 21:45:04 -0600, David Thielen
>><thielen@nospam.nospam> wrote:
>>
>>>This XPath works fine:
>>>(starts-with(./name,'J'))]
>>>
>>>But this XPath :
>>>
>>>ends-with() is standard XPath but I get the error: Namespace manager
>>>or XsltContext needed.
>>>
>>>??? - thanks - dave
>>>
>>>david@at-at-at@windward.dot.dot.net
>>>Windward Reports -- http://www.WindwardReports.com
>>>me -- http://dave.thielen.com
>>>
>>>Cubicle Wars - http://www.windwardreports.com/film.htm
>>
>>
>>david@at-at-at@windward.dot.dot.net
>>Windward Reports -- http://www.WindwardReports.com
>>me -- http://dave.thielen.com
>>
>>Cubicle Wars - http://www.windwardreports.com/film.htm
>>

david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm

 0
thielen (152)
7/21/2008 3:55:07 PM

Similar Artilces:

Work Offline Problems
We just recently did a fresh 3.0 install on a SBS with SQL 2005. We have one laptop user that has had significant problems with using the Outlook laptop client. The biggest problem is that any data created in Outlook and linked to the CRM while offline is no longer linked to the CRM after going back online. Also, once an appointment linked to the CRM has passed (like trying to look at yesterday's appointments), the CRM link is no longer there. Any ideas? ...

Looking for a working production formula so I can add to staff?
I'm looking to justify addition to the staff I support. Is there a common formula that is used that include production standards and time worked? ...

Scheduled email doesn't work after upgrade
Hi, I was running Office 2000 on my Windows XP laptop. After buying and upgrading to Office XP, the email accounts were all good (could send and receive) but they do not automatically (scheduled) receive. I have to hit the send/receive icon or F9. I have gone to tools>options>mail setup> send/receive and selected the check box and set the time interval. I have even deleted an account and added it fresh. The group for send/receive lists 'All Accounts'. Very annoying...any thoughts (*i'm betting someone says to use regedit at some point). Jerry ...

importing into Excel from Works?
I've been sent a .wdb file that was made in MS Works. I can't open it in any program. Is there a way to import this into Excel, Word or Access, or something? I just need to get at the data; don't really care what format it's in. Thanks!!! Generally you would normally open the file in WORKS and then save it down as a file that Excel can read. .xlr is a native Excel format, or .txt, .csv, dbaseIV are all formats it can read. You can also find a converter here if you don't have WORKS. http://www.rl-software.com/indexjs.htm?/converter/wkscnvxls_e.htm Text from the...

XPath
Using XPath I am querying parts of XML document, " get quoted by \ - is it possible to specify not to quote " with \? <RootElement> <Element Attribute="SomeValue" /> </RootElement> XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); XmlNode xmlNode = xmlDoc.SelectSingleNode("//RootElement/Element") Print xmlNode.OuterXml <Element Attribute=\"SomeValue\"/> where I was expecting to get <Element Attribute="SomeValue"/> TIA Dennis wrote: > Using XPath I am querying parts of XML document,...

Working out time from days and hors worked
Hi Guys, I'm a novice to excel and am trying to make up a leave form. I have column for time leave started (in hours) the next column is the dat next column is time returned (in hours) then next column is dat returned. I also have set up a list of public holidays. I then have column to count the number of days taken as leave usin =networkdays(startday, endday, holidays). This is fine if people ar taking off whole days, but can anyone suggest how I can take int account people who will insist on taking half day leave (which is why have the hours columns)? Cheers Henr -- henr ----------...

Does Office 2007 work on Windows 7?
I just upgraded to Windows 7 and have Office 2007. Do Office 2007 products work on Windows 7 Operating System? Yes "Fetzer2" <Fetzer2@discussions.microsoft.com> wrote in message news:6962F239-77EF-4461-B59F-0DA98D427488@microsoft.com... >I just upgraded to Windows 7 and have Office 2007. Do Office 2007 products > work on Windows 7 Operating System? Do you really think Microsoft would release a new Operating System that would be incompatible with their best selling software ? "Fetzer2" <Fetzer2@discussions.microsoft.com> wrote in me...

chart error message / work sheet not open ?
I have a chart that I want to add a new series of data. I get an error message saying "Reference not valid. Renerence must be to an open worksheet" But the chart and the data are in the same workbook. I can go to any worksheet. Why won't it chart? Any suggestions? Ron How are you referencing the data? - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "Ron" <Ron@discussions.microsoft.com> wrote in message news:413D2762-D3BB-4795-A2C6-A71F4789005D@microsoft.com... &g...

Getting a specific parent of any node via xpath navigation

SHFileOperation not working
This is what I have for deleting the contents of a folder const wchar_t g_wsz_DriverBackupFolder[] = L"C:\\My Folder\\* \0\0\0\0"; { SHFILEOPSTRUCT info; memset(&info, 0, sizeof(info)); info.wFunc = FO_DELETE; info.fFlags = FOF_NOCONFIRMATION | FOF_SILENT; info.pFrom = g_wsz_DriverBackupFolder; if (0 != SHFileOperation(&info)) { DWORD dwError = GetLastError(); ... } } It fails and GetLastError is 6: "Invalid Handle". What the fuck is going on? Offhand, I don't see anything serious here. You have three more \0s than you actually ne...

XPath pb
Hi In infopath, I use a XPath expression to get some nodes : var oEMailNodeList = XDocument.DOM.selectNodes("//Message/EMail"); My problem is that this method returns 0 items. Here is the DOM.xml property : <?xml version="1.0" ?> <?mso-infoPathSolution productVersion=\"11.0.5329\" PIVersion=\"1.0.0.0\" href=\"file:///C:\Documents%20and%20Settings\t-stevbe\Local%20Settings\Appli cation%20Data\Microsoft\InfoPath\7ab6e8af39fc42e2\manifest.xsf\" solutionVersion=\"1.0.0.9\" initialView=\"messagesList\" ?> <?...

Work out of a number is between a range and display YES or NO
Why wont my formula work? =IF(AND(K90>1, K90<L90), "YES", "no") In K90 I have the formula: =IF(E90="","",IF($B$4="",TODAY()-E90,IF(E90>$B$4,"Other",$B$4-E90))) Which displays a number. In box L90 I have the formula: =(Master!L90) which displays from a different sheet a number. Hi Steve, It looks to me as if your formulae DO work - it's just that you're not getting the results you expect. What are the *values* in K90 and L90? I note that K90 can often have text, not numbers! As may 'Master!L90'. What do...

Spellcheck not working in Outlook 2000
works fine in Word, doesn't work in Outlook ...

Editing links to work when setting the desktop as a web page.
I am creating an html document to use as the desktop for our display laptops in my store so the customers can click on the the links on the desktop and be sent to their respective web pages. I've created the HTML file sucessfully and when I open it as a web page in explorer, it correctly directs me to the url I specified in the link. However, if I set it as the desktop, it doesn't open up IE. Is there a code that I'm leaving out that causes it to open up i.e. in order to send people to the website? I'm not finding it. thanks for the help. =) ...

Autofilter not working
Hi, When using AutoFilter in Excel (Data->Autofilter) the spreadsheet freezes and stops working. This occurs on both small and large spreadsheets. Any info on how to overcome this is appreciated. Ahmed ...

About to try my third install of CRM Server 1.2 because the sample app will not install. The docs say Installing and Configuring Microsoft CRM Create the OU for the Microsoft CRM organization 1. From AD01, on the Start menu, point to Programs, point to Administrative Tools, and then click Active Directory Users and Computers. 2. Right-click adventure-works.com, click New, and then click Organizational Unit. but in our Exchange server we have no adventure-works.com domain. Where/how does that get setup? Thanks, TimJowers Adventure-work...

Sheet codename not working
Hi, XP and Excel2003. What might be the reason why this is not working (Sheet2 is codename): Sheet2.Select I have tried all possibilities that I can imaging, but no. I have another file and selecting sheet with code name (Sheet4.Select) funtions just fine. Now using code: Workbooks.Open Filename:=Doc2 ActiveWorkbook.Sheet2.Select Opens Doc2 excel file just fine, but does not open the sheet. Thanks in advance MakeLei Use the index number instead. Activeworkbook.Sheets(2).select OR the sheetname itself Activeworkbook.Sheets("Sheetname").select ...

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.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 &qu...

hyperlinks within an incoming email do not work.
In an incoming email, when trying to access a hyperlink, it does not work. error msg is: "operation has been cancelled due to restrictions in effect on this computer" I tried looking at the security / firewall options, but they all seem to be ok. Hyperlinks work fine using webmail. Any ideas ? E "Ed-A" <Ed-A@discussions.microsoft.com> wrote in message news:4748C098-958B-454F-ACB7-619D56B44AC9@microsoft.com... > In an incoming email, when trying to access a hyperlink, it does not work. > error msg is: "operation has been cancelled due ...

XPath Validation
I'm looking for a way to Validate an XPath prior to executing the expression, without using a try catch clause. For example: I'm looking for something that would tell me that "\some/Xpath\to\Node" is invalid... Any Ideas? Hi, As far as I know, the .NET framework could not validate XPath directly with class library. The only thing we can do is to use try/catch block. Or you can try to find some 3rd-party tool such as XML spy to validate it. HTH. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." Thanks K...

Work Flow problem
Here is what I want, I have a custom picklist in my contact form. I would like for an email to be launched to a given user when a given item is selected from that picklist. So in other words, lets say I have a picklist on the contact form, called "status". When a user modifies this contact and changes the "status" picklist from null to "Prospect", it will send an email to their manager. Here is what I've done, I create a new rule under Contacts. The event I choose is "Change Status" (later I try Manual). And I place a wait condition: When contact s...

crm works really well
...

MS Money 2006: Why does the item dialog box sometimes not work?
I've got MS Money 2006 Premium. Most of the time when I'm entering purchases at places like Wal-Mart or Costco, I enter the total and then click the Split button to split the transaction. This brings up a dialog box in which I'll enter the individual items. As I enter them Money adds what's already been entered into this dialog box, and subtracts the total from the amount that I enter into the amount field in the check form. Except, all by itself, for reasons which are not at all apparent to me, MS Money will decided that rather than subtract the running sum from the ...

Write off Documents not working
I have a bunch of account balances with .01 cent on them. When I go into Write off Documents under Tools | Sales and put in the info, then press preview I get a message saying " " no documents matching that criteria were found. " I have checked set up and I have posting accounts for write offs. Any help would be appreciated. Thank you! Jeremy Jeremy, Make sure that the customers have write offs allowed. -- Victoria Yudin Dynamics GP MVP <Jeremy> wrote in message news:uL%23efyl8GHA.940@TK2MSFTNGP03.phx.gbl... >I have a bunch of account balances with ....

Multiple IF statement not working
I have numbers in cells b2, d2,e2, and f2. I am trying to write statment that will increment number in cell b2 by one for each cell (d2, e2, f2) that is greater than or equal to one. The following formula will not work if more than one cell (d2, e2, f2) has a zero in it: =IF(AND(D2>=1,E2>=1,F2>=1),B2+3,IF(OR(D2=0,E2=0,F2=0),B2+2,IF(AND (D2=0,E2=0),B2+1,IF(AND(D2=0,F2=0),B2+1,IF(AND(E2=0,F2=0),B2+1,))))) Does anyone know why? Try this =B2+COUNTIF(D2:F2,">=1") -- Wag more, bark less "Anthony" wrote: > I have numbers in cells b2, d...