Subject: [xsl] table/matrix and xpath prob From: m.vanrootseler@xxxxxxxxx Date: Tue, 10 Feb 2004 19:46:09 +0100 |
I'm battling with the following problem. I have two xml-files; on one I'm doing the transformation and the other one is imported with document(). The structure of the first file is as follows: <variables> <variable> <word>X</word> <variants> <variant> <word>foo</word> <locations> <location>1</location> <location>7</location> <location>39</location> </locations> </variant> <variant> <word>oof</word> <locations> <location>2</location> <location>3</location> <location>78</location> </locations> </variant> etc. The second file looks like this: <locations> <location> <id>1</id> <placename>London</placename> </location> <location> <id>2</id> <placename>Tokyo</placename> </location> etc. I want to do a table in which all the placenames from the second file are listed, followed by columns for each variant (as many columns as there are variants) from the first file. So far so good. I want to fill the columns with cells with the location value from the first file but only where this number matches the id number from the locations list. If there's no match, the cell should remain empty. What I have so far (not working) is: <xsl:variable name="CurrentVariant" select="../variants/variant"/> <table border="1"> <tr> <td>place</td> <xsl:for-each select="../variants/variant"> <td> <xsl:value-of select="word"/> </td> </xsl:for-each> </tr> <xsl:for-each select="document('LGWLocations.xml')/locations/location"> <xsl:sort select="placename"/> <tr> <td> <xsl:value-of select="placename"/> </td> <xsl:for-each select="$CurrentVariant"> <td> <xsl:for-each select="locations/location[. = document('LGWLocations.xml')/locations/location/id]"> <xsl:value-of select="."/> </xsl:for-each> </td> </xsl:for-each> </tr> </xsl:for-each> </table> I can't get the xpath for the last for-each-set right. I know that I have to somehow match the location with the id from the imported file in order to get a matrix like this: placename foo oof London 1 - Tokyo - 2 etc. I'm using MSXML and IE6. Has anyone got any idea how this might be solved? Much appreciated. Mick XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Flatten XML to load into , bryan . s . schnabel | Thread | RE: [xsl] table/matrix and xpath pr, Américo Albuquerque |
Re: [xsl] xml to xml transformation, G. Ken Holman | Date | RE: [xsl] Flatten XML to load into , bryan . s . schnabel |
Month |