For my exam in my class where we learned about things relating to XML, DTD, XSD, XSL, we were asked to create an XSLT that would extract from a document XML only the parks within the town of Saint-Malo and then turn the results into an XML document. My results were almost correct, but not quite. It's too late to change my grade, but I'm just really curious on how to do this.
Here's a snipit of the original XML:
<entry>
<id>https://www2.mgcloud.fr/dataserver/tourismebretagne/data/jardins35fr('PCUBRE0351000100')</id>
<title type="text">'PCUBRE0351000100'</title>
<updated>2015-05-25T06:18:05Z</updated>
<author>
<name>https://www2.mgcloud.fr/dataserver/tourismebretagne/catalog/agents/17692</name>
</author>
<link rel="edit" title="jardins35frType" href="jardins35fr('PCUBRE0351000100')"/>
<category term="fr.mgdis.odata.data.jardins35frType" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<content type="parc">
<properties>
<num_id>PCUBRE0351000100</num_id>
<titre>Le Domaine de la Briantais</titre>
<theme>Parc</theme>
<telephone>02 99 81 83 42</telephone>
<fax>02 99 82 51 56</fax>
<web>www.ville-saint-malo.fr</web>
<mail>deep@saint-malo.fr</mail>
<adresse>Rue Maurice Nogues</adresse>
<code_postal>35400</code_postal>
<insee>35288</insee>
<commune>Saint-Malo</commune>
<latitude>48.6194348</latitude>
<longitude>-2.0147895</longitude>
<pmr>Oui</pmr>
<descriptif>Le Château a été construit à partir de 1864, en remplacement d'un vieux manoir du XVIIème siècle qui appartenait à de notables armateurs malouins. La famille La Chambre en devient propriétaire en 1888. Il est entouré d'un parc de 27 hectares surplombant la Tour Solidor, et la vallée de la Rance. Parc ouvert de 9h à 19h en juillet et août. Ouvert de 14h à 17h ou 18h en semaine hors saison, et de 9h à 17h ou 19h les week-ends et jours fériés toujours en basse saison. Parc avec vues sur mer. Renseignements : ville de Saint Malo - Direction de l'Environnement et de l'Espace Public - Division des Espaces verts. 02 99 81 83 42 pour tout renseignement complémentaire.</descriptif>
<photos>http://cdt29.media.tourinsoft.com/upload/4CECC4CF-0833-47A8-9B65-762C434CC0D0/Dinard-vu-de-la-Briantais.jpg</photos>
</properties>
</content>
</entry>
Here's the XSLT I wrote:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="4.0" indent="yes"/>
<xsl:template match="/">
<parcs_et_jardins_de_Saint_Malo>
<xsl:for-each select="//properties[commune='Saint-Malo']">
<titre><xsl:value-of select="//titre"/></titre>
</xsl:for-each>
</parcs_et_jardins_de_Saint_Malo>
</xsl:template>
</xsl:stylesheet>
Here's what I had for the resulting XML document:
<?xml version="4.0"?>
<parcs_et_jardins_de_Saint_Malo>
<titre>Parc Oberthur</titre>
<titre>Parc Oberthur</titre>
<titre>Parc Oberthur</titre>
<titre>Parc Oberthur</titre>
<titre>Parc Oberthur</titre>
<titre>Parc Oberthur</titre>
<titre>Parc Oberthur</titre>
</parcs_et_jardins_de_Saint_Malo>
Obviously it didn't work for me, but I cannot understand why. The problem is is that the element "commune" can have other towns in it and we didn't want to bring those results into play -- only the ones with Saint-Malo. My XSLT generated the same town over and over -- though the number of elements is the correct number (there are as many elements "titre" as there are mentions of Saint-Malo).
I'd appreciate the help and hope this isn't too confusing.