1 / 4

<?xml version="1.0" encoding="UTF-8"?>

<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" xmlns:xlink="http://www.w3.org/1999/xlink"> <xsd:element name="movies"> <xsd:complexType> <xsd:sequence>

rosina
Download Presentation

<?xml version="1.0" encoding="UTF-8"?>

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" xmlns:xlink="http://www.w3.org/1999/xlink"> <xsd:element name="movies"> <xsd:complexType> <xsd:sequence> <xsd:element name="movie" type="movieDetails" minOccurs = "1" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:complexType name="movieDetails"> <xsd:sequence> <!-- Note use of xlink--> <xsd:element name="name" xlink:type="simple"/> <xsd:element name="genre"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Action"/> <xsd:enumeration value="Horror"/> <xsd:enumeration value="Comedy"/> <xsd:enumeration value="Drama"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="actors" type="actorDetails" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="actorDetails"> <xsd:sequence> <xsd:element name="actorName" type="xsd:string"/> <xsd:element name="actorSSN" type="ssnType" minOccurs="0"/> <xsd:element name="actorAge" type="xsd:integer"/> </xsd:sequence> </xsd:complexType> <xsd:simpleType name="ssnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value="\d{3}-\d{2}-\d{4}"/> </xsd:restriction> </xsd:simpleType> </xsd:schema>

  2. <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="movie.xsl" type="text/xsl"?> <movies xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:noNamespaceSchemaLocation="movie.xsd"> <movie> <name xlink:type="simple" xlink:href="http://www.imdb.com/title/tt0239948/"> Saving Silverman </name> <genre>Comedy</genre> <actors> <actorName>Jack Black</actorName> <actorSSN>111-11-1111</actorSSN> <actorAge>35</actorAge> </actors> <actors> <actorName>Jason Biggs</actorName> <actorSSN>222-22-2222</actorSSN> <actorAge>25</actorAge> </actors> </movie> <movie> <name xlink:type="simple" xlink:href="http://www.imdb.com/title/tt0396269/"> Wedding Crashers</name> <genre>Comedy</genre> <actors> <actorName>Vince Vaughn</actorName> <actorSSN>333-33-3333</actorSSN> <actorAge>30</actorAge> </actors> <actors> <actorName>Owen Wilson</actorName> <actorSSN>444-44-4444</actorSSN> <actorAge>33</actorAge> </actors> </movie> <movie> <name xlink:type="simple" xlink:href="http://www.imdb.com/title/tt0103064/"> Terminator 2</name> <genre>Action</genre> <actors> <actorName>Arnold Schwarzenegger</actorName> <actorSSN>666-66-6666</actorSSN> <actorAge>50</actorAge> </actors> </movie> </movies>

  3. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" exclude-result-prefixes="xlink" version="1.0"> <xsl:output method="html"/> <xsl:template match="*[@xlink:type = 'simple' and @xlink:href]"> <a href="{@xlink:href}"> <xsl:apply-templates/> </a> </xsl:template> <xsl:template match="/"> <HTML> <HEAD> <TITLE>Movie XLink Example</TITLE> <STYLE TYPE="text/css"> H2 {TEXT-ALIGN:CENTER;} .blueBackground {BACKGROUND-COLOR:LIGHTBLUE; TEXT-ALIGN:CENTER;} .yellowBackground {BACKGROUND-COLOR:LIGHTYELLOW; TEXT-ALIGN:CENTER; FONT-WEIGHT: BOLD ; FONT-SIZE:14pt;} .salmonBackground {BACKGROUND-COLOR=LIGHTBLUE; TEXT-ALIGN:CENTER; FONT-SIZE:12pt;} </STYLE> </HEAD> <BODY> <H2>Movie XLinks</H2> <xsl:apply-templates select="movies"/> </BODY> </HTML> </xsl:template> <!-- template for handling a link --> <xsl:template match="name"> <a href="{../@xlink:href}"> <xsl:value-of select="."/> </a> </xsl:template>

  4. <xsl:template match="movies"> <TABLE BORDER="1" WIDTH="100%"> <xsl:for-each select="movie"> <TR> <TD COLSPAN="6" CLASS="blueBackground"> <BR/> <xsl:text>Movie: </xsl:text> <!--applying the template--> <xsl:apply-templates select="name"/> <BR/> <xsl:text>Movie Genre: </xsl:text> <xsl:value-of select="genre"/> <BR/> <BR/> </TD> </TR> <TR CLASS="yellowBackground"> <TD> <xsl:text>Actor Name: </xsl:text> </TD> <TD> <xsl:text>Actor SSN: </xsl:text> </TD> <TD> <xsl:text>Actor Age: </xsl:text> </TD> </TR> <xsl:for-each select="actors"> <TR CLASS="salmonBackground"> <TD> <xsl:value-of select="actorName"/> </TD> <TD> <xsl:value-of select="actorSSN"/> </TD> <TD> <xsl:value-of select="actorAge"/> </TD> </TR> </xsl:for-each> </xsl:for-each> </TABLE> </xsl:template> </xsl:stylesheet>

More Related