Re: Attribute value templates

Subject: Re: Attribute value templates
From: Anders Kristensen <ak@xxxxxxxxxxxxxxx>
Date: Mon, 26 Oct 1998 19:24:17 +0000
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