"1.0" "ISO-8859-1" "2.0" "/course - Catalog/Department" "Title"

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

XML 2 1 <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/Course_Catalog/Department"> <Title><xsl:value-of select="Title"/></Title> </xsl:template> </xsl:stylesheet> 2 <?xml version="1.

0" encoding="ISO-8859-1"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/Course_Catalog/Department"> <Department> <Title><xsl:value-of select="Title"/></Title> <xsl:copy-of select="Chair"/> </Department> </xsl:template> </xsl:stylesheet> XML 3 1 doc("countries.xml")/countries/country[@name="Mongolia"]/data(@area) 2 doc("countries.xml")/countries/country/city[name=parent::country/data(@name)]/name 3 doc("countries.xml")/countries/avg(country[language="Russian"]/data(@population)) 4 doc("countries.xml")/countries/country[count(city[population>3000000])>2]/data(@name) 5 <result> <French> {for $var in doc("countries.xml")/countries/country where some $lang in $var/language satisfies contains($lang, "French") return <country>{$var/data(@name)}</country>} </French> <German> {for $var in doc("countries.xml")/countries/country where some $lang in $var/language satisfies contains($lang, "German") return <country>{$var/data(@name)}</country>} </German> </result> 6 <result> {for $var in doc("countries.xml")/countries/country where $var/(@population div @area)=

max(doc("countries.xml")/countries/country/(@population div @area)) return <highest density="{$var/(@population div @area)}"> {$var/data(@name)} </highest>} {for $var in doc("countries.xml")/countries/country where $var/(@population div @area)= min(doc("countries.xml")/countries/country/(@population div @area)) return <lowest density="{$var/(@population div @area)}"> {$var/data(@name)} </lowest>} </result> XML 4

1 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> <xsl:template match="countries/country[@population &gt; 9000000 and @population &lt; 10000000]"> <xsl:copy-of select="." /> </xsl:template> <xsl:template match="text()"/> </xsl:stylesheet> 2 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> <xsl:template match="/"> <html> <table border="1"> <xsl:for-each select="countries/country[count(language) &gt; 3]"> <xsl:sort select="count(language)" order="descending"/> <tr> <td><b><xsl:value-of select="@name"/></b></td> <td><xsl:value-of select="@population"/></td> <td><xsl:value-of select="@area"/></td> <td><xsl:value-of select="count(language)"/></td> </tr> </xsl:for-each> </table> </html> </xsl:template> <xsl:template match="text()"/> </xsl:stylesheet>

3 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> <xsl:template match="*|@*|text()"> <xsl:copy> <xsl:apply-templates select="*|@*|text()" /> </xsl:copy> </xsl:template> <xsl:template match="country">

<country cities="{count(city)}" languages="{count(language)}"> <name> <xsl:value-of select="./@name" /> </name> <population> <xsl:value-of select="./@population" /> </population> </country> </xsl:template> </xsl:stylesheet>

You might also like