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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:34:50+00:00 2026-06-02T22:34:50+00:00

I am parsing an XSL file with XSL. And I have a problem dynamically

  • 0

I am parsing an XSL file with XSL. And I have a problem dynamically finding nodes in it. Here is the scenario:

<linkbase xmlns="http://www.xbrl.org/2003/linkbase"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xsi:schemaLocation="http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd">
    <labelLink xmlns:xlink="http://www.w3.org/1999/xlink" 
                xlink:role="http://www.xbrl.org/2003/role/link" 
                xlink:type="extended">
        <loc xlink:type="locator" 
                    xlink:href="de-gaap-ci-2010-12-16.xsd#de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other" 
                    xlink:label="de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other"/>

        <!-- many <loc... elements -->

        <labelArc xlink:from="de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other"
                xlink:to="label_de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other" 
                priority="1" 
                xlink:arcrole="http://www.xbrl.org/2003/arcrole/concept-label"
                xlink:type="arc"/>

        <!-- many <labelArc... elements -->

     </labelLink>
</linkbase>

I am parsing the labelArc elements and want to include the information from the loc elements. This is done with SAP/ABAP…

My XSL code looks as follows:

<xsl:stylesheet version="1.0"
 xmlns:lb="http://www.xbrl.org/2003/linkbase"
 xmlns:xlink="http://www.w3.org/1999/xlink">

    <xsl:template match="lb:labelArc">
        <xsl:variable name="arc_to" select="@xlink:to"/>

      <TY_T_LABELARC>
        <LOC>  <xsl:value-of select="//lb:loc[@xlink:label='$arc_to']/@xlink:href"/> </LOC>
        <FROM> <xsl:value-of select="@xlink:from"/> </FROM>
        <TO>   <xsl:value-of select="@xlink:to"/> </TO>
        <!-- Other values follow -->
      </TY_T_LABELARC>

    </xsl:template>

I expect this result:

<TY_T_LABELARC>
   <LOC>de-gaap-ci-2010-12-16.xsd#de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other</LOC>
   <FROM>de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other</FROM>
   <TO>label_de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other</TO>
</TY_T_LABELARC>

My problem is that it’s all okay except the element LOC which has an empty value (<LOC/>).

It means this xpath expression returns an empty value:

<xsl:value-of select="//lb:loc[@label='$arc_to']/@href"/>

The goal of this statement is to get the attribute href from the element loc. I can find the corresponding loc tag with the value of @to of each labelArc tag.

I tried it both with the leading namespace “xlink:” on each attribute and without it…

Any ideas?

  • 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-02T22:34:52+00:00Added an answer on June 2, 2026 at 10:34 pm

    There are two issues with your code:

    Firstly:

        <xsl:variable name="arc_to"       
           select="@xlink:to"/>
    

    Do notice that the value of the attribute xlink:to of the element labelArc starts with the string "label_" — and the xlink:label attribute of loc doesn’t start with this string.

    So you should write:

        <xsl:variable name="arc_to"
          select="substring-after(@xlink:to, 'label_')"/>
    

    Secondly:

        <xsl:value-of select="//lb:loc[@xlink:label='$arc_to']/@xlink:href"/>
    

    this compares @xlink:label to the string "$arc_to" — not to the variable $arc_to.

    So you should write:

        <xsl:value-of select="//lb:loc[@xlink:label= $arc_to]/@xlink:href"/>
    

    The corrected code:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:lb="http://www.xbrl.org/2003/linkbase"
     xmlns:xlink="http://www.w3.org/1999/xlink"
      exclude-result-prefixes="lb xlink">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="lb:labelArc">
        <xsl:variable name="arc_to"
          select="substring-after(@xlink:to, 'label_')"/>
    
      <TY_T_LABELARC>
        <LOC>  <xsl:value-of select="//lb:loc[@xlink:label= $arc_to]/@xlink:href"/> </LOC>
        <FROM> <xsl:value-of select="@xlink:from"/> </FROM>
        <TO>   <xsl:value-of select="@xlink:to"/> </TO>
        <!-- Other values follow -->
      </TY_T_LABELARC>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied to the provided XML document:

    <linkbase
      xmlns="http://www.xbrl.org/2003/linkbase"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd">
      <labelLink xmlns:xlink="http://www.w3.org/1999/xlink"
                 xlink:role="http://www.xbrl.org/2003/role/link"
                 xlink:type="extended">
        <loc xlink:type="locator"
             xlink:href="de-gaap-ci-2010-12-16.xsd#de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other"
             xlink:label="de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other"/>
    
                <!-- many <loc... elements -->
    
       <labelArc priority="1" xlink:type="arc"
         xlink:from="de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other"
         xlink:to="label_de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other"
         xlink:arcrole="http://www.xbrl.org/2003/arcrole/concept-label" />
    
                <!-- many <labelArc... elements -->
    
     </labelLink>
    </linkbase>
    

    the wanted, correct result is produced:

    <TY_T_LABELARC>
       <LOC>de-gaap-ci-2010-12-16.xsd#de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other</LOC>
       <FROM>de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other</FROM>
       <TO>label_de-gaap-ci_bs.ass.fixAss.fin.otherLoans.other</TO>
    </TY_T_LABELARC>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is an example of the XQuery output that I get: <clinic> <Name xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance>Healthy
I'm parsing a huge word file with Test descriptions, and have a problem of
For example: <doc xmlns=http://www.foo.org> <div id> <title>Mr. Title</title> <paragraph>This is one paragraph.</paragraph> </div> </doc>
I have a value I am parsing from an xml file that I need
I am parsing itunes library XML file using xslt grammar. Here's sample code void
Parsing a text file in vb.net and need to locate the latitude and longitude
Im parsing an xml file. My XML handler, my object that holds an Arraylist
After parsing a json file which contains names and ages of people, {People: [
When parsing an xml file in android, I'm doing like this: try { InputStream
Using an Document DTD I did the following: file.xsl: <!DOCTYPE xsl:stylesheet[ <!ENTITY red rgb(255,0,0)>

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.