4

I'm using the XmlDocument class like this:

divisionsDoc.SelectSingleNode(
    string.Format(@"Root/PoliticalDivisions/PoliticalDivision[upper-case(@Code)='{0}']", withCode.ToUpper()));

And this is resulting in the error:

Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.

I gather this is due to the upper-case XPath function, which I understand exists in XPath 2.0 and not 1.0 (from here, here, etc.)

MSDN doesn't specify the version of XPath it uses. I'm targeting .NET 4.5.1 -- wouldn't that be late enough to be using XPath 2.0? Or is that something that is defined elsewhere (outside of .NET)?

How can I find out what version of XPath is being targeted?

Please note, I'm aware of the work-around using translate('some text','abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ') -- that's not what I'm asking.

Community
  • 1
  • 1
rory.ap
  • 34,009
  • 10
  • 83
  • 174
  • 2
    As an aside, do you *need* to use XPath here? I'd personally just use LINQ to XML - no need to worry about whether `withCode` contains apostrophes, for example - but I appreciate you may have other requirements. – Jon Skeet Jun 19 '15 at 15:09
  • [Basic Querys Linq to XML](https://msdn.microsoft.com/en-us/library/bb943906.aspx) – MethodMan Jun 19 '15 at 15:13
  • No... Microsoft never implemented XPath 2.0 or Xslt 2.0. See for example http://stackoverflow.com/a/7521282/613130 of 2011. In one comment someone asked for an update in 2014... – xanatos Jun 19 '15 at 15:34

1 Answers1

15

Microsoft never implemented XPath 2.0 or Xslt 2.0... See for example this uservoice (aptly named Native support for XPath 2.0 or XSLT 2.0 in .NET) of 2013...

Last comment of March 2015 by one user:

i guess we will never see this as the world doesn't like XML anymore, it's all about JSON. Which is a shame as XML is still far better for a number of key scenarios than JSON.

xanatos
  • 109,618
  • 12
  • 197
  • 280