Subject: Re: [xsl] How to specify a path to a node in a nodeset using a variable From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Wed, 14 Mar 2001 17:14:08 +0000 |
Hi Shakeel, >> If you want to learn about XPath expressions, you should have a look >> at the XPath Recommendation at http://www.w3.org/TR/xpath. Or one of >> the online tutorials about them. > > The XPath TR contains just 5 references to '$' and another 5 > references to 'VariableReference'. There arent any examples or > explanation of VariableReference. Yeah, it has to be said that specs are usually clear as mud when it comes to learning anything. Online tutorials are probably better at explaining the basics. But anyway... VariableReference is defined in production 36 in XPath as: VariableReference ::= '$' QName In other words, it's a '$' followed by a qualified name. Qualified names sometimes look like 'foo' or sometimes look like 'foo:foo' - the ':' is used to separate the prefix from the local name. So '$container' is indeed a valid variable reference. > Can VariableReference contain VariableReferences? No (and I'm not sure what it would mean if it did?). The '$' that starts a variable reference isn't a valid QName character. > Can an expression contain more than one VariableReference? Sure, for example: $foo = $bar Variable references are primary expressions, so they can be used with operators or at the beginning of a path expression (which is what $container//account/person/@name is). You can't use a variable reference in the middle of a path expression (except within a predicate [i.e. square brackets in the path] - predicates can hold any expressions). So: $foo/$bar is illegal, although: $foo[$bar] is fine. The description of VariableReference is in Section 3.1 (http://www.w3.org/TR/xpath#section-Basics): "A VariableReference evaluates to the value to which the variable name is bound in the set of variable bindings in the context. It is an error if the variable name is not bound to any value in the set of variable bindings in the expression context." In other words, a variable reference resolves to the value of the named variable. The QName in the VariableReference production is that name. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to specify a path to , Shakeel Mahate | Thread | RE: [xsl] How to specify a path to , Michael Kay |
[xsl] ;), heavensky | Date | Re: [xsl] dash, YueMa |
Month |