3

How to read component link field using XSLT in tridion?

In a component there is a field called "abc" which is a component link field. In that component link, I have a component with fields "a", "b", "c". I need to retrieve the value from that a, b, c text fields.

5
  • take a look at yoavniran.wordpress.com/2009/07/11/… Mar 16 '15 at 10:28
  • what exactly do you mean with read? the field itself is an xlink element, so you can read its href attribute and find the TCMURI Mar 16 '15 at 10:28
  • In a component there is a field called "abc" which is a component link field, in that component link i have a component with fields "a", "b", "c" I need to retrieve the value from that a, b , c text fields.
    – saxena
    Mar 16 '15 at 10:33
  • @saxena, questions asked in a comment you can best answer by editing your original question, and supplying the answer there. That is better readable, since you have formatting options there too. When done, you can delete the comment, so it doesn't get messy. Right now your question is not very clear. which is not strange since it is only a single sentance and doesn't really explain what you are trying to do, so it can definitely benefit from editing and supplying more detailed information. Mar 16 '15 at 12:03
  • Additionally I'd suggest you put any examples of what you've tried (it could be you've tried the correct thing but there's a syntactical issue - or it could be you've gone down the wrong path and someone can redirect you). Mar 19 '15 at 9:32
2

If you are trying to read Component Link related text fields on XSLT Component Template.

You can perform as below,

<!-- Gets the Component Link Uri -->
<xsl:variable name="abcLink" select="/tcm:Component/tcm:Data/tcm:Content/ref:XYZ/ref:ABCLink/@xlink:href" />
<!-- Gets the Content of Link Component  -->
<xsl:variable name="abcLinkField" select="document($abcLink)/tcm:Component/tcm:Data/tcm:Content/ref:ABC" />
<!-- Prints "A" field related content -->
<xsl:value-of select="$abcLinkField/ref:AField/text()" />
<!-- Prints "B" field related content -->
<xsl:value-of select="$abcLinkField/ref:BField/text()" />
<!-- Prints "C" field related content -->
<xsl:value-of select="$abcLinkField/ref:CField/text()" />

Here document($abcLink) invokes the protocol handler to get the linked item through the URI specified, and from there onwards you can simply proceed as with any item

2
  • could be useful to add that document($abcLink) invokes the protocol handler to get the linked item through the URI specified, and from there onwards you can simply proceed as with any item. Mar 17 '15 at 15:10
  • @BartKoopman: Thanks Bart. I have added the information. Mar 18 '15 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.