Subject: Re: [xsl] why this expression: match="@foo='bar'" does not work with XT ? From: Mike Brown <mike@xxxxxxxx> Date: Sat, 6 Jan 2001 13:50:27 -0700 (MST) |
Mathieu Mangeot Lerebours wrote: > <xsl:template match="@foo='bar'"> As Ken Holman mentioned, the solution is <xsl:template match="@foo[.='bar']"> You also wanted to know what was wrong... @foo='bar' is an equality test. It evaluates to a boolean (true or false). So you are essentially saying this template matches nodes that are true or false. In an xsl:template's match attribute, you want a pattern: a subset of XPath expressions that essentially identify node-sets, not a boolean, and against which a given node can be tested for a match. For example if match="foo" then a given node will match if it is an element named foo. If match="fu/foo" then the node will match if it is an element named foo that is a child of an element named fu. The main difference between a regular XPath expression and a pattern here is that there is no current node; instead the processor is reading the pattern from right to left and verifying that the current node follows the pattern. The expression fu/foo would normally be the nodes that are, relative to the current node, something like current node --> child::fu --> child::foo. In a pattern, it is as if the node being tested is the current node, and means, essentially, current node --> self::foo[parent::fu] You don't really have to thoroughly get patterns. I have been working with them for nearly 2 years and they're still hard to explain. The important thing to understand is that an xsl:template match pattern is not an instruction to go find nodes. That's what xsl:apply-templates is for. The processor will have a node already, as a result of xsl:apply-templates, usually, and will be looking for a template that is a good match for it. - Mike ____________________________________________________________________ Mike J. Brown, software engineer at My XML/XSL resources: webb.net in Denver, Colorado, USA http://skew.org/xml/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] why this expression: matc, G. Ken Holman | Thread | [xsl] Any XSL-FO browser implementa, AndrewWatt2000 |
[xsl] bounced message, B. Tommie Usdin | Date | Re: [xsl] Any XSL-FO browser implem, MURAKAMI Shinyu |
Month |