Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
723 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...