Skip to content

Tasks

  1. 200SimpleElements: For the following elements write their simple elements definitions.

    <city>Roma</city>
    <birthday>1996-12-18</birthday>
    <time>18:29:45</time>
    <mark>7.5</mark>
    <pass>true</pass>
    
  2. 201Fruits.xsd: Given the following XML document

    <?xml version="1.0" encoding="UTF-8"?>
    <fruits>
        <item>
            <id>1000</id>
            <name>Apple</name>
            <price>4</price>
            <quantity>133</quantity>
        </item> 
        <item>
            <id>1001</id>
            <name>Apricot</name>
            <price>5</price>
            <quantity>175</quantity>
        </item> 
    </fruits>
    
    Create an XSD document to validate it. After that add some fruits and validate again.

    After that, modify the XSD file taking into account that the price must be greater than 0 and quantity musn't be negative.

  3. 202Catalog.xsd: Given the following XML document

<catalog>
  <cd>
    <title>Empire Burlesque</title>
    <artist>Bob Dylan</artist>        
    <price>10.90</price>      
    <date>1985-05-01</date>
    <details>
      <company>Columbia</company>
      <country>USA</country>
    </details>
  </cd>
  <cd>
    <title>Hide your heart</title>
    <artist>Bonnie Tyler</artist>
    <price>9.90</price>
    <date>1988-06-20</date>
    <details>
      <company>CBS Records</company>
      <country>UK</country>
    </details>      
  </cd> 
  <cd>
    <title>Still got the blues</title>
    <artist>Gary Moore</artist>
    <price>10.20</price>
    <date>1990-12-10</date>
    <details>
      <company>RCA</company>
      <country>USA</country>
    </details>
  </cd>
</catalog>
Create an XSD document to validate it. After that add some cd and validate again.

Next, modify the XSD file taking into account that the price must be greater than 0 and the date cannot be earlier than 1 January 1970.

  1. 203Card.xsd: Given the following XML document

    <?xml version="1.0" encoding="UTF-8"?>
    <cards xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="203Cards.xsd">
        <card number="1">
            <name>Ana Sanz Tin</name>
            <age>22</age>
        </card>
        <card number="2">
            <name>Iker Rubio Mol</name>
            <age>23</age>
        </card>
    </cards>
    
    Create the 202Cards.xsd file in order to validate it.

  2. 203Card.xsd: Modify the previous task by adding 3 restrictions:

    1. age element must be greather than or equal to 18 amb less than 100.
    2. name element can only contain alphabetic characters.
    3. number attribute must only contain positive integers.
  3. 204Recipes.xml: Given the following XSD file, create a valid XML document with at least two recipes.

    <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="recipes">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="recipe" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="name" type="xs:string" />
                    <xs:element name="photo" type="xs:string" minOccurs="0" />
                    <xs:element name="ingredients">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="ingredient" maxOccurs="unbounded" type="xs:string" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="method">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="step" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="xs:string">
                                  <xs:attribute name="number" type="xs:integer" use="required" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:schema>
    
  4. 206Prices.xsd: Triple-digit prices

    Given the following XML document:

    <?xml version="1.0" encoding = "UTF-8"?>
    <prices xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="prices.xsd">
        <price>8</price>
        <price>2.6</price>
        <price>4.95</price>
        <price>187</price>
    </prices>
    
    Write the content of the "prices.xsd" file to validate it, bearing in mind that the "price" element can take as a value a number that contains a maximum of three digits and, of these, only two can be decimals. To do this, write a restriction that cannot be used by other elements and, on the other hand, make use of:

    • xs:totalDigits used to specify the maximum number of digits that a number can have, including decimals.
    • xs:fractionDigits used to specify the maximum number of decimal places that a number can have.
  5. 207Players.xsd. Given the following XML document:

    <?xml version="1.0" encoding = "UTF-8"?>
    <players xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="206Players.xsd">
        <player preferred_number="7">
            <name nickname="the bug">Cristiano Ronaldo</name>
            <postion>Left wing</postion>
            <community />
        </player>
    
        <player preferred_number="9">
            <name nickname="the bull">Maxi Gómez</name>
            <postion>Striker</postion>  
        </player>
    
        <player preferred_number="10">
            <name nickname="the flea">Lionel Messi</name>
            <postion>Right wing</postion>
            <community />
        </player>
        <player preferred_number="8">
            <name>Carlos Soler</name>
            <postion>Right midfielder</postion>
            <community />
        </player>
    </players>    
    

    Write an XSD file to validate it. After that, add 2 new records.

    In addition, you can define the position element as a choice element in order to control the correctness of positions. You can find the name of positions in English at Soccer Positions: The Numbers, Player Roles & Basic Formations

  6. 208people.xsd: Given the following XSD file "people.xsd".

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="people">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="person" maxOccurs="unbounded">
                        <xs:complexType mixed="true">
                            <xs:sequence>
                                <xs:element name="name" type="xs:string"/>
                                <xs:element name="city" type="xs:string"/>
                                <xs:element name="age" type="xs:positiveInteger"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:schema>
    
    Using the elements "name", "city" and "age", write a XML document that can be validate by "people.xsd" and that storages the following information:

    • "Eva lives in Paris and she is 25 years old."
    • "Giovanni lives in Florence and he is 26 years old."

