Reputation: 521
This is my XSLT code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes" />
<xsl:output doctype-public="-//W3C//DTD XHTML 1.1//EN"
doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" />
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt">
<head>
<title>João Cona</title>
<link rel="stylesheet" type="text/css" href="T01Catalogue.css"
charset="UTF-8" />
</head>
<body>
<xsl:apply-templates select="//utilizadores" />
</body>
</html>
</xsl:template>
<xsl:template match="utilizadores">
<xsl:call-template name="username">
<xsl:with-param name="id" select="//utilizador/@username"/>
</xsl:call-template>
<xsl:call-template name="birthdate">
<xsl:with-param name="id" select="//utilizador/@username"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="username">
<xsl:param name="id"/>
<xsl:call-template name="name">
<xsl:with-param name="nome">
<xsl:value-of select="//utilizador[@username = $id]/nome"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="birthdate">
<xsl:param name="id"/>
<xsl:call-template name="dataNasc">
<xsl:with-param name="data">
<xsl:value-of select="//utilizador[@username = $id]/birthday"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="name">
<xsl:param name="nome"/>
<p>
<xsl:value-of select="$nome"/>
</p>
</xsl:template>
<xsl:template name="dataNasc">
<xsl:param name="data"/>
<p>
<xsl:value-of select="$data"/>
</p>
</xsl:template>
I have this output (on HTML):
Guilherme Luís1996-11-28
I was expecting this (on HTML):
Guilherme Luís
1996-11-28
In the snippet you can find my XML code, if that helps.
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="1.xsl"?>
<xml_tube>
<utilizadores>
<utilizador username="Guicky" password="futurama96">
<nome>Guilherme Luís</nome>
<birthday>1996-11-28</birthday>
<foto href="guilhas.jpg"/>
</utilizador>
<utilizador username="Daisy" password="woofwoof11">
<nome>Daisy Luís</nome>
<birthday>2011-04-04</birthday>
<foto href="daisy.png"/>
</utilizador>
<utilizador username="Anabela65" password="crumble65">
<nome>Anabela Ribeiro</nome>
<birthday>1965-04-02</birthday>
<foto href="belinha.jpg"/>
</utilizador>
<utilizador username="Izzie" password="lagartixa">
<nome>Isadora Luís</nome>
<birthday>1988-06-27</birthday>
<foto href="izzie.jpg"/>
</utilizador>
</utilizadores>
<videos_pub>
<video id="Vid1" publisher="Daisy" duracao="3:37" data="2016-02-29">
<título>Who let the dogs out? - Baha Men</título>
<thumb>http://i3.ytimg.com/vi/Qkuu0Lwb5EM/hqdefault.jpg</thumb>
<descrição>My favorite song, lol.</descrição>
<hyperlink>https://www.youtube.com/watch?v=Qkuu0Lwb5EM</hyperlink>
<qualidade pixelization="1080p"/>
<qualidade pixelization="480p"/>
<likes liked="Guicky"/>
<related></related>
</video>
<video id="Vid2" publisher="Guicky" duracao="4:01" data="2016-02-29">
<título>Desiigner - Timmy Turner</título>
<thumb>http://i3.ytimg.com/vi/JzmRt2VgKYQ/hqdefault.jpg</thumb>
<descrição>Timmy Timmy Timmy Turner.</descrição>
<hyperlink>https://www.youtube.com/embed/ProbPpO_8oo</hyperlink>
<qualidade pixelization="720p"/>
<qualidade pixelization="1080p"/>
<likes liked="Anabela65"/>
<likes liked="Daisy"/>
<related></related>
</video>
<video id="Vid3" publisher="Guicky" duracao="3:47" data="2016-02-29">
<título>I'm all the way up - Fat Joe</título>
<thumb>https://www.youtube.com/watch?v=y2ak_oBeC-I</thumb>
<descrição>Nothing can stop me, I'm all the way up.</descrição>
<hyperlink>https://www.youtube.com/embed/y2ak_oBeC-I</hyperlink>
<qualidade pixelization="480p"/>
<qualidade pixelization="720p"/>
<related></related>
</video>
<video id="Vid4" publisher="Anabela65" duracao="3:21" data="2016-02-29">
<título>Putzgrilla - Sentadinha</título>
<thumb>http://i3.ytimg.com/vi/QC4JbIvIhdI/hqdefault.jpg</thumb>
<descrição>Dá uma sentadinha.</descrição>
<hyperlink>https://www.youtube.com/watch?v=QC4JbIvIhdI</hyperlink>
<qualidade pixelization="720p"/>
<likes liked="Guicky"/>
<likes liked="Daisy"/>
<related></related>
</video>
<video data="2017-01-13" duracao="02:16" id="Vid5" publisher="Izzie">
<título>Yann Tiersen - La Valse d'Amelie</título>
<thumb>http://i3.ytimg.com/vi/uzurqBnALkw/hqdefault.jpg</thumb>
<descrição>A minha música preferida.</descrição>
<hyperlink>https://www.youtube.com/watch?v=uzurqBnALkw</hyperlink>
<qualidade pixelization="720p"/>
<likes liked="Guicky"/>
<likes liked="Anabela65"/>
<related></related>
</video>
</videos_pub>
<playlist>
<lista owner="Guicky" dataIns="2016-10-24" id="PV1">
<titulo>BEST MUSIC.</titulo>
<descricao>Compilation of my favourite music videos.</descricao>
<gostosL gostouL="Guicky"/>
<links_vid vid="Vid2"/>
<links_vid vid="Vid3"/>
<administradores>
<admin ref="Guicky"/>
<admin ref="Daisy"/>
</administradores>
<editores>
<editor ref="Guicky"/>
</editores>
<subscritores>
<subs ref="Daisy"/>
<subs ref="Anabela65"/>
</subscritores>
<thumbnail link="http://i3.ytimg.com/vi/QC4JbIvIhdI/hqdefault.jpg"/>
</lista>
<lista owner="Anabela65" dataIns="2016-02-29" id="PV2">
<titulo>Sentadinha!</titulo>
<descricao>Siting lesson's with Guicky's mom!</descricao>
<links_vid vid="Vid4"/>
<administradores>
<admin ref="Anabela65"/>
<admin ref="Guicky"/>
</administradores>
<editores>
<editor ref="Anabela65"/>
</editores>
<subscritores>
<subs ref="Guicky"/>
<subs ref="Daisy"/>
</subscritores>
<thumbnail link="http://i3.ytimg.com/vi/uMK0prafzw0/hqdefault.jpg"/>
</lista>
</playlist>
<comentarios>
<comentario id="C1" refV="Vid1" user="Guicky" data="2016-10-23">
<text>AHAHAHAHA, bom vídeo.</text>
<gosto gostou="Daisy"/>
<respostas>
<texto autor="Daisy">Grande clássico!</texto>
</respostas>
</comentario>
<comentario id="C2" refL="Vid2" user="Anabela65" data="2016-10-22">
<text>Timmy timmy timmy turner...</text>
<gosto gostou="Guicky"/>
<gosto gostou="Daisy"/>
<respostas>
<texto autor="Guicky">U know it.</texto>
<resposta autor="Daisy">LOL!</resposta>
</respostas>
</comentario>
</comentarios>
</xml_tube>
Any idea why this isn't working? Why is the XSLT not reading the
tag?
Upvotes: 0
Views: 200
Reputation: 167716
Try moving the xmlns="http://www.w3.org/1999/xhtml"
to the root of the stylesheet element (i.e. <xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
) so that all result elements are XHTML elements and not only those in the template where you currently have the namespace declaration.
Upvotes: 1