[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

table/matrix and xpath prob

Subject: table/matrix and xpath prob
From: m.vanrootseler@xxxxxxxxx
Date: Tue, 10 Feb 2004 19:46:09 +0100
table matrix
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.