[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Fetching the value of a dynamically assigned attribute

Subject: Fetching the value of a dynamically assigned attribute
From: "Joseph L. Casale jcasale@xxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 18 Jul 2017 23:52:10 -0000
 Fetching the value of a dynamically assigned attribute
While mocking up some examples related to a previous question,
I have an example where I add a namespace to my stylesheet and
add some data to it:

  <myns:data>
    <foo>
      <bar>one</bar>
      <bar>two</bar>
      <bar>three</bar>
    </foo>
  </myns:data>

I also load another XML doc I am using data from:

  <xsl:variable name="documentAppConfig"
select="document('some_binary.exe.config')" />

While looping over the elements from the data I added to my stylesheet, I
am trying to select the value of an attribute where the attribute name is
dynamically specified:

    <xsl:for-each select="document('')/xsl:stylesheet/myns:data/foo/bar">

        <!-- this works: -->
        <xsl:value-of select="concat('some-text', text())" />

        <!-- this does not work: -->
        <xsl:value-of
select="$documentAppConfig/configuration/myNode/@*[local-name()=text()]" />

        <!-- this works: -->
        <xsl:variable name="text" select="text()" />
        <xsl:value-of
select="$documentAppConfig/configuration/myNode/@*[local-name()=$text]" />

    </xsl:for-each>

That result is not surprising, but what is the syntactically correct
way of accomplishing this, or is the intermediate assignment the only
way?

Thanks,
jlc

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.