![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: XPath LT & GT: problems when comparing strings! [Thread Next] Re: XPath LT & GT: problems when comparing strings!To: NULL Date: 9/6/2006 1:19:00 AM
Martin Honnen =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=B2:
> Dmitry Bond. wrote:
>
> > Something strage happens when I try to compare a string value (value of
> > XML attribute) with ">", "<" or ">=3D", "<=3D" operators. Looks like on=
ly
> > "=3D" works for strings comparison in MSXML. :-(
>
> With MSXML there is an extension function provided for string comparison =
e=2Eg.
[=2E..]
> xmlDocument.setProperty('SelectionNamespaces',
> 'xmlns:ms=3D"urn:schemas-microsoft-com:xslt"');
Thank you very much. It works fine in JScript.
But what should I do to use the same approach in .NET ?
The code below reports an "XsltContext is needed for this query because
of an unknown function" error.
=3D=3D=3DC# code sample:begin=3D=3D=3D
XmlDocument xmlDoc =3D new XmlDocument();
XmlTextReader reader =3D new XmlTextReader(File.OpenRead("order.xml"));
xmlDoc.Load(reader);
XmlNamespaceManager namespaceManager =3D new
XmlNamespaceManager(xmlDoc.NameTable);
namespaceManager.AddNamespace("ms", "urn:schemas-microsoft-com:xslt");
XmlNodeList resultNodes =3D xmlDoc.SelectNodes("//Order [
ms:string-compare(@Location, 'M') >=3D 0 ]", namespaceManager);
MessageBox.Show(resultNodes.Count.ToString() + " nodes selected.");
=3D=3D=3DC# sample code:end=3D=3D=3D
I have read Q324899 article on microsoft.com but it describes custom
functions whereas "ms:string-compare" should be available by default (I
hope, just by specifying "ms:urn:schemas-microsoft-com:xslt" namespace
in XmlNamespaceManager).
Or maybe XML in .NET does not support such namespace / function ?...
If not - what should I do in .NET? Implement it as custom function like
described in Q324899?=20
WBR,
Dmitry.
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
