Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XSL Pattern vs. XPath

20 views
Skip to first unread message

Richard M. Hartman

unread,
Nov 16, 2009, 5:10:37 PM11/16/09
to

Trying to figure out selectSingleNode(). The query syntax can be either
"XPath" or "XSL Pattern". Not finding any good comparisons of the two
syntaxes. What I really want to know is if you can do a case-insensitive
search with selectSingleNode() ... so far it seems to be case sensitive.


--
-Richard M. Hartman

186,000 mi/sec: not just a good idea, it's the LAW!


Martin Honnen

unread,
Nov 17, 2009, 6:15:10 AM11/17/09
to
Richard M. Hartman wrote:
> Trying to figure out selectSingleNode(). The query syntax can be either
> "XPath" or "XSL Pattern". Not finding any good comparisons of the two
> syntaxes. What I really want to know is if you can do a case-insensitive
> search with selectSingleNode() ... so far it seems to be case sensitive.

XPath 1.0 is a W3C standard since 1999, consider to use that. It is the
only option available with MSXML 4, 5, 6 anyway.
Only MSXML 3 supports both XPath and XSL pattern but I don't think
Microsoft has any documentation of that XSL pattern language which was
implemented before XPath became a standard in 1999.

As for case-insensitive search, element and attribute names in XML are
case sensitive, so XPath is too when it comes to element and attribute
names. If you want to compare string values in a case insensitive manner
then the extension function ms:string-compare
http://msdn.microsoft.com/en-us/library/ms256114.aspx
has an option to do that. It should be supported in MSXML 6:

var doc = new ActiveXObject('Msxml2.DOMDocument.6.0');
doc.loadXML('<root><foo>bar</foo><foo>BAR</foo><foo>baz</foo></root>');
doc.setProperty('SelectionLanguage', 'XPath');
doc.setProperty('SelectionNamespaces',
'xmlns:ms="urn:schemas-microsoft-com:xslt"');
doc.selectNodes('root/foo[ms:string-compare(., "bar", "", "i") = 0]').length


--

Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/

0 new messages