There are times when you want XPath expressions to be evaluated (interpreted, resolved) and there are other times when you want expressions to be taken literally (literal expressions).
To accommodate these two needs, USoft Blend automatically evaluates expressions when it is likely that you want this, and in other cases does not. In those other cases, if you want evaluation, you must prompt the processor to evaluate the expression. You do that by embedding the expression in curly braces, turning it into what XSLT calls an Attribute Value Template.
USoft Blend automatically evaluates XPath expressions in attribute values in the following contexts:
•Values of select attributes. •Values of pc:return. •Values of attributes of the type assign:variable. Example
This example outputs the value c:\temp\temp2. Curly braces are NOT called for.
<pc:assign-var mysubdir="temp2">
<pc:value-of select="path:Combine('c:\temp',$mysubdir)"/>
|
|
If USoft Blend does not automatically evaluate but you want evaluation, you must surround the expression by curly braces ( { } ), which turns it into an Attribute Value Template (AVT). A limitation, in comparison with XSLT, is that USoft Blend only supports AVT braces surrounding the entire expression of the attribute value.
Example
This example deletes directory c:\temp\temp2. Curly braces ARE called for.
<pc:assign-var mysubdir="temp2">
<pc:DeleteDirectories>
<Directory dirpath="{path:Combine('c:\temp',$mysubdir)}" />
...
</pc:DeleteDirectories>
|
|
USoft Blend automatically interprets a select attribute value, as well as a value of an attribute of the assign:variable type, as an XPath location path representing a node set. For this reason, in these contexts, you must explicitly convert the expression if you mean to express not a node set but, for example, a string or a number.
Contrast the following 2 examples.
Example 1
In this example, xy is evaluated as an XPath expression: a relative location path. If the context node has one or more child elements named 'xy' then the string-value of the first 'xy' child element in document order is returned, following the XSLT specification.
<pc:value-of select="xy"> ... </pc:value-of>
|
Example 2
This example returns the character string 'xy'.
<pc:value-of select="'xy'" />
|
|
See also
Guide to expressions and data types
Literal expressions
Dates
string literals
Path expressions
XML expressions
XPath expressions
Node set expressions
Booleans
Strings
Numbers
Function calls
Variable references
Implicit XPath datatype conversion
Evaluated expressions vs. literals
SQL expressions
|