title: Working with XSLT Variables
body: <p>Here is my XML:
  (it's in Portuguese but I guess it really doesn't matter)</p>
  
  <pre><code>    &lt;xml_tube&gt;
      &lt;utilizadores&gt;
          &lt;utilizador username="Guicky" password="futurama96"&gt;
              &lt;nome&gt;Guilherme Luís&lt;/nome&gt;
              &lt;birthday&gt;1996-11-28&lt;/birthday&gt;
              &lt;foto href="guilhas.jpg"/&gt;
          &lt;/utilizador&gt;
          &lt;utilizador username="Daisy" password="woofwoof11"&gt;
              &lt;nome&gt;Daisy Luís&lt;/nome&gt;
              &lt;birthday&gt;2011-04-04&lt;/birthday&gt;
              &lt;foto href="daisy.png"/&gt;
          &lt;/utilizador&gt;
          &lt;utilizador username="Anabela65" password="crumble65"&gt;
              &lt;nome&gt;Anabela Ribeiro&lt;/nome&gt;
              &lt;birthday&gt;1965-04-02&lt;/birthday&gt;
              &lt;foto href="belinha.jpg"/&gt;
          &lt;/utilizador&gt;
          &lt;utilizador username="Izzie" password="lagartixa"&gt;
              &lt;nome&gt;Isadora Luís&lt;/nome&gt;
              &lt;birthday&gt;1988-06-27&lt;/birthday&gt;
              &lt;foto href="izzie.jpg"/&gt;
          &lt;/utilizador&gt;
      &lt;/utilizadores&gt;
      &lt;videos_pub&gt;
          &lt;video id="Vid1" publisher="Daisy" duracao="3:37" data="2016-02-29"&gt;
              &lt;título&gt;Who let the dogs out? - Baha Men&lt;/título&gt;
              &lt;thumb&gt;http://i3.ytimg.com/vi/Qkuu0Lwb5EM/hqdefault.jpg&lt;/thumb&gt;
              &lt;descrição&gt;My favorite song, lol.&lt;/descrição&gt;
              &lt;hyperlink&gt;https://www.youtube.com/watch?v=Qkuu0Lwb5EM&lt;/hyperlink&gt;
              &lt;qualidade pixelization="1080p"/&gt;
              &lt;qualidade pixelization="480p"/&gt;
              &lt;likes liked="Guicky"/&gt;
              &lt;related&gt;&lt;/related&gt;
          &lt;/video&gt;
          &lt;video id="Vid2" publisher="Guicky" duracao="4:01" data="2016-02-29"&gt;
              &lt;título&gt;Desiigner - Timmy Turner&lt;/título&gt;
              &lt;thumb&gt;http://i3.ytimg.com/vi/JzmRt2VgKYQ/hqdefault.jpg&lt;/thumb&gt;
              &lt;descrição&gt;Timmy Timmy Timmy Turner.&lt;/descrição&gt;
              &lt;hyperlink&gt;https://www.youtube.com/embed/ProbPpO_8oo&lt;/hyperlink&gt;
              &lt;qualidade pixelization="720p"/&gt;
              &lt;qualidade pixelization="1080p"/&gt;
              &lt;likes liked="Anabela65"/&gt;
              &lt;likes liked="Daisy"/&gt;
              &lt;related&gt;&lt;/related&gt;
          &lt;/video&gt;
          &lt;video id="Vid3" publisher="Guicky" duracao="3:47" data="2016-02-29"&gt;
              &lt;título&gt;I'm all the way up - Fat Joe&lt;/título&gt;
              &lt;thumb&gt;https://www.youtube.com/watch?v=y2ak_oBeC-I&lt;/thumb&gt;
              &lt;descrição&gt;Nothing can stop me, I'm all the way up.&lt;/descrição&gt;
              &lt;hyperlink&gt;https://www.youtube.com/embed/y2ak_oBeC-I&lt;/hyperlink&gt;
              &lt;qualidade pixelization="480p"/&gt;
              &lt;qualidade pixelization="720p"/&gt;
              &lt;related&gt;&lt;/related&gt;
          &lt;/video&gt;
          &lt;video id="Vid4" publisher="Anabela65" duracao="3:21" data="2016-02-29"&gt;
              &lt;título&gt;Putzgrilla - Sentadinha&lt;/título&gt;
              &lt;thumb&gt;http://i3.ytimg.com/vi/QC4JbIvIhdI/hqdefault.jpg&lt;/thumb&gt;
              &lt;descrição&gt;Dá uma sentadinha.&lt;/descrição&gt;
              &lt;hyperlink&gt;https://www.youtube.com/watch?v=QC4JbIvIhdI&lt;/hyperlink&gt;
              &lt;qualidade pixelization="720p"/&gt;
              &lt;likes liked="Guicky"/&gt;
              &lt;likes liked="Daisy"/&gt;
              &lt;related&gt;&lt;/related&gt;
          &lt;/video&gt;
          &lt;video data="2017-01-13" duracao="02:16" id="Vid5" publisher="Izzie"&gt;
              &lt;título&gt;Yann Tiersen - La Valse d'Amelie&lt;/título&gt;
              &lt;thumb&gt;http://i3.ytimg.com/vi/uzurqBnALkw/hqdefault.jpg&lt;/thumb&gt;
              &lt;descrição&gt;A minha música preferida.&lt;/descrição&gt;
              &lt;hyperlink&gt;https://www.youtube.com/watch?v=uzurqBnALkw&lt;/hyperlink&gt;
              &lt;qualidade pixelization="720p"/&gt;
              &lt;likes liked="Guicky"/&gt;
              &lt;likes liked="Anabela65"/&gt;
              &lt;related&gt;&lt;/related&gt;
          &lt;/video&gt;
      &lt;/videos_pub&gt;
      &lt;playlist&gt;
          &lt;lista owner="Guicky" dataIns="2016-10-24" id="PV1"&gt;
              &lt;titulo&gt;BEST MUSIC.&lt;/titulo&gt;
              &lt;descricao&gt;Compilation of my favourite music videos.&lt;/descricao&gt;
              &lt;gostosL gostouL="Guicky"/&gt;
              &lt;links_vid vid="Vid2"/&gt;
              &lt;links_vid vid="Vid3"/&gt;
              &lt;administradores&gt;
                  &lt;admin ref="Guicky"/&gt;
                  &lt;admin ref="Daisy"/&gt;
              &lt;/administradores&gt;
              &lt;editores&gt;
                  &lt;editor ref="Guicky"/&gt;
              &lt;/editores&gt;
              &lt;subscritores&gt;
                  &lt;subs ref="Daisy"/&gt;
                  &lt;subs ref="Anabela65"/&gt;
              &lt;/subscritores&gt;
              &lt;thumbnail link="http://i3.ytimg.com/vi/QC4JbIvIhdI/hqdefault.jpg"/&gt;
          &lt;/lista&gt;
          &lt;lista owner="Anabela65" dataIns="2016-02-29" id="PV2"&gt;
              &lt;titulo&gt;Sentadinha!&lt;/titulo&gt;
              &lt;descricao&gt;Siting lesson's with Guicky's mom!&lt;/descricao&gt;
              &lt;links_vid vid="Vid4"/&gt;
              &lt;administradores&gt;
                  &lt;admin ref="Anabela65"/&gt;
                  &lt;admin ref="Guicky"/&gt;
              &lt;/administradores&gt;
              &lt;editores&gt;
                  &lt;editor ref="Anabela65"/&gt;
              &lt;/editores&gt;
              &lt;subscritores&gt;
                  &lt;subs ref="Guicky"/&gt;
                  &lt;subs ref="Daisy"/&gt;
              &lt;/subscritores&gt;
              &lt;thumbnail link="http://i3.ytimg.com/vi/uMK0prafzw0/hqdefault.jpg"/&gt;
          &lt;/lista&gt;
      &lt;/playlist&gt;
      &lt;comentarios&gt;
          &lt;comentario id="C1" refV="Vid1" user="Guicky" data="2016-10-23"&gt;
              &lt;text&gt;AHAHAHAHA, bom vídeo.&lt;/text&gt;
              &lt;gosto gostou="Daisy"/&gt;
              &lt;respostas&gt;
                  &lt;texto autor="Daisy"&gt;Grande clássico!&lt;/texto&gt;
              &lt;/respostas&gt;
          &lt;/comentario&gt;
          &lt;comentario id="C2" refL="Vid2" user="Anabela65" data="2016-10-22"&gt;
              &lt;text&gt;Timmy timmy timmy turner...&lt;/text&gt;
              &lt;gosto gostou="Guicky"/&gt;
              &lt;gosto gostou="Daisy"/&gt;
              &lt;respostas&gt;
                  &lt;texto autor="Guicky"&gt;U know it.&lt;/texto&gt;
                  &lt;resposta autor="Daisy"&gt;LOL!&lt;/resposta&gt;
              &lt;/respostas&gt;
          &lt;/comentario&gt;
      &lt;/comentarios&gt;
  &lt;/xml_tube&gt;
  </code></pre>
  
  <p>Here is my XSLT:
  (version 1.0)</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&gt;
  &lt;xsl:output doctype-public="-//W3C//DTD XHTML 1.1//EN"
              doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" /&gt;
  
      &lt;xsl:template match="/"&gt;
          &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="eng"&gt;
              &lt;head&gt;
                  &lt;title&gt;My XML Tube&lt;/title&gt;
                  &lt;link rel="stylesheet" type="text/css" href="XML_Tube.css" charset="UTF-8"/&gt;
                  &lt;link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"/&gt;
                  &lt;link rel="icon" 
                        type="image.png"
                        href="favicon-16.png"/&gt;   
              &lt;/head&gt;
              &lt;body&gt;
                  &lt;div class="spacer"/&gt;
                  &lt;a href="https://www.youtube.com"&gt;
                      &lt;img id="img" src="img/logos/logo.png"/&gt;
                  &lt;/a&gt;
                  &lt;nav&gt;
                      &lt;ul&gt;
                          &lt;li&gt;&lt;a href="home.html"&gt;Playlists&lt;/a&gt;
                              &lt;ul&gt;
                                  &lt;li&gt;&lt;a href="../XMLTube.xml#body"&gt;Playlist&lt;/a&gt;&lt;/li&gt;
                                  &lt;li&gt;&lt;a href=""&gt;Playlists&lt;/a&gt;&lt;/li&gt;
                              &lt;/ul&gt;
                          &lt;/li&gt;
                          &lt;li&gt;&lt;a href="portfolio.html"&gt;Utilizadores&lt;/a&gt;
                              &lt;ul&gt;
                                  &lt;li&gt;&lt;a href="Portfolio.html#NOSLeague"&gt;Um utilizador&lt;/a&gt;&lt;/li&gt;
                                  &lt;li&gt;&lt;a href="Portfolio.html#PremierLeague"&gt;Lista geral de utilizadores&lt;/a&gt;&lt;/li&gt;
                              &lt;/ul&gt;
                          &lt;/li&gt;
                          &lt;li&gt;&lt;a href="contacts.html"&gt;Vídeos&lt;/a&gt;
                              &lt;ul&gt;
                                  &lt;li&gt;&lt;a href="Contacts.html#gui"&gt;Vídeo&lt;/a&gt;&lt;/li&gt;
                                  &lt;li&gt;&lt;a href="Contacts.html#rodri"&gt;Lista geral de vídeos&lt;/a&gt;&lt;/li&gt;
                              &lt;/ul&gt;
                          &lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/nav&gt;
                  &lt;h1&gt;Lista de Utilizadores&lt;/h1&gt;
                  &lt;xsl:for-each select="xml_tube/utilizadores"&gt;
                      &lt;xsl:for-each select="utilizador"&gt;
                          &lt;xsl:for-each select="foto"&gt;
                              &lt;xsl:element name="img"&gt;
                                  &lt;xsl:attribute name="src"&gt;
                                      &lt;xsl:value-of select="@href"/&gt;
                                  &lt;/xsl:attribute&gt;
                                  &lt;xsl:attribute name="width"&gt;20%&lt;/xsl:attribute&gt;
                                  &lt;xsl:attribute name="height"&gt;auto&lt;/xsl:attribute&gt;
                              &lt;/xsl:element&gt;
                          &lt;/xsl:for-each&gt;
                      &lt;xsl:variable name="utilizadores" select="@username"/&gt;
                      &lt;p&gt;&lt;strong&gt;Username: &lt;/strong&gt;&lt;xsl:value-of select="@username"/&gt;&lt;/p&gt;
                      &lt;p&gt;&lt;strong&gt;Nome: &lt;/strong&gt; &lt;xsl:value-of select="nome"/&gt;&lt;/p&gt;
                      &lt;p&gt;&lt;strong&gt;Birthday: &lt;/strong&gt; &lt;xsl:value-of select="birthday"/&gt;&lt;/p&gt;
                          &lt;p&gt;&lt;strong&gt;Vídeos Publicados:&lt;/strong&gt; &lt;xsl:value-of select="xml_tube/videos_pub/video[@publisher=$utilizadores]/título"/&gt;&lt;/p&gt;
                      &lt;/xsl:for-each&gt;
                  &lt;/xsl:for-each&gt;
              &lt;/body&gt;
          &lt;/html&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I'm having a problem with this specific part:</p>
  
  <pre><code>&lt;xsl:variable name="utilizadores" select="@username"/&gt;
          &lt;p&gt;&lt;strong&gt;Username: &lt;/strong&gt;&lt;xsl:value-of select="@username"/&gt;&lt;/p&gt;
          &lt;p&gt;&lt;strong&gt;Nome: &lt;/strong&gt; &lt;xsl:value-of select="nome"/&gt;&lt;/p&gt;
          &lt;p&gt;&lt;strong&gt;Birthday: &lt;/strong&gt; &lt;xsl:value-of select="birthday"/&gt;&lt;/p&gt;
              &lt;p&gt;&lt;strong&gt;Vídeos Publicados:&lt;/strong&gt; &lt;xsl:value-of select="xml_tube/videos_pub/video[@publisher=$utilizadores]/título"/&gt;&lt;/p&gt;
          &lt;/xsl:for-each&gt;
  </code></pre>
  
  <p>I want to use the @username of the users that the <code>xsl:for-each</code> iterated on and use it to to search for the published vids of that @username.</p>
  
  <p>Expected output:</p>
  
  <pre><code>Videos publicados: Vid1Vid3
  </code></pre>
  
  <p>My question is: How can i use the xsl:for-each to get me every username and then get me the videos of that specific username</p>