Subject: Attribute value templates From: Anders Kristensen <ak@xxxxxxxxxxxxxxx> Date: Mon, 26 Oct 1998 19:09:46 +0000 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Doubts regarding XSL and DOM, keshlam | Thread | Re: Attribute value templates, Anders Kristensen |
Re: Beginners question: Koala XSL-E, keshlam | Date | Re: Attribute value templates, Anders Kristensen |
Month |