Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between XSL Pattern and XPath in syntax?

Tags:

xslt

xpath

I'm updating codes to use MSXML6.0 from MSXML3.0. However, I noticed that, for MSXML3.0, the default "SelectionLanguage" is "XSL Pattern", while MSXML6.0 only support XPath. I have concerns that this change would introduce differences in the query syntax.

Can somebody list the difference of syntax between these two syntax?

like image 223
RogerCui Avatar asked Jan 20 '10 08:01

RogerCui


1 Answers

The one thing that has tripped me up is selecting the first node in a node set. For example, we'd been using MSXML 3.0 (which uses XSLPattern) and has queries like this:

/root/book[0]

This query was supposed to select the first book. This works with XSLPattern. But with XPath, this is correct:

/root/book[1]

So when I switched us to using MSXML 6.0, which uses correct XPath, all those queries with "[0]" stopped working.

Update: I just found this link that talks some more about XSLPattern and XPath:

MSDN Magazine: MSXML 3.0 Supports XPath 1.0, XSLT 1.0, XDR, and SAX2

http://msdn.microsoft.com/en-us/magazine/cc302348.aspx

Update #2:

Here's the W3C Spec on XSLT which includes XSL Patterns:

http://www.w3.org/TR/1998/WD-xsl-19981216.html#AEN376

Update #3

Here's another post that describes the same thing I mentioned above:

http://www.eggheadcafe.com/software/aspnet/29579789/xml-parsing.aspx

like image 134
Tom Winter Avatar answered Oct 06 '22 10:10

Tom Winter