Article View: fr.comp.text.xml
Article #144Re: Xslt avec une seconde base xml
From: Marc
Date: Tue, 05 Jan 2010 07:09
Date: Tue, 05 Jan 2010 07:09
64 lines
3216 bytes
3216 bytes
Bonjour,
Voici ce que je ferais (non test�)
<xsl:variable name="CitiesFile" select="document('Cities.xml')/>
<xsl:template match='Locations'>
<xsl:for-each select='Location'>
<xsl:value-of select="ZipCode" />
<xsl:variable name="CityId" select="CityId"/>
<xsl:variable name="City" select="$CitiesFile//City[@CityId=$CityId]" />
<xsl:value-of select="$City" />
</xsl:for-each>
</xsl:template>
Es tu sur que tu as besoin d'un for-each, un template n'est suffisant?
Marc
Le 04/01/2010 18:44, CrazyCat a �crit :
> Bonjour � tous, et meilleurs voeux !
>
> Je dois faire une transformation XSL sur un fichier (jusque l� pas de
> probl�me), et ce fichier contient des identifiants qui doivent me
> permettre de retrouver des libell�s pr�sents dans un autre fichier XML.
>
> Mon probl�me est que je ne vois pas trop comment faire. J'ai suivi une
> piste qui m'am�nerait � faire:
>
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" encoding="utf-8" indent="yes" />
> <xsl:strip-space elements="*" />
> <!-- Only make xml file if it's an agency which is a client -->
> <!-- Parsing the xml file -->
> <xsl:template match='Locations'>
> <xsl:for-each select='Location'>
> <xsl:value-of select="ZipCode" /> :
> <xsl:variable name="CityId" select="document('/home/user/Cities.xml',
> /CityId)" />
> <xsl:value-of select="$CityId/@CityId" />
> </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>
>
> Mon fichier initial est de la forme:
> <?xml version="1.0" encoding="utf-8"?>
> <root>
> <Locations>
> <Location>
> <Address>Une adresse</Address>
> <ZipCode>75000</ZipCode>
> <CityId>1</CityId>
> </Location>
> </Locations>
> </root>
>
> Et mon fichier Cities.xml de la forme:
> <Cities>
> <City CityId="1">Paris</City>
> <City CityId="2">Lyon</City>
> </Cities>
>
> Cette solution ne semble pas marcher, quelqu'un aurait-il une id�e ?
>
> Merci d'avance.
Technical Details
Message-ID:
<4b42e5a3$0$2707$426a74cc@news.free.fr>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!212.27.60.64.MISMATCH!cleanfeed3-b.proxad.net!nnrp14-2.free.fr!not-for-mailReferences:
<hht9da$692$1@speranza.aioe.org>Show Full Headers
Complete Article Headers
X-Google-Thread: 8a75585569,ea8c1daf85e4d2b6 X-Google-Attributes: gid8a75585569,public,usenet X-Google-NewGroupId: yes X-Google-Language: FRENCH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!212.27.60.64.MISMATCH!cleanfeed3-b.proxad.net!nnrp14-2.free.fr!not-for-mail Date: Tue, 05 Jan 2010 08:09:10 +0100 From: Marc <dum.dum@dum.fr> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 MIME-Version: 1.0 Newsgroups: fr.comp.text.xml Subject: Re: Xslt avec une seconde base xml References: <hht9da$692$1@speranza.aioe.org> In-Reply-To: <hht9da$692$1@speranza.aioe.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Antivirus: avast! (VPS 100104-0, 04/01/2010), Outbound message X-Antivirus-Status: Clean Lines: 64 Message-ID: <4b42e5a3$0$2707$426a74cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 05 Jan 2010 08:09:23 MET NNTP-Posting-Host: 88.174.81.36 X-Trace: 1262675363 news-2.free.fr 2707 88.174.81.36:1493 X-Complaints-To: abuse@proxad.net