0

XSL 1.0 を使用して同じ年に制作されたジョニー・デップ主演の映画のすべてのペアを検索する方法について、誰かが私にいくつかのガイダンスを教えてください。映画の @id は最初の映画の @id よりも大きいため、次のようになります。

<same_year actor="Johnny Depp">
<pair year="..">
<movie id=".."> ... </movie>
<movie id=".."> ... </movie>
</pair>
...
</same_year>

XML:

<movie id="475" imdb_id="0107207">
<title>In the Name of the Father</title>
<year>1993</year>
<critic_rating>7.6</critic_rating>
<critic_num_reviews>39</critic_num_reviews>
<critic_score>94</critic_score>
<audience_rating>4.0</audience_rating>
<audience_num_ratings>10715</audience_num_ratings>
<audience_score>92</audience_score>
<directors>
<director>Jim Sheridan</director>
</directors>
<actors>
<actor rank="1">Daniel Day-Lewis</actor>
<actor rank="2">Pete Postlethwaite</actor>
<actor rank="3">Emma Thompson</actor>
<actor rank="4">John Lynch</actor>
...
<actor rank="60">Philip King</actor>
</actors>
<countries>
<country>Ireland</country>
</countries>
</movie>

ありがとう。

4

1 に答える 1

0

次のようなものが機能するはずです(テストされていません):

<same_year actor="Johnny Depp">
    <xsl:for-each select="movie[actor = 'Johnny Depp']">
        <xsl:variable name="movie1" select="."/>
        <xsl:for-each select="../movie[actor = 'Johnny Depp' and year = $movie1/year and @id &gt; $movie1/@id]">
            <pair year="{year}">
                <xsl:copy-of select="$movie1"/>
                <xsl:copy-of select="."/>
            </pair>
        </xsl:for-each>
    </xsl:for-each>
</same_year>

for-each条件に一致するムービーのすべてのペアをループする2 つのループがあります。

于 2013-05-08T14:50:29.310 に答える