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

Re: Attribute value templates

Subject: Re: Attribute value templates
From: Anders Kristensen <ak@xxxxxxxxxxxxxxx>
Date: Mon, 26 Oct 1998 19:24:17 +0000
attribute value templates example
I just realized why this *does* matter but the example changes
slightly.  The original document is the same but we now we want to
produce the document

  <circle bg="..." fg="..."/>

where bg is the rgb value of the 'color' element with name 'green' and
fg is the rgb value of the 'color' element with name 'blue'. Since we're
producing a single element with attribute values which come from more
than one elements in the input doc we must select node (on attribute
value) and value in a single attribute value template.

Is this possible?

Regards,
Anders

Anders Kristensen wrote:
> 
> Hello,
> 
> Suppose I have a document of the form
> 
> <example>
>   <color name="red"   rgb="ff0000"/>
>   <color name="green" rgb="00ff00"/>
>   <color name="blue"  rgb="0000ff"/>
> </example>
> 
> 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)}"/>
>   </xsl:template>
> </xsl:stylesheet>
> 
> 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
> like
> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
>   <xsl:template match="example">
>     <col bg="{input[attribute(name)='green',attribute(rgb)]}"/>
>   </xsl:template>
> </xsl:stylesheet>
> 
> 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.
> 
> Regards,
> Anders
> 
> --
> Anders Kristensen <ak@xxxxxxxxxxxxxxx>,
> http://www-uk.hpl.hp.com/people/ak/
> Hewlett-Packard Labs, Bristol, UK


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


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.