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

  • Home
  • SEARCH
  • 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 8646185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:44:20+00:00 2026-06-12T12:44:20+00:00

I am working on the XSLT TBB (using the XSLT Mediator on Tridion 2011

  • 0

I am working on the XSLT TBB (using the XSLT Mediator on Tridion 2011 SP1) to retrieve the key Value from the Keyword.

My Keyword looks like this.

Value: Some Value   
Key: Its ID is 123

It’s a normal Keyword.

I have created a schema with a field. The values will be selected from List and from Category.

The component Source looks like this:
This is the Component source directly taken from the component of Tridion UI.

<Content xmlns="Some Name space">
    <keywordlink xlink:href="tcm:202-9737-1024" xlink:title="Some Value"
        xmlns:xlink="http://www.w3.org/1999/xlink">Some Value</keywordlink>
</Content>

When I observed the tcm:Component source from template builder, I observed that there are no attributes present for the field.

  <Content xmlns="Some Name space">
    <keywordlink>Some Value</keywordlink>
  </Content>

I want to retrieve the Key value of the keyword.

I wrote a XSLT TBB like this. I am using XSLT mediator to execute XSLT TBBs.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:simple="Some Name space"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:tcm="http://www.tridion.com/ContentManager/5.0"
  xmlns:xh="http://www.w3.org/1999/xhtml" 
  xmlns:i="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:transform-ext="urn:tridion:transform-ext" 
  xmlns="http://www.w3.org/1999/xhtml" 
  exclude-result-prefixes="#default simple xh">

    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />

    <xsl:template match="/">
        <xsl:apply-templates 
            select="tcm:Component/tcm:Data/tcm:Content/simple:Content" />
    </xsl:template>

    <xsl:template match="simple:Content">
        <xsl:value-of  select="simple:keywordlink/@*"/>
        <xsl:value-of select=document(simple:keywordlink/@xlink:href)/>
    </xsl:template>
<xsl:stylesheet>

I am getting blank output. I want to get the key value of a keyword.

I am getting blank output because in tcm:Component XML, there are no attributes.

I am not sure how can I navigate to that keyword.

I should retrieve the value of Key i.e. “Its ID is 123”.

Can any one help how to do this?

  • 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-12T12:44:21+00:00Added an answer on June 12, 2026 at 12:44 pm

    It seems it’s impossible to get an xlink:href to the referred keyword in a Keyword field using just the XSLT Mediator.

    To overcome this I created a .NET compound that “inflates” the extra keyword info in the XML. You’ll have to place this compound just before the XSLT compound.

    Code:

    namespace ContentManagement.TBB.Templates
    {
       [TcmTemplateTitle("Inflate Keyword Info")]
        public class GetExtendedComponent : TemplateBase
        {
           public override void Transform(Engine engine, Package package)
           {
               Initialize(engine, package);
    
               Component component = GetComponent();
               XmlElement componentXml = component.ToXml();
    
               XmlNamespaceManager ns = new XmlNamespaceManager(componentXml.OwnerDocument.NameTable);
               ns.AddNamespace("ns", component.Schema.NamespaceUri);
    
               ItemFields fields = new ItemFields(component.Content, component.Schema);
               InflateKeywords(fields, (XmlElement)componentXml.SelectSingleNode(String.Format("//ns:{0}", component.Schema.RootElementName), ns));
    
               ItemFields metaFields = new ItemFields(component.Metadata, component.MetadataSchema);
               InflateKeywords(metaFields, (XmlElement)componentXml.SelectSingleNode("//ns:Metadata", ns));
    
               Item xmlItem = package.CreateStringItem(ContentType.Component, componentXml.OuterXml);
               package.Remove(package.GetByName(Package.ComponentName));
               package.PushItem(Package.ComponentName, xmlItem);
           }
    
           private void InflateKeywords(ItemFields fields, XmlElement element)
           {
               XmlNamespaceManager ns = new XmlNamespaceManager(element.OwnerDocument.NameTable);
               ns.AddNamespace("ns", element.NamespaceURI);
               Logger.Debug("NS: " + element.NamespaceURI);
               foreach (ItemField field in fields)
               {
                   if (field is KeywordField)
                   {
                       KeywordField keywordField = (KeywordField)field;
    
                       XmlNodeList nodes = element.SelectNodes(String.Format("./ns:{0}", keywordField.Name), ns);
                       foreach (XmlNode node in nodes)
                       {
                           XmlElement kwelement = (XmlElement)node;
    
                           Logger.Debug(String.Format("Keyword titel: {0}", keywordField.Value.Title));
                           Logger.Debug(String.Format("Keyword Element Value: {0}", kwelement.InnerText));
    
                           kwelement.SetAttribute("href", "http://www.w3.org/1999/xlink", keywordField.Values.First(v => v.Title.Equals(kwelement.InnerText)).Id);
                           kwelement.SetAttribute("type", "http://www.w3.org/1999/xlink", "simple");
                           kwelement.SetAttribute("title", "http://www.w3.org/1999/xlink", kwelement.InnerText);
                       }
                   }
                   else if (field is EmbeddedSchemaField)
                   {
                       EmbeddedSchemaField embedField = (EmbeddedSchemaField)field;
    
                       XmlNodeList nodes = element.SelectNodes(String.Format("./ns:{0}", embedField.Name), ns);
                       int i = 0; 
                       foreach (XmlNode node in nodes)
                       {
                           XmlElement embedElement = (XmlElement)node;
                           InflateKeywords(embedField.Values[i], embedElement);
                           i++;
                       }
                   }
    
               }
           }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an XSLT TBB in Tridion 2011 SP1, using the XSLT
I am working on SDL Tridion 2011 SP1 with the XSLT Mediator from SDL
I am working on a XSLT Template Building Blocks in SDL Tridion 2011 SP1
I am working XSLT where the source looks like this. Source: <Data> <AB>all</AB> <AB>all2</AB>
I'd like to get a real XSLT processor working with erlang. Which would be
I am working on this from xslt cookbook type my.xml <?xml version=1.0 encoding=UTF-8?> <people>
I'm working at a java application that performs some xslt transformation. I would like
I am trying to learn xslt and i am working an xml which looks
Ok, I'm working through some simple tutorials from here: http://www.cch.kcl.ac.uk/legacy/teaching/7aavdh06/xslt/html/module_06.html The first exercise involves
I'm working on a project that involves XSLT. And would like to use a

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.