You can use the current() function to get the XSLT context node from within an
XPath:
<xsl:value-of
select="$documentAppConfig/configuration/myNode/@*[local-name()=current()/text()]"
/>
Patrik
------------------------------------------------------------------
Systemarchitektur & IT-Projekte
Tel: +49 40 33449-1142
Fax: +49 40 33449-1400
E-Mail: mailto:Patrik(_dot_)Stellmann(_at_)gdv-dl(_dot_)de
-----Ursprüngliche Nachricht-----
Von: Joseph L. Casale jcasale(_at_)activenetwerx(_dot_)com [mailto:xsl-list-
service(_at_)lists(_dot_)mulberrytech(_dot_)com]
Gesendet: Mittwoch, 19. Juli 2017 01:53
An: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Betreff: [xsl] 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
GDV Dienstleistungs-GmbH
Glockengießerwall 1
D-20095 Hamburg
www.gdv-dl.de
Sitz und Registergericht: Hamburg
HRB 145291
USt.-IdNr : DE 205183123
Geschäftsführer:
Dr. Jens Bartenwerfer
Michael Bathke
Fred di Giuseppe Chiachiarella
Thomas Fischer
Aufsichtsratsvorsitzender: Werner Schmidt
------------------------------------------------------------------
Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich
geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte
Weitergabe der E-Mail ist nicht gestattet.
This e-mail and any attached files may contain confidential and/or privileged
information. If you are not the intended recipient (or have received this
e-mail in error) please notify the sender immediately and destroy this e-mail.
Any unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--