Sei sulla pagina 1di 3

<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.

org/1999/xhtml"> <xsl:attribute-set name="set_table"> <xsl:attribute name="border">5</xsl:attribute> <xsl:attribute name="cellpadding">10</xsl:attribute> <xsl:attribute name="cellspacing">10</xsl:attribute> <xsl:attribute name="fname">Garamond</xsl:attribute> </xsl:attribute-set> <xsl:attribute-set name="den"> <xsl:attribute name="font-weight">bold</xsl:attribute> <xsl:attribute name="font-color">red</xsl:attribute> <xsl:attribute name="font-size">14px</xsl:attribute> </xsl:attribute-set> <xsl:template match="TELEFOANE"> <html> <body> <h2 align="center" >Telefoane in vinzare</h2> <table xsl:use-attribute-sets="set_table"> <tr bgcolor="#9acd32"> <th>Denumire</th> <th>Tip ecran</th> <th>Tip baterie</th> <th>Marime</th> <th>Lansare</th> <th>Functii</th> <th>Pret</th> <th>VALUTA</th> </tr> <xsl:for-each select="NOKIA"> <xsl:sort select="LANSARE" order="ascending"/> <xsl:if test="VALUTA='lei'"> <tr> <td xsl:use-attribute-sets="den"><xsl:value-of select="DENUMIRE"/></td> <td><xsl:value-of select="TIP_ECRAN"/></td> <td><xsl:value-of select="TIP_BATERIE"/></td> <td><xsl:value-of select="MARIME"/></td> <td><xsl:value-of select="LANSARE"/></td> <td><xsl:value-of select="FUNCTII"/></td> <xsl:choose> <xsl:when test="PRET &lt; 2500 "> <td bgcolor="#F08080"> <xsl:value-of select="PRET"/></td> </xsl:when> <xsl:otherwise> <td><xsl:value-of select="PRET"/></td> </xsl:otherwise> </xsl:choose> <td><xsl:value-of select="VALUTA"/></td> </tr> </xsl:if> </xsl:for-each> </table> <xsl:variable name="suma" select="sum(NOKIA/PRET)"/> <p style="font-size:20px">Pretul total al telefoanelor Nokia :<xsl:value-of select="$suma"/></p> <h2></h2> </body> </html> </xsl:template> </xsl:stylesheet>

File.xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="xsltdoc.xsl"?> <TELEFOANE> <NOKIA> <DENUMIRE>Nokia 100 Black</DENUMIRE> <TIP_ECRAN>TFT</TIP_ECRAN> <TIP_BATERIE>Li-Ion 850 mAh(BL-5CB)</TIP_BATERIE> <MARIME>1.8</MARIME> <LANSARE>2011,noiembrie</LANSARE> <FUNCTII>Lanterna - Organizator</FUNCTII> <STOC>In stoc</STOC> <PRET>100</PRET> <VALUTA>euro</VALUTA> </NOKIA> <NOKIA> <DENUMIRE>Nokia 500 Black (Azure/Red)</DENUMIRE> <TIP_ECRAN>TFT touchscreen, 16M culori</TIP_ECRAN> <TIP_BATERIE>Li-Ion 1110 mAh (BL-4U)</TIP_BATERIE> <MARIME>3.2</MARIME> <LANSARE>2011,septembrie</LANSARE> <CAMERA>5 MP,2592x1944 pixeli</CAMERA> <FUNCTII>Sistem de operare Symbian </FUNCTII> <STOC>In stoc</STOC> <PRET>2299</PRET> <VALUTA>lei</VALUTA> </NOKIA> .xsd(schema) <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified"> <xs:element name="TELEFOANE"> <xs:complexType> <xs:sequence> <xs:element name="NOKIA" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element ref="DENUMIRE"/> <xs:element ref="TIP_ECRAN"/> <xs:element ref="TIP_BATERIE"/> <xs:element ref="MARIME"/> <xs:element ref="LANSARE"/> <xs:element ref="CAMERA" minOccurs="0"/> <xs:element ref="FUNCTII"/> <xs:element ref="STOC"/> <xs:element ref="PRET"/> <xs:element ref="VALUTA"/> </xs:sequence> <xs:attribute name="cod" type="xs:ID" use="required"/> </xs:complexType> </xs:element> <xs:element name="SAMSUNG" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element ref="DENUMIRE"/> <xs:element ref="TIP_ECRAN"/> <xs:element ref="TIP_BATERIE"/> <xs:element ref="MARIME"/>

<xs:element ref="LANSARE"/> <xs:element ref="CAMERA" minOccurs="0"/> <xs:element ref="FUNCTII"/> <xs:element ref="STOC"/> <xs:element ref="PRET"/> <xs:element ref="VALUTA"/> </xs:sequence> <xs:attribute name="cod" type="xs:ID" use="required"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="DENUMIRE" type="xs:string"/> <xs:element name="TIP_ECRAN" type="xs:string"/> <xs:element name="TIP_BATERIE" type="xs:string"/> <xs:element name="MARIME" type="xs:string"/> <xs:element name="LANSARE" type="xs:gYearMonth"/> <xs:element name="CAMERA" type="xs:string"/> <xs:element name="FUNCTII" type="xs:string"/> <xs:element name="STOC" type="xs:string"/> <xs:element name="PRET"> <xs:simpleType> <xs:restriction base="xs:decimal"> <xs:minInclusive value="10"/> <xs:maxExclusive value="10000"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="VALUTA" > <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="lei"/> <xs:enumeration value="euro"/> <xs:enumeration value="$"/> </xs:restriction> </xs:simpleType> </xs:element> </xs:schema>

Potrebbero piacerti anche