Content syndication

  1. Using a RSS aggregator

    In the next task we will install an RSS aggregator and subscribe to some channels.

    1. Install the Firefox add-on: Feedbro.
    2. Access the add-on.
    3. Subscribe to the following channels:
      1. The podcasts of the 24h24l.org event.
      2. The latest news from El País
      3. The front page news of El Mundo.
      4. Check if any of the pages you consult regularly redistribute their contents. If so, subscribe to their channel.
  2. 222rssfeed.xml. Creating an RSS feed

    You were the creator of the web recipe-example.org and you currently have in the main page the following content.

    <!DOCTYPE html>
    <html lang = "ca">
    <head>
      <meta charset = "UTF-8">
      <meta name = "viewport" content = "width = device-width, initial-scale = 1.0">
      <title>Recipes</title>
    </head>
    
    <body>
    <header>
      <h1>Sample recipes </h1>
    </header>
    <main>
    <article>
      <h2>Baked rice</h2>
      <time datetime = "2020-12-13 08:00:00"> Sunday, December 13
        2020 </time>
      <p> The peculiarity of this rice, as the name suggests, is
        which is baked. I,
        like paella and other Valencian rice dishes, it is also a
        dish of popular origin, which in this case was made from
        of the remains of the putxero. That's why among his
        Ingredients are not missing chickpeas, pork chops and
        sausage. This dish is especially typical in counties such as
        la Costera, where it has been celebrated in Xàtiva for a long time
        a few years the National Baked Rice Contest. </p>
      <p> <a href="/2020/12/arros-al-forn.html"> Continue reading </a> </p>
    </article>
    <article>
      <h2>Paella valenciana</h2>
      <time datetime="2020-04-06 13:20:00"> Monday, April 6,
       2020 </time>
      <p> The paella is the highest standard of Valencian cuisine and
      probably also of the Spanish, due to its recognition
      gastronomy worldwide. Its origin, like that of all
      dishes of popular cuisine, derived from the conjunction of foods that
      each family had at their disposal, especially in the area of
      the orchard of Valencia, which was supplied with fresh vegetables.
      In addition, it was formerly customary to raise chickens and rabbits for
      to family use, therefore, if we add abundance to all this
      of the rice cultivated in the Albufera, the result is this
      genuinely Valencian dish that receives the name of the container in the
      which is cooked. </p>
      <p><a href="/2020/04/paella-valenciana.html"> Continue reading </a> </p>
    </article>
    <article>
      <h2>Olleta</h2>
      <time datetime = "2019-12-28 18:20:00"> Friday, December 28
      2019 </time>
      <p> L'olleta is the most representative dish in the mountain area
      of Alicante and in the interior of Valencia. This is a succulent putxero,
      similar to a broth stew but one of the most refined in all of Spain,
      and for this reason it is recognized nationally. Its intense flavor
      and fragrant derives from the aromatic fragrance of the sausages and,
      once degreased, it reaches a sublime point. </p>
      <p> <a href="/2019/12/olleta.html"> Continue reading </a> </p>
    </article>
    </main>
      <footer>
      </footer>
      </body>
    </html>
    
    Create the RSS feed in version 2.0 so that users know when you post new recipes.

    Validate the file.

  3. 223Ivoox. Given the following IVOOX screenshot create by hand in your notebook an RSS feed that announces the three podcast episodes.