• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with ....

 
Nancy King
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
I am learning xPath and have difficulty in understand the explaination of "/descentant::sku[not(.=preceding::sku)]". The explaination in the book is: "Identifies the descendant sku elements with string-values that do not equal those of one of the preceding sku elements. This expression only identifies the first sku with the same value are excluded from the result node-set."
From my understanding, "." in the predicates refers to current node. But the explaination seems refer "." as the descendant sku element. What should "." refer to?
Why This expression only identifies the firstsku with the same value are excluded from the result node-set.
Your help is highly appreciated.
Thanks,
Nancy
 
Naichen Liu
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"/descentant::sku[not(.=preceding::sku)]".
I believe "/descentant::sku" will return back a node-set of sku, the conditiion [not(.=preceding::sku)] will be applied to each node in the set, then "." means each sku node being tested.
Any comments?
 
Karthik Jayaraman
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right niachen.
This is how it goes.
Remember the CONTEXT funda.
when you say /descendant::sku, the context gets changed to the element sku. Now the predicate part. This sku (.) should not be equal to the previous (Note preceding:: means previous sibling) sku element.
 
Karthik Jayaraman
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As mentioned above you will get a list of sku elements with unique (string)value.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic