![]() If you used the nearest-equivalent FLWOR expression, for $s in $doc//section return $s//para, then a that appears in several nested sections would appear several times in the output, and the order of elements in the output won't necessarily be the same as their order in the original document. For example, the expression $doc//section//para will return each qualifying element exactly once, even if it appears in several nested elements. When a path expression selects nodes, they're always returned in document order, with duplicates removed.In the earlier example //video/count(actorRef) the expression on the right returned a number - that's a new feature in XPath 2.0 - but the left-hand expression must still return nodes. With the "/" operator, the expression on the left must always select nodes rather than atomic values.root()//video, so the reference to the context item is implicit. The for expression defines a variable $v that's used in the return clause to refer to each successive item in the input sequence, while a path expression instead uses the notion of a context item, which you can refer to as ".There are three main differences between the constructs: The FLWOR expression and the "/" operator in fact perform quite similar roles: they apply a calculation to every item in a sequence and return the sequence containing the results of these calculations. Two actors are listed twice because they appear in more than one video. ![]() ![]() The reason is that path expressions eliminate duplicates, and FLWOR expressions don't. Try them both in Stylus Studio: the FLWOR expression produces a list containing 38 actors, while the path expression produces only 36. This time the two expressions aren't precisely equivalent.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |