Considérons le fichier xml suivant :
<?xml version="1.0" encoding="UTF-8"?> <!-- <!DOCTYPE presidents SYSTEM "presidents.dtd"> --> <?xml-stylesheet type="text/xsl" href="xslt_q0.xslt"?> <presidents> <president> <term from="1809" to="1817"/> <name> <first>James</first> <last>Madison</last> </name> <party>Democratic Republican</party> <vicePresident> <name> <first>George</first> <last>Clinton</last> </name> </vicePresident> </president> <president> <term from="1825" to="1829"/> <name> <first>John</first> <middle>Quincy</middle> <last>Adams</last> </name> <party>Democratic Republican</party> <vicePresident> <name> <first>John</first> <middle>C</middle> <last>Calhoun</last> </name> </vicePresident> </president> </presidents>
Pourquoi ce fichier xslt n'est-il pas correct ?
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <html><body> <xsl:apply-templates select="president"> <p> </p> </xsl:apply-templates> </body></html> </xsl:template> </xsl:stylesheet>
Quelle sortie sera produite par ce fichier ?
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <html> <body> <xsl:apply-templates select="president"/> </body> </html> </xsl:template> <xsl:template match="president"> <a></a> </xsl:template> </xsl:stylesheet>
Quelle sortie sera produite par ce fichier ?
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="presidents"> <html> <body> <xsl:apply-templates select="president"/> </body> </html> </xsl:template> <xsl:template match="president"> <a></a> </xsl:template> </xsl:stylesheet>
Quelle sortie sera produite par ce fichier ?
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="presidents"> <html><body> <xsl:for-each select="president"> <abcd></abcd> <xsl:apply-templates select="name/middle"/> </xsl:for-each> </body></html> </xsl:template> <xsl:template match="president"> <p></p> </xsl:template> </xsl:stylesheet>
Quelle sortie sera produite par ce fichier ?
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="presidents"> <html><body> <xsl:for-each select="president"> <xsl:apply-templates select="name"/> </xsl:for-each> </body></html> </xsl:template> <xsl:template match="name"> <xsl:variable name="midName"> <xsl:choose> <xsl:when test="middle"> <xsl:value-of select="middle"/> </xsl:when> <xsl:otherwise> <xsl:text>???</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:value-of select="$midName"/> </xsl:template> </xsl:stylesheet>
Quelle sortie sera produite par ce fichier ?
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="presidents"> <html><body> <ul> <xsl:apply-templates select="president"> <xsl:sort select="name/first" order="descending"/> </xsl:apply-templates> </ul> </body></html> </xsl:template> <xsl:template match="vicePresident"/> <xsl:template match="party"/> <xsl:template match="name"> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> <xsl:value-of select="first"/> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> <xsl:value-of select="middle"/> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> <xsl:value-of select="last"/> <br/> </xsl:template> </xsl:stylesheet>