Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 1st, 2009, 11:28 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default Processing XSL Keys

Hi, I am having some fundamental problems with processing the following key. Here is a example:
Stylesheet:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="text"/>
    <xsl:key name="wp-name-key" match="wp" use="@id"/>
    <xsl:template match="/">
        <xsl:for-each select="//xref">
            <xsl:value-of select="key('wp-name-key', @href)/@name"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>
XML
Code:
<root>
    <wp id="A1234" name="test"/>
    <xref href="image1.png"/> 
</root>
Why is it that I have no output result?

Thanks,
 
Old May 1st, 2009, 11:47 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Well you have a single 'xref' element where the 'href' attribute has the value 'image1.png'. If you pass that value to the key function it returns an empty node-set as the only 'wp' element has an 'id' attribute with value 'A1234' and not 'image1.png'.

I am not sure what you want to achieve, you would need an <xref href="A1234"/> element, then key('wp-name-key', @href)/@name would give you 'test'.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old May 1st, 2009, 12:00 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Thank you very much





Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional processing in XSL francislang XSLT 2 March 18th, 2008 12:04 AM
When to define primary keys and foregin keys? method SQL Server 2000 1 August 26th, 2005 09:14 AM
XSL processing question.. eladner XSLT 1 August 24th, 2004 07:58 AM
Create processing instruction in XSL hbcontract XML 6 May 7th, 2004 12:14 PM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.