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 4574138
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:52:56+00:00 2026-05-21T19:52:56+00:00

Fairly new to XSL – so please forgive noobishness. I have an input XML

  • 0

Fairly new to XSL – so please forgive noobishness.

I have an input XML document (this is actually the docbook form of the Jargon File, snipped significantly):

<?xml version="1.0" encoding="ISO-8859-1"?>
<glossary>
    <glossdiv id='glossdiv-0'>
        <title>0</title>            
        <glossentry id='dev-null'>
            <glossterm>/dev/null</glossterm>
            <glossdef>
                snip...
                <glossterm>bit bucket</glossterm>
            </glossdef>
        </glossentry>
        <glossentry id='me'>
            <glossterm>/me</glossterm>
            <glossdef>
                snip...
                <glossterm>/dev/null</glossterm>
            </glossdef>
        </glossentry>           
    </glossdiv>
</glossary>

This is the testing XSL I’ve been working with:

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

    <xsl:output indent="yes" xalan:indent-amount="5" />
    <xsl:template match="text()" />

    <xsl:key name="glossterm-lookup-key" match="glossentry/@id" use="glossentry/glossterm" />

    <xsl:template match="glossary" >
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="glossterm">
        Key: <xsl:value-of select="." />
        Value: <xsl:value-of select="key('glossterm-lookup-key', .)" />
        <xsl:text>
        </xsl:text>
    </xsl:template>
</xsl:stylesheet>

My objective, is that whenever I come across a <glossterm> element, I’d like to lookup the glossentry/@id given the glossterm/text(). So, for example, if I find a <glossterm>/dev/null</glossterm>, I’d like to get dev-null.

I’m only really interested in glossterms in a glossdef, but I have working xsl:templates for all that stuff – for the sake of testing I’ve just been working on all glossterms.

I have tried creating a separate lookup document and using the approach described at XML.com: Reading Multiple Input Documents but had no luck with that.

Any hints?

  • 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-05-21T19:52:56+00:00Added an answer on May 21, 2026 at 7:52 pm

    It’s a little hard to tell from your description but I think you want this

    <xsl:key name="glossterm-lookup-key" match="glossentry/glossterm" use="text()" />
    

    This creates an index of glossentry/glossterm nodes keyed on the text of the child glossterm. The reference is then:

    <xsl:value-of select="key('glossterm-lookup-key', .)/../@id" />
    

    This uses the current context node’s text to search the index and returns the @id of the parent.

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

Sidebar

Related Questions

Fairly new to python, forgive me if this is a basic question about learning
Im fairly new to c sorry if this is a stupid question! i have
Im completely new to XML/XSL/XSLT, and while i have been digging msdn, 3schools.com and
still fairly new to ruby, and wrote this very simple recursive function. def test(input)
I am new to fairly new to AS3 and I have found myself needing
I am fairly new to C++ and I have seen a bunch of code
I am fairly new to Rails and I have never developed a large application.
Being fairly new to C++ I have a question bascially concerning the g++ compiler
im fairly new to databases in vb.net and i have just learned how to
Being fairly new to iPhone / Objective-C development, I wanted to ask this question

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.