This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Lookup in a xml file with a key


Hi,

Here is my problem :
I have this xml file :
<in>
	<country>010</country>
	<country>020</country>
</in>

and with this other xml file that describe a table, I named the file
"lookup.xml" :
<?xml version="1.0"?>
<lookup>
	<countrydef>
		<abbr>010</abbr>
		<name>Germany</name>
	</countrydef>
	<countrydef>
		<abbr>020</abbr>
		<name>France</name>
	</countrydef>
</lookup>

I would like to output the following :
<out>
Germany
France
</out>

I can't manage to get my xslt to work, here is the current version of it :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output indent="yes" omit-xml-declaration="yes"/>
  <xsl:key name="kLookup" match="abbr" use="name"/>

  <xsl:template match="/">
    <in>
      <xsl:apply-templates select="in/country"/>
    </in>
  </xsl:template>

<xsl:template match="in/country">
    <xsl:variable name="input" select="."/>
     <xsl:for-each select="document('c:/gaston/lookup.xml')">
        <xsl:for-each select="key('kLookup',name($input))">
            <xsl:value-of select="."/>
        </xsl:for-each>
     </xsl:for-each>
</xsl:template>
</xsl:stylesheet>


If someone could help me with that, I'm totaly lost !!

Thanks, Gaston.

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]