xml - XPath 2 / XSLT : Find sibling nodes of a set with matching values of child node -


i couldn't find question in particular answered anywhere, , i've been struggling it. i'd able select xpath nodes in set child node value exists node in set same child node value a, , pair them together.

for example, have xml document lists movies, 'imdb'. nodes here follow pattern:

<movie>   <title>pirates of carribbean: @ world's end</title>   <year>2007</year>   <directors>     <director>gore verbinski</director>   </directors>   <actors>     <actor>johnny depp</actor>      ......     </actors> </movie> 

in example i'd find movies feature johnny depp have come out in same year movie of same. in output i'm sorting years - so, every year has more 2 movies johnny depp, want output year along movies.

my xslt for-each select far looks this: <xsl:for-each select="/imdb/movie[contains(actors/actor/text(), 'johnny depp')][year = following-sibling::movie/year]">

but seems output every movie johnny depp has been in. doing wrong here?

for every year has more 2 movies johnny depp, want output year along movies.

that's

<xsl:for-each-group select="movie" group-by="year">   <xsl:variable name="depp-movies"                  select="current-group()[actors/actor='johnny depp']"/>   <xsl:if test="count($depp-movies) gt 2">     <year year="{current-grouping-key()}">       <xsl:copy-of select="current-group()"/>     </   </ </ 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -