I have an XML file that shows a list of movies. Each movie has some metadata to describe the plot, actors, directors, etc. This is the example structure:
<movies>
<movie>
<title>The Shawshank Redemption</title>
<year>1994</year>
<rated>R</rated>
<released>1994 Oct 14</released>
<runtime>142 min</runtime>
<genres>
<genre>Crime</genre>
<genre>Drama</genre>
</genres>
<directors>
<director>Name Surname</director>
</directors>
<writers>
<writer>Stephen King (short story 'Rita Hayworth and Shawshank Redemption')</writer>
<writer>Frank Darabont (screenplay)</writer>
</writers>
<actors>
<actor>Tim Robbins</actor>
<actor>Morgan Freeman</actor>
<actor>Bob Gunton</actor>
<actor>William Sadler</actor>
</actors>
<plot>Two imprisoned men bond over a number of years, finding solace and eventual redemption through acts of common decency.</plot>
<languages>
<language>English</language>
</languages>
<countries>
<country>USA</country>
</countries>
<awards>Nominated for 7 Oscars. Another 16 wins and 16 nominations.</awards>
<poster>http://ia.media-imdb.com/images/M/MV5BODU4MjU4NjIwNl5BMl5BanBnXkFtZTgwMDU2MjEyMDE@._V1_SX300.jpg</poster>
<metascore>80</metascore>
<imdbRating>9.3</imdbRating>
<imdbVotes>1358212</imdbVotes>
<imdbID>tt0111161</imdbID>
<type>movie</type>
</movie>
<movie>
...
</movie>
<movie>
...
</movie>
...
</movies>
I have to create an XSL stylesheet to transform this file in a graphml file that shows the actors relations with the movies, where nodes are the movies and the edges between two nodes exists if an actor appears in the movies (nodes) connected. Here an example:
<key id="actors" for="edge" attr.name="actors" attr.type="int">
<default>1</default>
</key>
<graph id="movies" edgedefault="undirected">
<node id="movie title 1"/>
<node id="movie title 2"/>
<node id="movie title 3"/>
...
<edge source="movie title 1" target="movie title 2">
<data key="actors">2</data> (number of actors who appear in both "movie title 1" and "movie title 2")
</edge>
This is a fragment of XSL to list the nodes:
<xsl:for-each-group select="/movies/movie" group-by=".">
<xsl:sort select="current-grouping-key()"/>
<node><xsl:attribute name="id"><xsl:value-of select="current-grouping-key()"/></xsl:attribute></node>
<xsl:text>
</xsl:text>
</xsl:for-each-group>
<xsl:text>
</xsl:text>
Thanks in advance for the answers.