Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8151295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:20:16+00:00 2026-06-06T15:20:16+00:00

I feel like I’m missing something obvious, but I can’t work out why my

  • 0

I feel like I’m missing something obvious, but I can’t work out why my XSLT 1.0 key is not working for me.

My desired output is “Sample Brand” (see comment in XSLT below), but nothing is output at all.

The testing I’ve done seems to indicate that the key isn’t being generated, as when I do a for-each using the key() function with some dummy output, nothing is output then either (it seems like there are 0 key items). But I’m not sure of this.

XML:

<data>
    <products-by-instances>
        <entry id="1975">
            <name>Sample Name</name>
            <brand>
                <item id="1970">Sample Brand</item>
            </brand>
            <instances>
                <item id="1972">MILT501</item>
                <item id="1974">MILT502</item>
            </instances>
        </entry>
    </products-by-instances>
    <shopping-cart items="2" total="35">
        <item id="1972" num="1" sum="5" />
        <item id="1974" num="3" sum="30" />
    </shopping-cart>
</data>

XSLT:

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

<xsl:key name="products-by-instance-id" match="/data/products-by-instances/entry" use="instances/item/@id"/>

<!-- other templates redacted for brevity; the below template is being applied -->

<xsl:template match="/data/shopping-cart/item">
    <xsl:value-of select="key(products-by-instance-id, @id)/brand/item"/>
    <!-- desired output is "Sample Brand" -->
</xsl:template>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:20:18+00:00Added an answer on June 6, 2026 at 3:20 pm

    It’s now been pointed out to me that I neglected to put the key name in quotes:

    <xsl:value-of select="key('products-by-instance-id', @id)/brand/item"/>
    

    Key now working as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like I'm missing something very obvious here, but I can't get a
I feel like I must be missing something completely obvious, but I don't see
I feel like I'm missing an obvious point here, but let's say I'm working
I feel like I'm missing something obvious... but does firebug interfere with cookie deletion?
I feel like this should be obvious, and perhaps I'm totally missing something, but
I feel like I'm missing something pretty basic, but I can't seem to figure
I feel like this is something I should already know, but I'm just not
I feel like this is easy but I am missing something... Using jQuery, I
I feel like this should be a no brainer, but clearly I'm missing something...
I feel like I am just missing a simple property, but can you set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.