Subject: Re: [xsl] How to use xsl:key to get all values? From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Thu, 12 Apr 2001 18:11:41 +0100 |
Hi,
Based on the following XML and XSL file, I'd like to output "1" "2". But I just get "1" "1". Any body can tell me what is wrong with <xsl:key>
<xsl:variable name="child" select="key('key-name', 'a1')" />
<xsl:value-of select="$child/@value" />
It's unclear why you are using the key. Why not just: <xsl:for-each select="CC"> <xsl:value-of select="DD/EE/@value" /> </xsl:for-each>
Hope that helps, Wendell
<?xml version="1.0"?> <AA> <BB> <CC> <DD> <EE aField="a1" value="1"/> </DD> </CC> <CC> <DD> <EE aField="a1" value="2"/> </DD> </CC> </BB> </AA>
<?xml version="1.0"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/WD-xsl" version="1.0">
<xsl:output method="text"/> <xsl:key name="key-name" match="EE" use="@aField" /> <xsl:template match="AA/BB"> <xsl:for-each select="CC"> <xsl:variable name="child" select="key('key-name', 'a1')" /> <xsl:value-of select="$child/@value" /> </xsl:for-each> </xsl:template>
</xsl:transform>
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to use xsl:key to get all, Di Luo | Thread | RE: [xsl] How to use xsl:key to get, Di Luo |
[xsl] XPath unique ids, Dave Gomboc | Date | Re: [xsl] use of '>' and '<' in tes, Sarboday Misra |
Month |