Re: [xsl] Indirect referencing in XSLT/XPath?

Subject: Re: [xsl] Indirect referencing in XSLT/XPath?
From: "Peter Flynn peter@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 5 Apr 2025 17:49:05 -0000
On 05/04/2025 15:35, Roger L Costello costello@xxxxxxxxx wrote:

Is there any way to do indirect referencing in XSLT/XPath?

The following returns the value "this". Is that the kind of thing you meant?

Peter

======================== test.xml
<test>
  <thing xml:id="foo" ref="blort">
    <another xml:id="bar" ref="stuff"/>
  </thing>
  <yetmore xml:id="blort" ref="bar">
    <something ref="foo"/>
  </yetmore>
  <else xml:id="stuff" value="this"/>
</test>

======================== test.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="3.0">

<xsl:output method="text"/>

  <xsl:template match="something">
    <xsl:apply-templates
      select="id(@ref)/id(@ref)/id(@ref)/id(@ref)/@value"/>
  </xsl:template>

</xsl:stylesheet>

Current Thread