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

Attribute value templates

Subject: Attribute value templates
From: Anders Kristensen <ak@xxxxxxxxxxxxxxx>
Date: Mon, 26 Oct 1998 19:09:46 +0000
attribute value templates

Suppose I have a document of the form

  <color name="red"   rgb="ff0000"/>
  <color name="green" rgb="00ff00"/>
  <color name="blue"  rgb="0000ff"/>

and I want to construct a document like:

  <circle bg="00ff00"/>

where the value of the 'bg' attribute is the value of the 'rgb'
attribute of the 'color' element with 'name' attribute having a value of
'green'.  I can do that with the stylesheet

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  <xsl:template match="example/color[attribute(name)='green']">
    <circle bg="{attribute(rgb)}"/>

but I was wondering if there is a more direct way. I'd like not to have
to first select the node I'm interested in and then select the value but
rather do both in one go. The problem is that I'm selecting the node on
one attribute while using the value of another. I was trying something

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  <xsl:template match="example">
    <col bg="{input[attribute(name)='green',attribute(rgb)]}"/>

but this produces the output

<col bg=""/>

My guess is that there is no way to do this. This probably doesn't even
matter - I'm just being curious.


Anders Kristensen <ak@xxxxxxxxxxxxxxx>,
Hewlett-Packard Labs, Bristol, UK

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.