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

Using the key function

Subject: Using the key function
From: "Fanghanel, Karl" <Karl.Fanghanel@xxxxxxxxx>
Date: Tue, 22 May 2007 16:18:53 -0400
 Using the key function
Hello All,

I'm working on a problem which I thought could be solved by using the
key function however it's not working as I thought.

I'm using the group-by function to gather most of my required
information except for a length attribute which is under a different
element.  I figured I could use the key function to acquire this other
value, but it doesn't work.

I'm thinking that either my select statement is wrong or maybe my key
isn't right.  Could someone please provided some insight of what I may
be doing wrong?

Below is a snippet of my xsl and xml data I'm using.  I'm using saxon8.

Thank you,
Karl

--- XSL ---
-------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

<xsl:output method="html"/>

<xsl:key name="numkey" match="//house" use="member/@ref"/>

<xsl:for-each-group select="//*"
group-by="property[@name='number']/@val">
<xsl:sort select="@number"/>
	<tr>
		<td>
			<xsl:value-of select="current-grouping-key()"/>
		</td>
		<td>
			<xsl:value-of
select="key('numkey',@id)/@length"/>
		</td>
	</tr>
</xsl:for-each-group>



--- XML Data ---
-------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<project>
	<trail> id="1234" length="50.5" </trail>
	<trail> id="9876" length="40.0" </trail>
	<house>
		<member> ref="1234" </member>
		<property> name="number" val="123L0001" </property>
	</house>
	<house>
		<member> ref="9876" </member>
		<property> name="number" val="123L0002" </property>
	</house>
</project>

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.