The nature of the problem

Imagine that we want to transform our Hamlet file (again). This time, we want to add a copy of the speaker’s roleDesc immediately following the character’s name at the beginning of every speech. This template would do it:


                
                ]]><xsl:text> (</xsl:text>
                <xsl:variable name="thisSpeaker" select="parent::sp/@who"/>
                <xsl:value-of select="//castItem[role/@xml:id = $thisSpeaker]/roleDesc"/>
                <xsl:text>)</xsl:text>
            ]]>
XSLT Keys, slide 2 of 9